Skip to content

Instantly share code, notes, and snippets.

View damianh's full-sized avatar
💥

Damian Hickey damianh

💥
View GitHub Profile
@damianh
damianh / gist:3722548
Created September 14, 2012 15:15
Nancy on Microsoft.HttpListener.Owin
using System;
using System.Collections.Generic;
using Microsoft.HttpListener.Owin;
using Nancy.Hosting.Owin;
namespace Spike
{
internal class Program
{
private static void Main(string[] args)
@damianh
damianh / gist:3839789
Created October 5, 2012 13:23
Send all Raven logs to null target
var config = new LoggingConfiguration();
var nullTarget = new NullTarget();
config.AddTarget("NullTarget", nullTarget);
config.LoggingRules.Add(new LoggingRule("Raven.*", LogLevel.Debug, nullTarget) { Final = true });
@damianh
damianh / gist:4214487
Created December 5, 2012 10:14 — forked from SimonCropp/gist:4214439
LogParamsOnException
Before
public class SimpleClass
{
[LogParamsOnException(LogLevel.Info)]
void Method(string param1, int param2)
{
//Do Stuff
}
@damianh
damianh / gist:4215137
Created December 5, 2012 12:26
RavenDB Contains Query Test
public class ContainsQueryTests : IDisposable
{
private readonly IDocumentStore _documentStore;
public ContainsQueryTests()
{
_documentStore = new EmbeddableDocumentStore {RunInMemory = true}.Initialize();
using (IDocumentSession session = _documentStore.OpenSession())
{
session.Store(new TestDocument
@damianh
damianh / WebApplication.cs
Last active December 11, 2015 04:39
WebApplication.Start suggestion
public interface IWebApplication : IDisposable
{
public Func<IDictionary<string, object>, Task> AppFunc { get; }
public string Url { get; }
}
// Start an app listen = false so that it is pure in-proc for testing.
using(IWebApplication webApp = WebApplication.Start(
builder => builder.UseThing(_foo),
@damianh
damianh / FastInMemoryPersistenceEngine.cs
Last active December 14, 2015 22:49
Alternative InMemory Eventstore persistence engine that does not contain statics and better performing. For the log statements, supply your own resources or remove them.
/*
Usage:
_storeEvents = Wireup
.Init()
.UsingFastInMemoryPersistence()
.InitializeStorageEngine()
.etc...
*/
// ReSharper disable CheckNamespace
namespace Microsoft.Owin.Testing.Tests
{
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Xunit;
public class TestServerTests
{
@damianh
damianh / WindowChromeExample.xml
Created June 26, 2013 12:04
The XAML in http://msdn.microsoft.com/en-us/library/system.windows.shell.windowchrome.aspx is copied from the Microsoft.Windows.Shell project but hasn't been updated to reflect the new namespace in .net 4.5. This is the correct XAML.
<Style TargetType="{x:Type local:MainWindow}">
<Setter Property="WindowChrome.WindowChrome">
<Setter.Value>
<WindowChrome />
</Setter.Value>
</Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:MainWindow}">
<Grid>
namespace TestinNancyWithOwinTesting
{
using System;
using System.Net.Http;
using System.Threading.Tasks;
using Nancy;
using Nancy.Bootstrapper;
using Nancy.Testing;
using Owin;
using Microsoft.Owin.Testing;
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
namespace Microsoft.Owin.FileSystems
{
/// <summary>