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);
        }
        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);
        }
        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.Merge(new[] { new OUR_SetWithVCElement <TestType>(one, tagOne, new VectorClock(clock.Add(node, 0))) }.ToImmutableHashSet(), ImmutableHashSet <OUR_SetWithVCElement <TestType> > .Empty);
            ourSet = ourSet.Merge(new[] { new OUR_SetWithVCElement <TestType>(one, tagOne, 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>(one, tagTwo, new VectorClock(clock.Add(node, 0))) }.ToImmutableHashSet());
            ourSet = ourSet.Merge(new[] { new OUR_SetWithVCElement <TestType>(two, tagTwo, new VectorClock(clock.Add(node, 0))) }.ToImmutableHashSet(), ImmutableHashSet <OUR_SetWithVCElement <TestType> > .Empty);
            ourSet = ourSet.Merge(new[] { new OUR_SetWithVCElement <TestType>(two, tagTwo, new VectorClock(clock.Add(node, 0))) }.ToImmutableHashSet(), ImmutableHashSet <OUR_SetWithVCElement <TestType> > .Empty);
            ourSet = ourSet.Merge(new[] { new OUR_SetWithVCElement <TestType>(two, tagOne, 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>(two, tagOne, new VectorClock(clock.Add(node, 0))) }.ToImmutableHashSet());
            ourSet = ourSet.Merge(ImmutableHashSet <OUR_SetWithVCElement <TestType> > .Empty, new[] { new OUR_SetWithVCElement <TestType>(three, tagThree, new VectorClock(clock.Add(node, 0))) }.ToImmutableHashSet());
            ourSet = ourSet.Merge(new[] { new OUR_SetWithVCElement <TestType>(three, tagThree, 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>(three, tagThree, new VectorClock(clock.Add(node, 0))) }.ToImmutableHashSet());

            var actualValues = ourSet.Values;

            Assert.Equal(2, actualValues.Count);
            Assert.Contains(one, actualValues);
            Assert.Contains(two, actualValues);
        }
        public void Merge_MergesAddsAndRemoves(OUR_SetWithVCElement <TestType> one, OUR_SetWithVCElement <TestType> two,
                                               OUR_SetWithVCElement <TestType> three, OUR_SetWithVCElement <TestType> four, OUR_SetWithVCElement <TestType> five)
        {
            var ourSet = new OUR_SetWithVC <TestType>(new[] { one, two }.ToImmutableHashSet(), new[] { three }.ToImmutableHashSet());

            var newOrSet = ourSet.Merge(new[] { three, four }.ToImmutableHashSet(), new[] { five }.ToImmutableHashSet());

            Assert.Equal(4, newOrSet.Adds.Count);
            Assert.Equal(2, newOrSet.Removes.Count);
            Assert.Contains(one, newOrSet.Adds);
            Assert.Contains(two, newOrSet.Adds);
            Assert.Contains(three, newOrSet.Adds);
            Assert.Contains(four, newOrSet.Adds);
            Assert.Contains(three, newOrSet.Removes);
            Assert.Contains(five, newOrSet.Removes);
        }