コード例 #1
0
ファイル: ReachabilitySpec.cs プロジェクト: zhanjian/akka.net
        public void ReachabilityTable_must_have_correct_aggregated_status()
        {
            var records = ImmutableList.Create(
                new Reachability.Record(nodeA, nodeB, Reachability.ReachabilityStatus.Reachable, 2),
                new Reachability.Record(nodeC, nodeB, Reachability.ReachabilityStatus.Unreachable, 2),
                new Reachability.Record(nodeA, nodeD, Reachability.ReachabilityStatus.Unreachable, 3),
                new Reachability.Record(nodeD, nodeB, Reachability.ReachabilityStatus.Terminated, 4)
                );
            var versions = ImmutableDictionary.CreateRange(new[]
            {
                new KeyValuePair <UniqueAddress, long>(nodeA, 3),
                new KeyValuePair <UniqueAddress, long>(nodeC, 3),
                new KeyValuePair <UniqueAddress, long>(nodeD, 4)
            });
            var r = new Reachability(records, versions);

            Assert.Equal(Reachability.ReachabilityStatus.Reachable, r.Status(nodeA));
            Assert.Equal(Reachability.ReachabilityStatus.Terminated, r.Status(nodeB));
            Assert.Equal(Reachability.ReachabilityStatus.Unreachable, r.Status(nodeD));
        }
コード例 #2
0
        public void ReachabilityTable_must_have_correct_aggregated_status()
        {
            var records = ImmutableList.Create(
                new Reachability.Record(nodeA, nodeB, Reachability.ReachabilityStatus.Reachable, 2),
                new Reachability.Record(nodeC, nodeB, Reachability.ReachabilityStatus.Unreachable, 2),
                new Reachability.Record(nodeA, nodeD, Reachability.ReachabilityStatus.Unreachable, 3),
                new Reachability.Record(nodeD, nodeB, Reachability.ReachabilityStatus.Terminated, 4));

            var versions = ImmutableDictionary.CreateRange(new[]
            {
                new KeyValuePair<UniqueAddress, long>(nodeA, 3),
                new KeyValuePair<UniqueAddress, long>(nodeC, 3),
                new KeyValuePair<UniqueAddress, long>(nodeD, 4)
            });
            var r = new Reachability(records, versions);
            r.Status(nodeA).Should().Be(Reachability.ReachabilityStatus.Reachable);
            r.Status(nodeB).Should().Be(Reachability.ReachabilityStatus.Terminated);
            r.Status(nodeD).Should().Be(Reachability.ReachabilityStatus.Unreachable);
        }
コード例 #3
0
        private void CheckStatus(Reachability r1)
        {
            var record = r1.Records.First();

            r1.Status(record.Observer, record.Subject).Should().Be(record.Status);
        }
コード例 #4
0
        private void CheckAggregatedStatus(Reachability r1)
        {
            var record = r1.Records.First();

            r1.Status(record.Subject).Should().Be(record.Status);
        }
コード例 #5
0
 public void ReachabilityTableMustHaveCorrectAggregatedStatus()
 {
     var records = ImmutableList.Create(
         new Reachability.Record(nodeA, nodeB, Reachability.ReachabilityStatus.Reachable, 2),
         new Reachability.Record(nodeC, nodeB, Reachability.ReachabilityStatus.Unreachable, 2),
         new Reachability.Record(nodeA, nodeD, Reachability.ReachabilityStatus.Unreachable, 3),
         new Reachability.Record(nodeD, nodeB, Reachability.ReachabilityStatus.Terminated, 4)
         );
     var versions = ImmutableDictionary.CreateRange(new[]
     {
         new KeyValuePair<UniqueAddress, long>(nodeA, 3),
         new KeyValuePair<UniqueAddress, long>(nodeC, 3),
         new KeyValuePair<UniqueAddress, long>(nodeD, 4)
     });
     var r = new Reachability(records, versions);
     Assert.Equal(Reachability.ReachabilityStatus.Reachable, r.Status(nodeA));
     Assert.Equal(Reachability.ReachabilityStatus.Terminated, r.Status(nodeB));
     Assert.Equal(Reachability.ReachabilityStatus.Unreachable, r.Status(nodeD));
 }