Skip to content

Instantly share code, notes, and snippets.

readonly Mock<ILog> log4netMock = new Mock<ILog>();
[Test]
public void SingleSendActionWithException_ErrorLoggedOnce()
{
Smock.Run(context =>
{
// Arrange
context.Setup(() => LogManager.GetLogger(It.IsAny<Type>())).Returns(log4netMock.Object);
@xplicit
xplicit / LogglyQueue.cs
Last active October 28, 2019 05:54
log4net mocking
public class LogglyQueue : StatisticsMessagingQueue
{
private static readonly ILog log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
public override bool SendAction(ActionMessage message)
{
....
}
}
@xplicit
xplicit / vscode-plugins.md
Last active May 13, 2018 15:53
VS Code usefull plugins

Useful plugins for VS Code

  • Msbuild Project tools
  • ESLint
  • npm
  • npm intellisence
  • Vue.js extension pack
  • Vetur - (vue tooling for VS Code)
  • docker
  • vscode-database
@xplicit
xplicit / main.cs
Created July 7, 2017 01:44
ServerEvents Host
using System.Threading;
using Funq;
using ServiceStack;
public class AppHost : AppSelfHostBase
{
public static ManualResetEvent ShouldQuit = new ManualResetEvent(false);
@xplicit
xplicit / main.cs
Created June 26, 2017 21:55
Leading Zeroes Deserialization
using System.Globalization;
using ServiceStack.Text;
using System;
JsConfig<Int32>.DeSerializeFn = x => Int32.Parse(x, CultureInfo.InvariantCulture);
var result = JsonSerializer.DeserializeFromString("011",typeof(Int32));
// Save a copy of this *public* Gist by clicking the "Save As" below
@xplicit
xplicit / main.cs
Created March 10, 2017 12:38
OrmLite Join
using ServiceStack;
using ServiceStack.Text;
using ServiceStack.OrmLite;
using ServiceStack.OrmLite.Sqlite;
using ServiceStack.DataAnnotations;
var dbFactory = new OrmLiteConnectionFactory(":memory:", SqliteDialect.Provider);
var db = dbFactory.Open(); // Open ADO.NET DB Connection
public class Todo
#!/bin/bash
sudo apt-get update
sudo apt-get install -y git
sudo sh -c 'echo "deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/dotnet-release/ xenial main" > /etc/apt/sources.list.d/dotnetdev.list'
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 417A0893
sudo apt-get update
sudo apt-get install -y dotnet-dev-1.0.0-preview2.1-003177
mkdir -p /var/www/netcore && chown -R www-data:www-data /var/www
su -c "cd /var/www/netcore && git clone https://github.com/NetCoreApps/Hello" -s /bin/sh www-data
find /var/www/netcore/Hello -type f -name "Program.cs" -exec sed -i "s/UseStartup<Startup>()/UseStartup<Startup>().UseUrls(\"http:\/\/0.0.0.0:5050\")/g" {} +
using System;
using System.Threading;
using ServiceStack;
using ServiceStack.Text;
var useUtc = JsConfig.AlwaysUseUtc;
TestClass t1 = new TestClass(){A=5, B="Hello"};
t1.TC2 = new TestClass2(){A2="Hello from TestClass2", B2=10};
@xplicit
xplicit / Main.cs
Last active May 31, 2016 12:00
Compute MD5 hash
//Compute md5
using System.Security.Cryptography;
using System.Text;
string code = "Hello, World!";
string hash;
using (MD5 md5 = MD5.Create())
{
byte[] retVal = md5.ComputeHash(Encoding.Unicode.GetBytes(code));
using System;
using System.IO;
using System.Threading;
for(int i=0;i<10;i++)
{
Console.WriteLine("i={0}",i);
Thread.Sleep(1000);
}