예제 #1
0
        public void Lookup_SameValueWithSeveralTags_ReturnsTrue(TestType value, Guid tag, long timestamp)
        {
            var ourSet = new OUR_OptimizedSet <TestType>();

            ourSet = ourSet.Merge(new[] { new OUR_OptimizedSetElement <TestType>(value, tag, timestamp, false) }.ToImmutableHashSet());
            ourSet = ourSet.Merge(new[] { new OUR_OptimizedSetElement <TestType>(value, Guid.NewGuid(), timestamp, false) }.ToImmutableHashSet());

            ourSet = ourSet.Merge(new[] { new OUR_OptimizedSetElement <TestType>(value, tag, timestamp + 2, true) }.ToImmutableHashSet());

            var lookup = ourSet.Lookup(value);

            Assert.True(lookup);
        }
예제 #2
0
        public void Lookup_AddedRemovedAndUpdated_ReturnsTrue(TestType value, Guid tag, long timestamp)
        {
            var ourSet = new OUR_OptimizedSet <TestType>();

            ourSet = ourSet.Merge(new[] { new OUR_OptimizedSetElement <TestType>(value, tag, timestamp, false) }.ToImmutableHashSet());
            ourSet = ourSet.Merge(new[] { new OUR_OptimizedSetElement <TestType>(value, tag, timestamp + 1, true) }.ToImmutableHashSet());

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

            ourSet = ourSet.Merge(new[] { new OUR_OptimizedSetElement <TestType>(newValue, tag, timestamp + 3, false) }.ToImmutableHashSet());

            var lookup = ourSet.Lookup(newValue);

            Assert.True(lookup);
        }
예제 #3
0
        public void Lookup_AddedAndNotRemoved_ReturnsTrue(TestType value, Guid tag, long timestamp)
        {
            var ourSet = new OUR_OptimizedSet <TestType>();

            ourSet = ourSet.Merge(new[] { new OUR_OptimizedSetElement <TestType>(value, tag, timestamp, false) }.ToImmutableHashSet());

            var lookup = ourSet.Lookup(value);

            Assert.True(lookup);
        }
예제 #4
0
        public void Merge_MergesAddsAndRemoves(TestType one, TestType two, TestType three, Guid tagOne, Guid tagTwo, Guid tagThree, long timestamp)
        {
            var orSet = new OUR_OptimizedSet <TestType>(new[] {
                new OUR_OptimizedSetElement <TestType>(one, tagOne, timestamp + 1, false),
                new OUR_OptimizedSetElement <TestType>(two, tagOne, timestamp + 7, true),
                new OUR_OptimizedSetElement <TestType>(three, tagThree, timestamp + 3, false),
            }.ToImmutableHashSet());

            var newOrSet = orSet.Merge(new[] {
                new OUR_OptimizedSetElement <TestType>(one, tagOne, timestamp + 4, false),
                new OUR_OptimizedSetElement <TestType>(one, tagTwo, timestamp + 5, true),
                new OUR_OptimizedSetElement <TestType>(two, tagOne, timestamp + 6, false),
                new OUR_OptimizedSetElement <TestType>(three, tagThree, timestamp + 7, false),
            }.ToImmutableHashSet());

            Assert.Equal(7, newOrSet.Elements.Count);
            Assert.Contains(new OUR_OptimizedSetElement <TestType>(one, tagOne, timestamp + 4, false), newOrSet.Elements);
            Assert.Contains(new OUR_OptimizedSetElement <TestType>(two, tagOne, timestamp + 7, true), newOrSet.Elements);
            Assert.Contains(new OUR_OptimizedSetElement <TestType>(three, tagThree, timestamp + 7, false), newOrSet.Elements);
            Assert.Contains(new OUR_OptimizedSetElement <TestType>(one, tagTwo, timestamp + 5, true), newOrSet.Elements);
        }