Skip to content

Instantly share code, notes, and snippets.

View margusmartsepp's full-sized avatar
😇
It is that simple

Margus Martsepp margusmartsepp

😇
It is that simple
  • Gunvor SA
  • Tallinn
View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@margusmartsepp
margusmartsepp / example.cs
Created September 2, 2016 11:28
Selenium acceptance test example
private static string _homepage = "http://rkr.devel.aedes.ee/";
[Test]
[TestCase("xxxx?-*", "Teie otsingul ei olnud tulemusi.")]
public void ReadPivot(string searchItem, string expectedResult)
{
using (var d = new ChromeDriver())
{
// Arrange
d.Navigate().GoToUrl(_homepage);
using System;
using UnityEngine;
using System.Collections;
using System.Linq;
using System.Text;
using UnityEngine.UI;
using Object = UnityEngine.Object;
public class SearchBehaviour : MonoBehaviour
{
public static class IdentityUtil
{
public static string GetCurrentIdentityDomainName()
{
var identity = WindowsIdentity.GetCurrent();
if (identity == null || !identity.IsAuthenticated || identity.IsSystem)
return null;
return GetDomainName(identity.Name);
}
@margusmartsepp
margusmartsepp / ISpecification.cs
Last active May 24, 2016 15:30
Generic Specification pattern
using System;
using System.Linq.Expressions;
namespace GenericSpecificationPattern
{
public interface ISpecification<T>
{
Expression<Func<T, bool>> Act { get; }
bool IsSatisfiedBy(T entity);
}
@margusmartsepp
margusmartsepp / program.cs
Created April 27, 2016 11:57
Is date after epoch
/// <summary>
/// https://en.wikipedia.org/wiki/Epoch_(reference_date)
/// </summary>
public static class DateTimeValidator
{
public static DateTime Epoch => Epoch1900;
public readonly static DateTime Epoch1900 = new DateTime(1900, 1, 1);
public readonly static DateTime EpochSqlDateTime = (DateTime)SqlDateTime.MinValue;
public static bool IsValid(DateTime dateTime)
@margusmartsepp
margusmartsepp / program.cs
Created April 25, 2016 11:42
dapper example
private static SqlConnection GetDatabaseConnection()
{
var connectionString = ConfigurationManager.ConnectionStrings["exampleEntities"].ConnectionString;
var csBuilder = new EntityConnectionStringBuilder(connectionString);
var connection = new SqlConnection(csBuilder.ProviderConnectionString);
return connection;
}
public static void Analyze()
{
@margusmartsepp
margusmartsepp / IRepository.cs
Created April 19, 2016 16:55
EF4 linq to sql repository interface
public interface IRepository<T>
{
IQueryable<T> Filter(Expression<Func<T, bool>> predicate);
int Insert(T entity);
int Delete(T entity);
int Save();
}
@margusmartsepp
margusmartsepp / Program.cs
Created April 19, 2016 07:25
LINQPad load test statistics aggregation example
void Main()
{
foreach(var run in LoadTestRuns
.Where(o=> o.LoadTestName == "baseline" && o.RunDuration == 7200)
.Select(o=> new {o.LoadTestRunId, o.StartTime, o.EndTime})
){
run.Dump();
var testruns = run.LoadTestRunId;
var failedTests = LoadTestMessageView2
.Where(o=>o.LoadTestRunId==testruns && o.TestCaseName!=null)
@margusmartsepp
margusmartsepp / web.config
Created April 18, 2016 14:16
Monitor asmx service with fiddler
<system.net>
<defaultProxy>
<proxy bypassonlocal="False" usesystemdefault="True" proxyaddress="http://127.0.0.1:8888" />
</defaultProxy>
</system.net>