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

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

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

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

            var newOrSet = ourSet.Remove(value, tag, timestamp);

            Assert.Same(ourSet, newOrSet);
        }
        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 Remove_AddsElementToRemovesSet(TestType value, Guid tag, long timestamp)
        {
            var ourSet = new OUR_Set <TestType>();

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

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

            Assert.Contains(element, ourSet.Removes);
        }
        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 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 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);
        }