Exemplo n.º 1
0
        public void MergeAdds_IsCommutative(Guid firstTag, Guid secondTag, long timestamp)
        {
            var firstElement  = new OUR_SetElement <TestType>(_builder.Build(), firstTag, timestamp);
            var secondElement = new OUR_SetElement <TestType>(_builder.Build(), secondTag, timestamp);
            var thirdElement  = new OUR_SetElement <TestType>(_builder.Build(), secondTag, timestamp);
            var fourthElement = new OUR_SetElement <TestType>(_builder.Build(), firstTag, timestamp);
            var fifthElement  = new OUR_SetElement <TestType>(_builder.Build(), firstTag, timestamp);

            var firstRepository = new OUR_SetRepository();
            var firstService    = new OUR_SetService <TestType>(firstRepository);

            _repository.PersistAdds(new List <OUR_SetElement <TestType> > {
                firstElement, secondElement, thirdElement
            }.ToImmutableHashSet());
            firstService.Merge(new List <OUR_SetElement <TestType> > {
                fourthElement, fifthElement
            }.ToImmutableHashSet(), ImmutableHashSet <OUR_SetElement <TestType> > .Empty);

            var firstRepositoryValues = firstRepository.GetAdds();

            var secondRepository = new OUR_SetRepository();
            var secondService    = new OUR_SetService <TestType>(secondRepository);

            _repository.PersistAdds(new List <OUR_SetElement <TestType> > {
                fourthElement, fifthElement
            }.ToImmutableHashSet());
            secondService.Merge(new List <OUR_SetElement <TestType> > {
                firstElement, secondElement, thirdElement
            }.ToImmutableHashSet(), ImmutableHashSet <OUR_SetElement <TestType> > .Empty);

            var secondRepositoryValues = firstRepository.GetAdds();

            Assert.Equal(firstRepositoryValues, secondRepositoryValues);
        }
Exemplo n.º 2
0
        public void MergeAdds_SingleValueWithEmptyRepository_AddsElementsToTheRepository(TestType value, Guid tag, long timestamp)
        {
            var element = new OUR_SetElement <TestType>(value, tag, timestamp);

            _orSetService.Merge(new List <OUR_SetElement <TestType> > {
                element
            }.ToImmutableHashSet(), ImmutableHashSet <OUR_SetElement <TestType> > .Empty);

            var repositoryValues = _repository.GetAdds();

            Assert.Equal(1, repositoryValues.Count(x => Equals(x, element)));
        }