Example #1
0
        public void ORSet_must_verify_MergeCommonKeys()
        {
            var commonKeys = ImmutableHashSet.CreateRange(new[] { "K1", "K2" });
            var thisDot1   = VersionVector.Create(new Dictionary <UniqueAddress, long> {
                { _nodeA, 3L }, { _nodeD, 7L }
            }.ToImmutableDictionary());
            var thisDot2 = VersionVector.Create(new Dictionary <UniqueAddress, long> {
                { _nodeB, 5L }, { _nodeC, 2L }
            }.ToImmutableDictionary());
            var thisVVector = VersionVector.Create(new Dictionary <UniqueAddress, long> {
                { _nodeA, 3L }, { _nodeB, 5L }, { _nodeC, 2L }, { _nodeD, 7L }
            }.ToImmutableDictionary());

            var thisSet = new ORSet <string>(
                elementsMap: new Dictionary <string, VersionVector> {
                { "K1", thisDot1 }, { "K2", thisDot2 }
            }.ToImmutableDictionary(),
                versionVector: thisVVector);

            var thatDot1    = VersionVector.Create(_nodeA, 3L);
            var thatDot2    = VersionVector.Create(_nodeB, 6L);
            var thatVVector = VersionVector.Create(new Dictionary <UniqueAddress, long> {
                { _nodeA, 3L }, { _nodeB, 6L }, { _nodeC, 1L }, { _nodeD, 8L }
            }.ToImmutableDictionary());
            var thatSet = new ORSet <string>(
                elementsMap: new Dictionary <string, VersionVector> {
                { "K1", thatDot1 }, { "K2", thatDot2 }
            }.ToImmutableDictionary(),
                versionVector: thatVVector);

            var expectedDots = new Dictionary <string, VersionVector>
            {
                { "K1", VersionVector.Create(_nodeA, 3L) },
                { "K2", VersionVector.Create(new Dictionary <UniqueAddress, long> {
                        { _nodeB, 6L }, { _nodeC, 2L }
                    }.ToImmutableDictionary()) }
            };

            ORSet <string> .MergeCommonKeys(commonKeys, thisSet, thatSet).Should().Equal(expectedDots);
        }