Exemple #1
0
        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);
        }
        private Dictionary <Node, CRDT.Application.Commutative.Set.P_SetService <TestType> > CreateCommutativeReplicas(List <Node> nodes)
        {
            var dictionary = new Dictionary <Node, CRDT.Application.Commutative.Set.P_SetService <TestType> >();

            foreach (var node in nodes)
            {
                var repository = new P_SetRepository();
                var service    = new CRDT.Application.Commutative.Set.P_SetService <TestType>(repository);

                dictionary.Add(node, service);
            }

            return(dictionary);
        }
Exemple #3
0
        private Dictionary <Node, P_SetService <TestType> > CreateConvergentReplicas(List <Node> nodes)
        {
            var dictionary = new Dictionary <Node, P_SetService <TestType> >();

            foreach (var node in nodes)
            {
                var repository = new P_SetRepository();
                var service    = new P_SetService <TestType>(repository);

                dictionary.Add(node, service);
            }

            return(dictionary);
        }