Skip to content

Instantly share code, notes, and snippets.

View yreynhout's full-sized avatar
👔
ceci n'est pas une cravate

Yves Reynhout yreynhout

👔
ceci n'est pas une cravate
View GitHub Profile
[assembly: AggregateSource.GEventStore.GEventStoreIntegration]
//Factory Assert impl
var result1 = specification1.When(specification1.SutFactory());
var succeeded1 = result1.GetChanges().SequenceEqual(specification1.Thens);
//Command Assert impl
var sut5 = specification5.SutFactory();
specification5.When(sut5);
var succeeded5 = sut5.GetChanges().SequenceEqual(specification5.Thens);
public class ImmutableXYZ {
public ImmutableXYZ() {
abc = "";
def = 0;
haha = -1;
}
ImmutableXYZ(string abc, int def, int haha) {
this.abc = abc;
this.def = def;
@yreynhout
yreynhout / RolloutPeriod.cs
Created May 24, 2013 10:18
Why a value object is not a datastructure ...
public static class LocalClock {
public static LocalDate Today {
get { return Now.Date; }
}
public static LocalDateTime Now {
get {
return SystemClock.Instance.Now.InZone(BclDateTimeZone.ForSystemDefault()).LocalDateTime;
}
}
namespace WhenSpecificationMeetsStructuralInspection {
//Read it like a story, the best part is the ending ...
public interface ISpecification<T> {
bool IsSatisfiedBy(T instance);
}
public class AndSpecification<T> : ISpecification<T> {
readonly ISpecification<T> leftOperand;
readonly ISpecification<T> rightOperand;
namespace WhenSpecificationMeetsStructuralInspection {
public interface ISpecification<T> {
bool IsSatisfiedBy(T instance);
}
public abstract class Specification<T> : ISpecification<T> {
public static Specification<T> operator &(Specification<T> leftOperand, Specification<T> rightOperand) {
return new AndSpecification<T>(leftOperand, rightOperand);
}
using NodaTime;
namespace FluentNodaTime {
public static class LocalTimeFluentSyntax {
public static LocalTime Hour(this int hour) {
return new LocalTime(hour, 0);
}
public static LocalTime Hour(this int hour, int minute) {
return new LocalTime(hour, minute);
public class MethodUnderTestBuilder() {
public IABCFactory ABCDependency { get; private set; }
public IXYZService XYZDependency { get; private set; }
YourSUT _sut;
Foo _foo;
Bar _bar;
public MethodUnderTestBuilder() {
//Configure the happy path
[Test]
public void ConstructorSucceeeds()
{
var id = new ConcertId(Guid.NewGuid());
new ConstructorScenario(() => Concert.New(id))
.Then(ConcertEvents.Planned(id))
.Assert();
}
@yreynhout
yreynhout / FutureOfTesting.cs
Created July 29, 2013 09:13
N/XUnit integration, sharing of runner logic, explicit result, ... current ramblings.
public interface IEventCentricAggregateCommandTestRunner
{
EventCentricAggregateCommandTestResult Run(EventCentricAggregateCommandTestSpecification specification);
}
public class EventCentricAggregateCommandTestRunner : IEventCentricAggregateCommandTestRunner
{
readonly IEqualityComparer<object> _comparer;
public EventCentricAggregateCommandTestRunner(IEqualityComparer<object> comparer)