Esempio n. 1
0
        public void ReachabilityTable_must_merge_versions_correctly()
        {
            var r1 = new Reachability(ImmutableList.Create <Reachability.Record>(), new Dictionary <UniqueAddress, long>
            {
                { nodeA, 3 },
                { nodeB, 5 },
                { nodeC, 7 }
            }.ToImmutableDictionary());

            var r2 = new Reachability(ImmutableList.Create <Reachability.Record>(), new Dictionary <UniqueAddress, long>
            {
                { nodeA, 6 },
                { nodeB, 2 },
                { nodeD, 1 }
            }.ToImmutableDictionary());
            var merged = r1.Merge(ImmutableHashSet.Create(nodeA, nodeB, nodeC, nodeD, nodeE), r2);

            var expected = new Dictionary <UniqueAddress, long>
            {
                { nodeA, 6 },
                { nodeB, 5 },
                { nodeC, 7 },
                { nodeD, 1 }
            }.ToImmutableDictionary();

            merged.Versions.Should().Equal(expected);

            var merged2 = r2.Merge(ImmutableHashSet.Create(nodeA, nodeB, nodeC, nodeD, nodeE), r1);

            merged2.Versions.Should().Equal(expected);
        }
Esempio n. 2
0
        public void ReachabilityTable_must_merge_versions_correctly()
        {
            var r1 = new Reachability(ImmutableList.Create<Reachability.Record>(), new Dictionary<UniqueAddress, long>
            {
                { nodeA, 3 },
                { nodeB, 5 },
                { nodeC, 7 }
            }.ToImmutableDictionary());

            var r2 = new Reachability(ImmutableList.Create<Reachability.Record>(), new Dictionary<UniqueAddress, long>
            {
                { nodeA, 6 },
                { nodeB, 2 },
                { nodeD, 1 }
            }.ToImmutableDictionary());
            var merged = r1.Merge(ImmutableHashSet.Create(nodeA, nodeB, nodeC, nodeD, nodeE), r2);

            var expected = new Dictionary<UniqueAddress, long>
            {
                { nodeA, 6 },
                { nodeB, 5 },
                { nodeC, 7 },
                { nodeD, 1 }
            }.ToImmutableDictionary();
            merged.Versions.Should().Equal(expected);

            var merged2 = r2.Merge(ImmutableHashSet.Create(nodeA, nodeB, nodeC, nodeD, nodeE), r1);
            merged2.Versions.Should().Equal(expected);
        }
Esempio n. 3
0
 private void Merge(Reachability r1, Reachability r2, int expectedRecords)
 {
     r1.Merge(Allowed, r2).Records.Count.Should().Be(expectedRecords);
 }