public void MergeRemoves_IsCommutative(Guid firstTag, Guid secondTag, Node node) { var clock = ImmutableSortedDictionary <Node, long> .Empty; var firstElement = new OUR_SetWithVCElement <TestType>(_builder.Build(), firstTag, new VectorClock(clock.Add(node, 0))); var secondElement = new OUR_SetWithVCElement <TestType>(_builder.Build(), secondTag, new VectorClock(clock.Add(node, 0))); var thirdElement = new OUR_SetWithVCElement <TestType>(_builder.Build(), secondTag, new VectorClock(clock.Add(node, 0))); var fourthElement = new OUR_SetWithVCElement <TestType>(_builder.Build(), firstTag, new VectorClock(clock.Add(node, 0))); var fifthElement = new OUR_SetWithVCElement <TestType>(_builder.Build(), firstTag, new VectorClock(clock.Add(node, 0))); var firstRepository = new OUR_SetWithVCRepository(); var firstService = new OUR_SetWithVCService <TestType>(firstRepository); firstRepository.PersistRemoves(new List <OUR_SetWithVCElement <TestType> > { firstElement, secondElement, thirdElement }.ToImmutableHashSet()); firstRepository.PersistAdds(new List <OUR_SetWithVCElement <TestType> > { fourthElement, fifthElement }.ToImmutableHashSet()); firstService.Merge(ImmutableHashSet <OUR_SetWithVCElement <TestType> > .Empty, new List <OUR_SetWithVCElement <TestType> > { fourthElement, fifthElement }.ToImmutableHashSet()); var firstRepositoryValues = firstRepository.GetRemoves(); var secondRepository = new OUR_SetWithVCRepository(); var secondService = new OUR_SetWithVCService <TestType>(secondRepository); secondRepository.PersistRemoves(new List <OUR_SetWithVCElement <TestType> > { fourthElement, fifthElement }.ToImmutableHashSet()); secondRepository.PersistAdds(new List <OUR_SetWithVCElement <TestType> > { firstElement, secondElement, thirdElement }.ToImmutableHashSet()); secondService.Merge(ImmutableHashSet <OUR_SetWithVCElement <TestType> > .Empty, new List <OUR_SetWithVCElement <TestType> > { firstElement, secondElement, thirdElement }.ToImmutableHashSet()); var secondRepositoryValues = firstRepository.GetRemoves(); Assert.Equal(firstRepositoryValues, secondRepositoryValues); }
public void MergeAdds_SingleValueWithEmptyRepository_AddsElementsToTheRepository(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))); _orSetService.Merge(new List <OUR_SetWithVCElement <TestType> > { element }.ToImmutableHashSet(), ImmutableHashSet <OUR_SetWithVCElement <TestType> > .Empty); var repositoryValues = _repository.GetAdds(); Assert.Equal(1, repositoryValues.Count(x => Equals(x, element))); }