Skip to content

Instantly share code, notes, and snippets.

View JefClaes's full-sized avatar

Jef Claes JefClaes

View GitHub Profile
@JefClaes
JefClaes / gist:6794475
Created October 2, 2013 14:16
ES Demo snippet
using System;
using System.Collections.Generic;
namespace EventSourcing
{
public class Program
{
public static void Main(string[] args)
{
var acc = new Account();
@JefClaes
JefClaes / gist:5458289
Created April 25, 2013 08:20
Also makes for clean controller tests.
[TestClass()]
public class ConfirmationModuleTest
{
private Mock<IBus> _bus;
private Browser _browser;
[TestInitialize]
public void Setup()
{
_bus = new Mock<IBus>();
@JefClaes
JefClaes / gist:5458275
Last active December 16, 2015 15:49
I do something very similar to what @tjaskula is doing. I approve!
public class ConfirmationModule : NancyModule
{
public ConfirmationModule(IBus bus)
{
Get["confirm/done"] = p =>
{
return View["ConfirmationDone"];
};
@JefClaes
JefClaes / gist:5375605
Created April 12, 2013 22:16
Best attempt at four eyes principal
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json;
using Ninject;
namespace ModelingFourEyes
{
@JefClaes
JefClaes / gist:5301262
Created April 3, 2013 13:36
Four eyes principle applied with commands
1. When the user adds an accountnumber, a command gets sent which isn't handled yet.
2. When a supervisor logs on, he gets a list of commands to approve or decline, including the AddAccountNumber.
3. When the supervisor approves the AddAccountNumber command, it will be handled.
@JefClaes
JefClaes / gist:5039087
Last active December 14, 2015 05:59
Queries
namespace Infrastructure
{
public interface IQueryHandler<TIn, TOut>
where TIn : class
where TOut : class
{
TOut Execute(TIn query);
}
}
@JefClaes
JefClaes / gist:4716622
Created February 5, 2013 18:44
Naïve ES take 1
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NaiveEventSourcing
{
class Program
{
static void Main(string[] args)
@JefClaes
JefClaes / gist:4505798
Created January 10, 2013 21:06
Stacktrace WebMatrix crash - for @JustinBeckwith
The UI first reported an NPM error on installing twitter-bootstrap-node, but there were no details in the dialog. Ignoring that, WebMatrix crashed a bit after.
I found this in the eventlog.
PROCESS_CRASH
The process terminated unexpectedly.
Exception:System.AggregateException: A Task's exception(s) were not observed either by Waiting on the Task or accessing its Exception property. As a result, the unobserved exception was rethrown by the finalizer thread. ---> System.AggregateException: One or more errors occurred. ---> NodeNpm.NpmException: Failed: npm reported an error.
at NodeNpm.NpmApi.ListChildren()
@JefClaes
JefClaes / gist:4366674
Created December 23, 2012 23:21
Quick-and-dirty errorhandler
public class LoggingErrorHandler : IErrorHandler
{
public void Handle(Nancy.HttpStatusCode statusCode, Nancy.NancyContext context)
{
object error;
var gotException = context.Items.TryGetValue(NancyEngine.ERROR_EXCEPTION, out error);
if (!gotException)
return;
@JefClaes
JefClaes / gist:4363612
Created December 23, 2012 14:17
Attempt to not have to separate command and command data to get some DI going. Most commands don't have dependencies which need to be injected (RavenDB in-memory store).
public class CommandHandler : ICommandHandler
{
private IKernel _kernel;
public CommandHandler() { }
public CommandHandler(IKernel kernel)
{
_kernel = kernel;
}