public void MergeAdds_IsCommutative() { var firstValue = _builder.Build(); var secondValue = _builder.Build(); var thirdValue = _builder.Build(); var fourthValue = _builder.Build(); var fifthValue = _builder.Build(); var firstRepository = new P_SetRepository(); var firstService = new P_SetService <TestType>(firstRepository); _repository.PersistAdds(new HashSet <TestType> { firstValue, secondValue, thirdValue }.ToImmutableHashSet()); firstService.Merge(new HashSet <TestType> { fourthValue, fifthValue }.ToImmutableHashSet(), ImmutableHashSet <TestType> .Empty); var firstRepositoryValues = firstRepository.GetAdds(); var secondRepository = new P_SetRepository(); var secondService = new P_SetService <TestType>(secondRepository); _repository.PersistAdds(new HashSet <TestType> { fourthValue, fifthValue }.ToImmutableHashSet()); secondService.Merge(new HashSet <TestType> { firstValue, secondValue, thirdValue }.ToImmutableHashSet(), ImmutableHashSet <TestType> .Empty); var secondRepositoryValues = firstRepository.GetAdds(); Assert.Equal(firstRepositoryValues, secondRepositoryValues); }
public void MergeAdds_SingleValueWithEmptyRepository_AddsElementsToTheRepository(TestType value) { _pSetService.Merge(new HashSet <TestType> { value }.ToImmutableHashSet(), ImmutableHashSet <TestType> .Empty); var repositoryValues = _repository.GetAdds(); Assert.Equal(1, repositoryValues.Count(x => Equals(x, value))); }