Skip to content

Instantly share code, notes, and snippets.

@bitbonk
bitbonk / Program.cs
Last active August 29, 2015 14:18
Debugging dynmically created scriptcs source code string in a hosted environment
namespace DebugStringConsoleHosted
{
using System.IO;
using System.Linq;
using Common.Logging.Simple;
using ScriptCs.Contracts;
using ScriptCs.Engine.Roslyn;
using ScriptCs.Hosting;
internal class Program
@bitbonk
bitbonk / TinyBootstrapper.cs
Last active August 29, 2015 14:19
Minimal Calibrun.Micro Bootstrapper Implementation that uses TinyIoC
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Windows;
using Caliburn.Micro;
using TinyIoC;
public class TinyBootstrapper : BootstrapperBase
{
@bitbonk
bitbonk / Model
Created May 8, 2015 20:16
ACL (Access Control List) in DDD (with CQS)
namespace UserManagement.Model
{
namespace Query
{
using System;
using System.Collections.Generic;
public class User
{
/// <summary>
public void Configure(IAppBuilder appBuilder)
{
this.container.RegisterSingle<ITodoRepository>(() => new TodoDatabase(this.slowness, this.todoCount));
var httpConfig = new HttpConfiguration();
httpConfig.Routes.MapHttpRoute(
"DefaultApi",
"{controller}/{id}",
new { id = RouteParameter.Optional });
httpConfig.DependencyResolver = new SimpleInjectorDependencyResolver(this.container);
private void ConfigureLogging()
{
this.log = this.loggerConfiguration.CreateLogger().ForContext<DefaultBootstrapper>();
LogManager.GetLog = type => new CaliburnSerilogAdapter(this.log.ForContext(type));
LogContext.PushProperty("a", 1);
this.log.Information("template", this, null, new Uri("http://google.de"));
this.log.ForContext(typeof(string)).Information("template2", this, null, new Uri("http://bing.com"));
}
[Fact]
public void AssertNestedInnerException()
{
var expectedException = new Exception();
new Action(
() =>
{
throw new InvalidOperationException("", new KeyNotFoundException("", expectedExcpetion));
})
[TestMethod]
public void AssertNestedInnerException()
{
var expectedExcpetion = new Exception();
new Action(
() =>
{
throw new InvalidOperationException("", new KeyNotFoundException("", expectedExcpetion));
})
[TestMethod]
public void AssertNestedInnerException()
{
var expectedExcpetion = new Exception();
new Action(
() =>
{
throw new InvalidOperationException("", new KeyNotFoundException("", expectedExcpetion));
})
@bitbonk
bitbonk / PareserTests.cs
Last active November 30, 2015 18:15
Can I have one Should() instead of two?
using System;
using System.Collections;
using System.Linq;
using FluentAssertions;
using Xunit;
public class ParserTests
{
[Theory,
InlineData(DataType.String, "foo", "foo"),
@bitbonk
bitbonk / Test.cs
Last active February 5, 2016 11:00
slow assertion
// The Property Culture is of type CultureInfo
enumarableOfComplexObject.ShouldAllBeEquivalentTo(
new[]
{
new { RefText = "Ref1", Culture = Invariant, Text = "Ref1 en", Component = string.Empty },
new { RefText = "Ref3", Culture = Invariant, Text = "Ref3 en", Component = string.Empty },
new { RefText = "Ref1", Culture = German, Text = "Ref1 de", Component = string.Empty },
new { RefText = "Ref3", Culture = German, Text = "Ref3 de", Component = string.Empty },
new { RefText = "Ref1", Culture = English, Text = "Ref1 en", Component = string.Empty },
new { RefText = "Ref3", Culture = English, Text = "Ref3 en", Component = string.Empty },