public void Remove_Concurrent_AddsOnlyOneElementToRemoveSet(TestType value, Guid tag, long timestamp) { var ourSet = new OUR_OptimizedSet <TestType>(); ourSet = ourSet.Add(value, tag, timestamp); ourSet = ourSet.Remove(value, tag, timestamp); ourSet = ourSet.Remove(value, tag, timestamp); var element = new OUR_OptimizedSetElement <TestType>(value, tag, timestamp, true); Assert.Equal(1, ourSet.Elements.Count(v => Equals(v, element))); }
public void Remove_BeforeAdd_HasNoEffect(TestType value, Guid tag, long timestamp) { var ourSet = new OUR_OptimizedSet <TestType>(); var newOrSet = ourSet.Remove(value, tag, timestamp); Assert.Same(ourSet, newOrSet); }
public void Values_ReturnsNonRemovedValues(TestType one, TestType two, TestType three, Guid tagOne, Guid tagTwo, Guid tagThree, long timestamp) { var ourSet = new OUR_OptimizedSet <TestType>(); ourSet = ourSet.Add(one, tagOne, timestamp); ourSet = ourSet.Add(one, tagTwo, timestamp + 1); ourSet = ourSet.Remove(one, tagTwo, timestamp + 2); ourSet = ourSet.Add(two, tagTwo, timestamp + 3); ourSet = ourSet.Add(two, tagOne, timestamp + 4); ourSet = ourSet.Remove(two, tagOne, timestamp + 5); ourSet = ourSet.Remove(three, tagThree, timestamp + 6); ourSet = ourSet.Add(three, tagThree, timestamp + 7); ourSet = ourSet.Remove(three, tagThree, timestamp + 8); var actualValues = ourSet.Values; Assert.Equal(2, actualValues.Count); Assert.Contains(one, actualValues); Assert.Contains(two, actualValues); }
public void Lookup_AddedAndRemoved_ReturnsFalse(TestType value, Guid tag, long timestamp) { var ourSet = new OUR_OptimizedSet <TestType>(); ourSet = ourSet.Add(value, tag, timestamp); ourSet = ourSet.Remove(value, tag, timestamp + 1); var lookup = ourSet.Lookup(value); Assert.False(lookup); }
public void Remove_AddsElementToRemovesSet(TestType value, Guid tag, long timestamp) { var ourSet = new OUR_OptimizedSet <TestType>(); ourSet = ourSet.Add(value, tag, timestamp); ourSet = ourSet.Remove(value, tag, timestamp); var element = new OUR_OptimizedSetElement <TestType>(value, tag, timestamp, true); Assert.Contains(element, ourSet.Elements); }
public void Lookup_SameValueWithSeveralTags_ReturnsTrue(TestType value, Guid tag, long timestamp) { var ourSet = new OUR_OptimizedSet <TestType>(); ourSet = ourSet.Add(value, tag, timestamp); ourSet = ourSet.Add(value, Guid.NewGuid(), timestamp + 1); ourSet = ourSet.Remove(value, tag, timestamp + 2); var lookup = ourSet.Lookup(value); Assert.True(lookup); }
public void Lookup_AddedRemovedAndUpdated_ReturnsTrue(TestType value, Guid tag, long timestamp) { var ourSet = new OUR_OptimizedSet <TestType>(); ourSet = ourSet.Add(value, tag, timestamp); ourSet = ourSet.Remove(value, tag, timestamp + 1); var newValue = _builder.Build(value.Id); ourSet = ourSet.Update(newValue, tag, timestamp + 1); var lookup = ourSet.Lookup(newValue); Assert.True(lookup); }