public void Must_correctly_merge_two_clocks()
{
var node1 = VectorClock.Node.Create("1");
var node2 = VectorClock.Node.Create("2");
var node3 = VectorClock.Node.Create("3");
var clock1_1 = VectorClock.Create();
var clock2_1 = clock1_1.Increment(node1);
var clock3_1 = clock2_1.Increment(node2);
var clock4_1 = clock3_1.Increment(node2);
var clock5_1 = clock4_1.Increment(node3);
var clock1_2 = clock4_1;
var clock2_2 = clock1_2.Increment(node2);
var clock3_2 = clock2_2.Increment(node2);
var merged1 = clock3_2.Merge(clock5_1);
Assert.Equal(3, merged1.Versions.Count);
Assert.True(merged1.Versions.ContainsKey(node1));
Assert.True(merged1.Versions.ContainsKey(node2));
Assert.True(merged1.Versions.ContainsKey(node3));
var merged2 = clock5_1.Merge(clock3_2);
Assert.Equal(3, merged2.Versions.Count);
Assert.True(merged2.Versions.ContainsKey(node1));
Assert.True(merged2.Versions.ContainsKey(node2));
Assert.True(merged2.Versions.ContainsKey(node3));
Assert.True(clock3_2.IsBefore(merged1));
Assert.True(clock5_1.IsBefore(merged1));
Assert.True(clock3_2.IsBefore(merged2));
Assert.True(clock5_1.IsBefore(merged2));
Assert.True(merged1.IsSameAs(merged2));
}