public void Add_Concurrent_AddsOnlyOneElement(TestType value, Guid tag, long timestamp)
        {
            var ourSet = new OUR_Set <TestType>();

            ourSet = ourSet.Add(value, tag, timestamp);
            ourSet = ourSet.Add(value, tag, timestamp);

            var element = new OUR_SetElement <TestType>(value, tag, timestamp);

            Assert.Equal(1, ourSet.Adds.Count(v => Equals(v, element)));
        }
        public void Lookup_SameValueWithSeveralTags_ReturnsTrue(TestType value, Guid tag, long timestamp)
        {
            var ourSet = new OUR_Set <TestType>();

            ourSet = ourSet.Add(value, tag, timestamp);
            ourSet = ourSet.Add(value, Guid.NewGuid(), timestamp + 1);
            ourSet = ourSet.Remove(value, tag, timestamp + 2);

            var lookup = ourSet.Lookup(value);

            Assert.True(lookup);
        }
        public void Add_AddsElementToAddsSet(TestType value, Guid tag, long timestamp)
        {
            var ourSet = new OUR_Set <TestType>();

            ourSet = ourSet.Add(value, tag, timestamp);

            var element = new OUR_SetElement <TestType>(value, tag, timestamp);

            Assert.Contains(element, ourSet.Adds);
        }
        public void Lookup_AddedAndNotRemoved_ReturnsTrue(TestType value, Guid tag, long timestamp)
        {
            var ourSet = new OUR_Set <TestType>();

            ourSet = ourSet.Add(value, tag, timestamp);

            var lookup = ourSet.Lookup(value);

            Assert.True(lookup);
        }
        public void Values_ReturnsNonRemovedValues(TestType one, TestType two, TestType three, Guid tagOne, Guid tagTwo, Guid tagThree, long timestamp)
        {
            var ourSet = new OUR_Set <TestType>();

            ourSet = ourSet.Add(one, tagOne, timestamp);
            ourSet = ourSet.Add(one, tagTwo, timestamp);
            ourSet = ourSet.Remove(one, tagTwo, timestamp);
            ourSet = ourSet.Add(two, tagTwo, timestamp);
            ourSet = ourSet.Add(two, tagOne, timestamp);
            ourSet = ourSet.Remove(two, tagOne, timestamp);
            ourSet = ourSet.Remove(three, tagThree, timestamp);
            ourSet = ourSet.Add(three, tagThree, timestamp);
            ourSet = ourSet.Remove(three, tagThree, timestamp);

            var actualValues = ourSet.Values;

            Assert.Equal(2, actualValues.Count);
            Assert.Contains(one, actualValues);
            Assert.Contains(two, actualValues);
        }
        public void Lookup_AddedAndRemoved_ReturnsFalse(TestType value, Guid tag, long timestamp)
        {
            var ourSet = new OUR_Set <TestType>();

            var element = new OUR_SetElement <TestType>(value, Guid.NewGuid(), timestamp);

            ourSet = ourSet.Add(value, tag, timestamp);
            ourSet = ourSet.Remove(value, tag, timestamp);

            var lookup = ourSet.Lookup(value);

            Assert.False(lookup);
        }
        public void Update_UpdatesElementInAddsSet(TestType value, Guid tag, long timestamp)
        {
            var ourSet = new OUR_Set <TestType>();

            var newValue   = _builder.Build(value.Id);
            var newElement = new OUR_SetElement <TestType>(newValue, tag, timestamp + 1);

            ourSet = ourSet.Add(value, tag, timestamp);
            ourSet = ourSet.Update(newValue, tag, timestamp + 1);

            var element = new OUR_SetElement <TestType>(value, tag, timestamp);

            Assert.Contains(newElement, ourSet.Adds);
            Assert.DoesNotContain(element, ourSet.Adds);
        }
        public void Lookup_AddedRemovedAndUpdated_ReturnsTrue(TestType value, Guid tag, long timestamp)
        {
            var ourSet = new OUR_Set <TestType>();

            ourSet = ourSet.Add(value, tag, timestamp);
            ourSet = ourSet.Remove(value, tag, timestamp + 1);

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

            ourSet = ourSet.Update(newValue, tag, timestamp + 1);

            var lookup = ourSet.Lookup(newValue);

            Assert.True(lookup);
        }