Example #1
0
        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);
        }
Example #2
0
 public OUR_OptimizedSetWithVCServiceTests()
 {
     _repository    = new OUR_OptimizedSetWithVCRepository();
     _ourSetService = new OUR_OptimizedSetWithVCService <TestType>(_repository);
     _builder       = new TestTypeBuilder(new Random());
 }