Skip to content

Instantly share code, notes, and snippets.

@bitbonk
bitbonk / Program.cs
Last active September 29, 2017 21:13
Host ScriptCs in a console application and install a script pack at startup
namespace ConsoleHostedScriptCs
{
using System;
using Common.Logging.Simple;
using NuGet;
using ScriptCs.Contracts;
using ScriptCs.Engine.Roslyn;
using ScriptCs.Hosting;
using PackageReference = ScriptCs.PackageReference;
@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"),