コード例 #1
0
        public void Lookup_AddedAndNotRemoved_ReturnsTrue(LWW_OptimizedSetWithVCElement <TestType> element)
        {
            var clock  = ImmutableSortedDictionary <Node, long> .Empty;
            var lwwSet = new LWW_OptimizedSetWithVC <TestType>();

            lwwSet = lwwSet.Assign(element.Value, element.VectorClock);

            var lookup = lwwSet.Lookup(element.Value);

            Assert.True(lookup);
        }
コード例 #2
0
        public void Lookup_AddedAndNotRemoved_ReturnsTrue(TestType value, Node node)
        {
            var clock = ImmutableSortedDictionary <Node, long> .Empty;

            var lwwSet = new LWW_OptimizedSetWithVC <TestType>();

            lwwSet = lwwSet.Merge(new[] { new LWW_OptimizedSetWithVCElement <TestType>(value, new VectorClock(clock.Add(node, 0)), false) }.ToImmutableHashSet());

            var lookup = lwwSet.Lookup(value);

            Assert.True(lookup);
        }
コード例 #3
0
        public void Lookup_AddedAndRemoved_ReturnsFalse(TestType value, Node node)
        {
            var clock = ImmutableSortedDictionary <Node, long> .Empty;

            var lwwSet = new LWW_OptimizedSetWithVC <TestType>();

            lwwSet.Assign(value, new VectorClock(clock.Add(node, 0)));
            lwwSet.Remove(value, new VectorClock(clock.Add(node, 1)));

            var lookup = lwwSet.Lookup(value);

            Assert.False(lookup);
        }
コード例 #4
0
        public void Lookup_ReAdded_ReturnsTrue(TestType value, Node node)
        {
            var clock  = ImmutableSortedDictionary <Node, long> .Empty;
            var lwwSet = new LWW_OptimizedSetWithVC <TestType>();

            var add    = new LWW_OptimizedSetWithVCElement <TestType>(value, new VectorClock(clock.Add(node, 0)), false);
            var remove = new LWW_OptimizedSetWithVCElement <TestType>(value, new VectorClock(clock.Add(node, 1)), true);
            var reAdd  = new LWW_OptimizedSetWithVCElement <TestType>(value, new VectorClock(clock.Add(node, 2)), false);

            lwwSet = lwwSet.Assign(add.Value, add.VectorClock);
            lwwSet = lwwSet.Remove(remove.Value, remove.VectorClock);
            lwwSet = lwwSet.Assign(reAdd.Value, reAdd.VectorClock);

            var lookup = lwwSet.Lookup(value);

            Assert.True(lookup);
        }