public void Parse_should_return_dvv_with_no_events_in_causal_history() { const string input = "((r,3),{})"; var dvv = DottedVersionVector.Parse(input); // Assert dvv.ToString().Should().Be(input); }
public void MaxDot_should_return_the_max_counter_for_a_server_id_not_found() { const string input = "((r,3),{(s,1),(t,5)})"; var dvv = DottedVersionVector.Parse(input); long counter = dvv.MaxDot("x"); counter.Should().Be(0); }
public void Ids_should_return_set_of_identifiers() { const string input = "((r,3),{(s,1),(t,5)})"; var dvv = DottedVersionVector.Parse(input); var ids = dvv.Ids(); ids.Should().Contain(new[] { "r", "s", "t" }); ids.Should().HaveCount(3); ids.Should().OnlyHaveUniqueItems(); }
public void MaxDot_should_return_the_max_counter_for_a_server_id_not_found() { var clocks = new Siblings { { new JObject(new JProperty("v", 1)), DottedVersionVector.Parse("((r,1),{})") }, { new JObject(new JProperty("v", 2)), DottedVersionVector.Parse("((r,2),{})") }, { new JObject(new JProperty("v", 1)), DottedVersionVector.Parse("((s,5),{(t,4)})") }, }; long counter = clocks.MaxDot("x"); counter.Should().Be(0); }
public void Sync_should_return_s1_when_input_s1_and_s1() { var kernel = new DvvKernel(); var s1 = new Siblings { { new JObject(new JProperty("v", 1)), "((r,1),{})" } }; var siblings = kernel.Sync(s1, s1); // Assert siblings.Should().HaveCount(1); siblings.Should().Contain(x => x.Clock.Equals(DottedVersionVector.Parse("((r,1),{})"))); }
public void Ids_should_return_set_of_identifiers() { var clocks = new Siblings { { new JObject(new JProperty("v", 1)), DottedVersionVector.Parse("((r,1),{})") }, { new JObject(new JProperty("v", 2)), DottedVersionVector.Parse("((r,2),{})") }, { new JObject(new JProperty("v", 1)), DottedVersionVector.Parse("((s,1),{(t,4)})") }, }; var ids = clocks.Ids(); ids.Should().Contain(new[] { "r", "s", "t" }); ids.Should().HaveCount(3); ids.Should().OnlyHaveUniqueItems(); }
public void Event_should_generate_a_new_clock_to_represent_a_new_version() { var kernel = new DvvKernel(); var context = new VersionVector(new[] { new CausalEvent("s", 2), new CausalEvent("r", 2), }); var s1 = new Siblings { { new JObject(new JProperty("v", 1)), "((r,1),{})" }, { new JObject(new JProperty("v", 2)), "((r,2),{(s,2)})" } }; DottedVersionVector dvv = kernel.Event(context, s1, "r"); dvv.ToString().Should().Be("((r,3),{(r,2),(s,2)})"); }
public void Discard_should_remove_obsolete_siblings() { var kernel = new DvvKernel(); var s1 = new Siblings { { new JObject(new JProperty("v", 1)), "((r,1),{})" }, { new JObject(new JProperty("v", 2)), "((r,2),{})" } }; // This is the context we'd receive representing ((r,3),{(r,1)}) : v3 var context = new VersionVector(new CausalEvent("r", 1)); Siblings siblings = kernel.Discard(s1, context); // Assert siblings.Should().HaveCount(1); siblings.Should().NotContain(x => x.Clock.Equals(DottedVersionVector.Parse("((r,1),{})"))); siblings.Should().Contain(x => x.Clock.Equals(DottedVersionVector.Parse("((r,2),{})"))); }
public void Sync_should_return_concurrent_siblings() { var kernel = new DvvKernel(); var s1 = new Siblings { { new JObject(new JProperty("v", 1)), "((r,1),{})" }, { new JObject(new JProperty("v", 2)), "((r,2),{})" } }; var s2 = new Siblings { { new JObject(new JProperty("v", 3)), "((r,3),{(r,1)})" } }; var siblings = kernel.Sync(s1, s2); // Assert siblings.Should().HaveCount(2); siblings.Should().NotContain(x => x.Clock.Equals(DottedVersionVector.Parse("((r,1),{})"))); siblings.Should().Contain(x => x.Clock.Equals(DottedVersionVector.Parse("((r,2),{})"))); siblings.Should().Contain(x => x.Clock.Equals(DottedVersionVector.Parse("((r,3),{(r,1)})"))); }