Пример #1
0
        public void Add_WithExistingValues_AddsElementToTheRepository(HashSet <OUR_SetWithVCElement <TestType> > adds, TestType value, Guid tag, Node node)
        {
            var clock = ImmutableSortedDictionary <Node, long> .Empty;

            _repository.PersistAdds(adds.ToImmutableHashSet());

            _ourSetService.DownstreamAdd(value, tag, new VectorClock(clock.Add(node, 0)));

            var repositoryValues = _repository.GetAdds();
            var actualValues     = repositoryValues.Where(v => Equals(v.Value, value) && v.Tag == tag && v.VectorClock.Equals(new VectorClock(clock.Add(node, 0))));

            Assert.Single(actualValues);
        }
Пример #2
0
        public void MergeAdds_UpdatedElementWithHigherTimestamp_ReplacesElementsInRepository(TestType value, Guid tag, Node node)
        {
            var clock = ImmutableSortedDictionary <Node, long> .Empty;

            var element = new OUR_SetWithVCElement <TestType>(value, tag, new VectorClock(clock.Add(node, 0)));

            _repository.PersistAdds(new List <OUR_SetWithVCElement <TestType> > {
                element
            }.ToImmutableHashSet());

            var newElement = new OUR_SetWithVCElement <TestType>(_builder.Build(value.Id), tag, new VectorClock(clock.Add(node, 1)));

            _orSetService.LocalAdd(newElement.Value, newElement.Tag, newElement.VectorClock);

            var repositoryValues = _repository.GetAdds();

            Assert.Equal(0, repositoryValues.Count(x => Equals(x, element)));
            Assert.Equal(1, repositoryValues.Count(x => Equals(x, newElement)));
        }