public void Remove_BeforeAdd_HasNoEffect(TestType value) { var pSet = new P_OptimizedSet <TestType>(); var newPSet = pSet.Remove(value); Assert.Same(pSet, newPSet); }
public void Add_Concurrent_AddsOnlyOneElement(TestType value) { var pSet = new P_OptimizedSet <TestType>(); pSet = pSet.Add(value); pSet = pSet.Add(value); Assert.Equal(1, pSet.Elements.Count(v => Equals(v.Value, value))); }
public void Lookup_AddedAndNotRemoved_ReturnsTrue(TestType value) { var pSet = new P_OptimizedSet <TestType>(); pSet = pSet.Merge(new[] { new P_OptimizedSetElement <TestType>(value, false) }.ToImmutableHashSet()); var lookup = pSet.Lookup(value); Assert.True(lookup); }
public void Lookup_AddedAndNotRemoved_ReturnsTrue(TestType value) { var pSet = new P_OptimizedSet <TestType>(); pSet = pSet.Add(value); var lookup = pSet.Lookup(value); Assert.True(lookup); }
public void Add_AddsElementToAddsSet(TestType value) { var pSet = new P_OptimizedSet <TestType>(); pSet = pSet.Add(value); var expectedElement = new P_OptimizedSetElement <TestType>(value, false); Assert.Contains(expectedElement, pSet.Elements); }
public void Lookup_ReAdded_ReturnsFalse(TestType value) { var pSet = new P_OptimizedSet <TestType>(); pSet = pSet.Add(value); pSet = pSet.Remove(value); pSet = pSet.Add(value); var lookup = pSet.Lookup(value); Assert.False(lookup); }
public void Create_CreatesSetWithElements(P_OptimizedSetElement <TestType> one, P_OptimizedSetElement <TestType> two, P_OptimizedSetElement <TestType> three) { var elements = new[] { one, two, three }.ToImmutableHashSet(); var pSet = new P_OptimizedSet <TestType>(elements); Assert.Equal(elements.Count, pSet.Elements.Count); foreach (var add in elements) { Assert.Contains(add, pSet.Elements); } }
public void Remove_AddsRemovedFlagToElement(TestType value) { var pSet = new P_OptimizedSet <TestType>(); pSet = pSet.Add(value); pSet = pSet.Remove(value); var expectedElement = new P_OptimizedSetElement <TestType>(value, true); var notExpectedElement = new P_OptimizedSetElement <TestType>(value, false); Assert.Contains(expectedElement, pSet.Elements); Assert.DoesNotContain(notExpectedElement, pSet.Elements); }
public void Merge_MergesAddsAndRemoves(TestType one, TestType two, TestType three) { var elementOne = new P_OptimizedSetElement <TestType>(one, false); var elementTwo = new P_OptimizedSetElement <TestType>(two, true); var elementThree = new P_OptimizedSetElement <TestType>(one, true); var elementFour = new P_OptimizedSetElement <TestType>(three, false); var pSet = new P_OptimizedSet <TestType>(new[] { elementOne, elementTwo }.ToImmutableHashSet()); var newPSet = pSet.Merge(new[] { elementThree, elementFour }.ToImmutableHashSet()); Assert.Equal(4, newPSet.Elements.Count); Assert.Contains(newPSet.Elements, e => Equals(e, elementOne)); Assert.Contains(newPSet.Elements, e => Equals(e, elementTwo)); Assert.Contains(newPSet.Elements, e => Equals(e, elementThree)); Assert.Contains(newPSet.Elements, e => Equals(e, elementFour)); }