public void MergeAdds_SingleValueWithEmptyRepository_AddsElementsToTheRepository(TestType value, Guid tag, Node node) { var clock = ImmutableSortedDictionary <Node, long> .Empty; var element = new OUR_OptimizedSetWithVCElement <TestType>(value, tag, new VectorClock(clock.Add(node, 0)), false); _ourSetService.Merge(new HashSet <OUR_OptimizedSetWithVCElement <TestType> > { element }.ToImmutableHashSet()); var repositoryValues = _repository.GetElements(); Assert.Equal(1, repositoryValues.Count(x => Equals(x, element))); }
public void MergeAdds_IsCommutative(Guid firstTag, Guid secondTag, Node node) { var clock = ImmutableSortedDictionary <Node, long> .Empty; var firstElement = new OUR_OptimizedSetWithVCElement <TestType>(_builder.Build(), firstTag, new VectorClock(clock.Add(node, 0)), false); var secondElement = new OUR_OptimizedSetWithVCElement <TestType>(_builder.Build(), secondTag, new VectorClock(clock.Add(node, 0)), false); var thirdElement = new OUR_OptimizedSetWithVCElement <TestType>(_builder.Build(), secondTag, new VectorClock(clock.Add(node, 0)), false); var fourthElement = new OUR_OptimizedSetWithVCElement <TestType>(_builder.Build(), firstTag, new VectorClock(clock.Add(node, 0)), false); var fifthElement = new OUR_OptimizedSetWithVCElement <TestType>(_builder.Build(), firstTag, new VectorClock(clock.Add(node, 0)), false); var firstRepository = new OUR_OptimizedSetWithVCRepository(); var firstService = new OUR_OptimizedSetWithVCService <TestType>(firstRepository); _repository.PersistElements(new HashSet <OUR_OptimizedSetWithVCElement <TestType> > { firstElement, secondElement, thirdElement }.ToImmutableHashSet()); firstService.Merge(new HashSet <OUR_OptimizedSetWithVCElement <TestType> > { fourthElement, fifthElement }.ToImmutableHashSet()); var firstRepositoryValues = firstRepository.GetElements(); var secondRepository = new OUR_OptimizedSetWithVCRepository(); var secondService = new OUR_OptimizedSetWithVCService <TestType>(secondRepository); _repository.PersistElements(new HashSet <OUR_OptimizedSetWithVCElement <TestType> > { fourthElement, fifthElement }.ToImmutableHashSet()); secondService.Merge(new HashSet <OUR_OptimizedSetWithVCElement <TestType> > { firstElement, secondElement, thirdElement }.ToImmutableHashSet()); var secondRepositoryValues = firstRepository.GetElements(); Assert.Equal(firstRepositoryValues, secondRepositoryValues); }