Created
April 20, 2012 15:58
-
-
Save haf/2429892 to your computer and use it in GitHub Desktop.
Disjoint Commands
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[TestFixture(typeof(Customer), typeof(DocMeta), ... etc)] | |
class AllDisjointCmds<T> where T : AggregateRoot, new() { | |
AggregateRoot F(Command applyFirst, Command applySecond) { | |
var t = new T(); | |
t.CallWith(applyFirst); | |
t.CallWith(applySecond); | |
return t; | |
} | |
[Test] | |
public void PrintAll() { | |
var cmds = typeof(AllDisjointCmds).Assembly | |
.GetTypes() | |
.Where(t => t.IsCommand()) | |
.Select(t => FastActivator.Create(t) as Command); | |
foreach (var c1 in cmds) | |
foreach (var c2 in cmds) { | |
var opt1 = F(c1, c2) | |
var opt2 = F(c2, c1) | |
if (InternalStateOfAllFields(opt1).Equals(InternalStateOfAllFields(opt2) | |
&& opt1.UncommittedEvents.SequenceEquals(opt2.UncommittedEvents, CompareOptions.IncludeEventProperties)) | |
Console.WriteLine("{0} and {1} are disjoint", c1, c2); | |
else Console.WriteLine("{0} and {1} are NOT disjoint", c1, c2); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment