public void MergeRemoves_IsCommutative(Guid firstTag, Guid secondTag) { var firstElement = new OR_SetElement <TestType>(_builder.Build(), firstTag); var secondElement = new OR_SetElement <TestType>(_builder.Build(), secondTag); var thirdElement = new OR_SetElement <TestType>(_builder.Build(), secondTag); var fourthElement = new OR_SetElement <TestType>(_builder.Build(), firstTag); var fifthElement = new OR_SetElement <TestType>(_builder.Build(), firstTag); var firstRepository = new OR_SetRepository(); var firstService = new OR_SetService <TestType>(firstRepository); firstRepository.PersistRemoves(new HashSet <OR_SetElement <TestType> > { firstElement, secondElement, thirdElement }.ToImmutableHashSet()); firstRepository.PersistAdds(new HashSet <OR_SetElement <TestType> > { fourthElement, fifthElement }.ToImmutableHashSet()); firstService.Merge(ImmutableHashSet <OR_SetElement <TestType> > .Empty, new HashSet <OR_SetElement <TestType> > { fourthElement, fifthElement }.ToImmutableHashSet()); var firstRepositoryValues = firstRepository.GetRemoves(); var secondRepository = new OR_SetRepository(); var secondService = new OR_SetService <TestType>(secondRepository); secondRepository.PersistRemoves(new HashSet <OR_SetElement <TestType> > { fourthElement, fifthElement }.ToImmutableHashSet()); secondRepository.PersistAdds(new HashSet <OR_SetElement <TestType> > { firstElement, secondElement, thirdElement }.ToImmutableHashSet()); secondService.Merge(ImmutableHashSet <OR_SetElement <TestType> > .Empty, new HashSet <OR_SetElement <TestType> > { firstElement, secondElement, thirdElement }.ToImmutableHashSet()); var secondRepositoryValues = firstRepository.GetRemoves(); Assert.Equal(firstRepositoryValues, secondRepositoryValues); }
public void MergeAdds_SingleValueWithEmptyRepository_AddsElementsToTheRepository(TestType value, Guid tag) { var element = new OR_SetElement <TestType>(value, tag); _orSetService.Merge(new HashSet <OR_SetElement <TestType> > { element }.ToImmutableHashSet(), ImmutableHashSet <OR_SetElement <TestType> > .Empty); var repositoryValues = _repository.GetAdds(); Assert.Equal(1, repositoryValues.Count(x => Equals(x, element))); }