public void AddNew() { LwwElementSet <string> set = new LwwElementSet <string>(Bias.Add); string item1 = "Test"; set.Add(item1, 1); set.Add(item1, 2); Assert.Single(set._adds); Assert.Equal(2, set._adds[item1]); Assert.Empty(set._removes); Assert.Single(set); Assert.Equal(item1, set.First()); }
public void RemoveOldAfterNewAdd() { LwwElementSet <string> set = new LwwElementSet <string>(Bias.Add); string item1 = "Test"; set.Add(item1, 1); set.Remove(item1, 0); Assert.Single(set._adds); Assert.Single(set._removes); Assert.Equal(1, set._adds[item1]); Assert.Equal(0, set._removes[item1]); Assert.Single(set); Assert.Equal(item1, set.First()); }
public void RemoveSameAfterSameAdd() { LwwElementSet <string> set = new LwwElementSet <string>(Bias.Add); string item1 = "Test"; set.Add(item1, 1); set.Remove(item1, 1); Assert.Single(set._adds); Assert.Single(set._removes); Assert.Equal(1, set._adds[item1]); Assert.Equal(1, set._removes[item1]); // Bias toward add Assert.Single(set); Assert.Equal(item1, set.First()); // Test the other bias set = new LwwElementSet <string>(Bias.Remove); set.Add(item1, 1); set.Remove(item1, 1); Assert.Empty(set); }