Example #1
0
        public void Lookup_AddedAndNotRemoved_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)));

            var lookup = ourSet.Lookup(value);

            Assert.True(lookup);
        }
        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.Merge(new[] { new OUR_SetWithVCElement <TestType>(value, tag, new VectorClock(clock.Add(node, 0))) }.ToImmutableHashSet(), new[] { new OUR_SetWithVCElement <TestType>(value, tag, new VectorClock(clock.Add(node, 0))) }.ToImmutableHashSet());

            var lookup = ourSet.Lookup(value);

            Assert.False(lookup);
        }
Example #3
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);
        }
        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.Merge(new[] { new OUR_SetWithVCElement <TestType>(value, tag, new VectorClock(clock.Add(node, 0))) }.ToImmutableHashSet(), ImmutableHashSet <OUR_SetWithVCElement <TestType> > .Empty);
            ourSet = ourSet.Merge(new[] { new OUR_SetWithVCElement <TestType>(value, Guid.NewGuid(), new VectorClock(clock.Add(node, 1))) }.ToImmutableHashSet(), ImmutableHashSet <OUR_SetWithVCElement <TestType> > .Empty);
            ourSet = ourSet.Merge(ImmutableHashSet <OUR_SetWithVCElement <TestType> > .Empty, new[] { new OUR_SetWithVCElement <TestType>(value, tag, new VectorClock(clock.Add(node, 2))) }.ToImmutableHashSet());

            var lookup = ourSet.Lookup(value);

            Assert.True(lookup);
        }
        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.Merge(new[] { new OUR_SetWithVCElement <TestType>(value, tag, new VectorClock(clock.Add(node, 0))) }.ToImmutableHashSet(), ImmutableHashSet <OUR_SetWithVCElement <TestType> > .Empty);
            ourSet = ourSet.Merge(ImmutableHashSet <OUR_SetWithVCElement <TestType> > .Empty, new[] { new OUR_SetWithVCElement <TestType>(value, tag, new VectorClock(clock.Add(node, 1))) }.ToImmutableHashSet());

            var newValue = new TestTypeBuilder(new Random()).Build(value.Id);

            ourSet = ourSet.Merge(new[] { new OUR_SetWithVCElement <TestType>(newValue, tag, new VectorClock(clock.Add(node, 2))) }.ToImmutableHashSet(), ImmutableHashSet <OUR_SetWithVCElement <TestType> > .Empty);

            var lookup = ourSet.Lookup(newValue);

            Assert.True(lookup);
        }