Beispiel #1
0
        public void Remove_AddDoesNotExist_DoesNotAddElementToTheRepository(TestType value, Node node)
        {
            var clock = ImmutableSortedDictionary <Node, long> .Empty;

            _lwwSetService.DownstreamRemove(value, new VectorClock(clock.Add(node, 0)));

            var repositoryValues = _repository.GetRemoves();

            Assert.DoesNotContain(value, repositoryValues.Select(v => v.Value));
        }
        public void Remove_AddExistsWithLowerTimestamp_AddsElementToTheRepository(TestType value, Node node)
        {
            var clock = ImmutableSortedDictionary <Node, long> .Empty;

            var addElement    = new LWW_SetWithVCElement <TestType>(value, new VectorClock(clock.Add(node, 0)));
            var removeElement = new LWW_SetWithVCElement <TestType>(value, new VectorClock(clock.Add(node, 1)));

            _lwwSetService.Merge(new HashSet <LWW_SetWithVCElement <TestType> > {
                addElement
            }.ToImmutableHashSet(), new HashSet <LWW_SetWithVCElement <TestType> > {
                removeElement
            }.ToImmutableHashSet());

            var repositoryValues = _repository.GetRemoves();

            Assert.Contains(value, repositoryValues.Select(v => v.Value));
        }