예제 #1
0
        public void Remove_Concurrent_AddsOnlyOneElementToRemoveSet(TestType value, Guid tag, Node node)
        {
            var clock = ImmutableSortedDictionary <Node, long> .Empty;

            var ourSet = new OUR_SetWithVC <TestType>();

            ourSet = ourSet.Add(value, tag, new VectorClock(clock.Add(node, 0)));
            ourSet = ourSet.Remove(value, tag, new VectorClock(clock.Add(node, 0)));
            ourSet = ourSet.Remove(value, tag, new VectorClock(clock.Add(node, 0)));

            var element = new OUR_SetWithVCElement <TestType>(value, tag, new VectorClock(clock.Add(node, 0)));

            Assert.Equal(1, ourSet.Removes.Count(v => Equals(v, element)));
        }
예제 #2
0
        public void Remove_BeforeAdd_HasNoEffect(TestType value, Guid tag, Node node)
        {
            var clock = ImmutableSortedDictionary <Node, long> .Empty;

            var ourSet = new OUR_SetWithVC <TestType>();

            var newOrSet = ourSet.Remove(value, tag, new VectorClock(clock.Add(node, 0)));

            Assert.Same(ourSet, newOrSet);
        }
예제 #3
0
        public void Values_ReturnsNonRemovedValues(TestType one, TestType two, TestType three, Guid tagOne, Guid tagTwo, Guid tagThree, Node node)
        {
            var clock = ImmutableSortedDictionary <Node, long> .Empty;

            var ourSet = new OUR_SetWithVC <TestType>();

            ourSet = ourSet.Add(one, tagOne, new VectorClock(clock.Add(node, 0)));
            ourSet = ourSet.Add(one, tagTwo, new VectorClock(clock.Add(node, 0)));
            ourSet = ourSet.Remove(one, tagTwo, new VectorClock(clock.Add(node, 0)));
            ourSet = ourSet.Add(two, tagTwo, new VectorClock(clock.Add(node, 0)));
            ourSet = ourSet.Add(two, tagOne, new VectorClock(clock.Add(node, 0)));
            ourSet = ourSet.Remove(two, tagOne, new VectorClock(clock.Add(node, 0)));
            ourSet = ourSet.Remove(three, tagThree, new VectorClock(clock.Add(node, 0)));
            ourSet = ourSet.Add(three, tagThree, new VectorClock(clock.Add(node, 0)));
            ourSet = ourSet.Remove(three, tagThree, new VectorClock(clock.Add(node, 0)));

            var actualValues = ourSet.Values;

            Assert.Equal(2, actualValues.Count);
            Assert.Contains(one, actualValues);
            Assert.Contains(two, actualValues);
        }
예제 #4
0
        public void Lookup_AddedAndRemoved_ReturnsFalse(TestType value, Guid tag, Node node)
        {
            var clock = ImmutableSortedDictionary <Node, long> .Empty;

            var ourSet = new OUR_SetWithVC <TestType>();

            ourSet = ourSet.Add(value, tag, new VectorClock(clock.Add(node, 0)));
            ourSet = ourSet.Remove(value, tag, new VectorClock(clock.Add(node, 0)));

            var lookup = ourSet.Lookup(value);

            Assert.False(lookup);
        }
예제 #5
0
        public void Remove_AddsElementToRemovesSet(TestType value, Guid tag, Node node)
        {
            var clock = ImmutableSortedDictionary <Node, long> .Empty;

            var ourSet = new OUR_SetWithVC <TestType>();

            ourSet = ourSet.Add(value, tag, new VectorClock(clock.Add(node, 0)));
            ourSet = ourSet.Remove(value, tag, new VectorClock(clock.Add(node, 0)));

            var element = new OUR_SetWithVCElement <TestType>(value, tag, new VectorClock(clock.Add(node, 0)));

            Assert.Contains(element, ourSet.Removes);
        }
예제 #6
0
        public void Lookup_SameValueWithSeveralTags_ReturnsTrue(TestType value, Guid tag, Node node)
        {
            var clock = ImmutableSortedDictionary <Node, long> .Empty;

            var ourSet = new OUR_SetWithVC <TestType>();

            ourSet = ourSet.Add(value, tag, new VectorClock(clock.Add(node, 0)));
            ourSet = ourSet.Add(value, Guid.NewGuid(), new VectorClock(clock.Add(node, 1)));
            ourSet = ourSet.Remove(value, tag, new VectorClock(clock.Add(node, 2)));

            var lookup = ourSet.Lookup(value);

            Assert.True(lookup);
        }
예제 #7
0
        public void Lookup_AddedRemovedAndUpdated_ReturnsTrue(TestType value, Guid tag, Node node)
        {
            var clock = ImmutableSortedDictionary <Node, long> .Empty;

            var ourSet = new OUR_SetWithVC <TestType>();

            ourSet = ourSet.Add(value, tag, new VectorClock(clock.Add(node, 0)));
            ourSet = ourSet.Remove(value, tag, new VectorClock(clock.Add(node, 1)));

            var newValue = _builder.Build(value.Id);

            ourSet = ourSet.Update(newValue, tag, new VectorClock(clock.Add(node, 1)));

            var lookup = ourSet.Lookup(newValue);

            Assert.True(lookup);
        }