Exemplo n.º 1
0
 public void PeerNewNodeTest()
 {
     TestLauncherActor.Test(TestContext, () =>
     {
         var node1 = new PeerActor <int, string>();
         var node2 = new PeerActor <int, string>();
         var node3 = new PeerActor <int, string>();
         var node4 = new PeerActor <int, string>();
         node1.NewPeer(node2, node2.GetHashKey().Result());
         node1.NewPeer(node3, node3.GetHashKey().Result());
         node1.NewPeer(node4, node4.GetHashKey().Result());
         node1.StoreNode(10, "10");
         node2.StoreNode(20, "20");
         node3.StoreNode(30, "30");
         var future = new Future <IPeerActor <int, string> >();
         node1.FindPeer(30, future);
         var result = future.Result();
         Assert.IsNotNull(result);
         // Assert.AreEqual(node3.Tag.Key(), result.Tag.Key());
         future = new Future <IPeerActor <int, string> >();
         node1.FindPeer(40, future);
         result = future.Result();
         Assert.IsNotNull(result);
         // Assert.AreEqual(node1.Tag.Key(), result.Tag.Key());
     });
 }
Exemplo n.º 2
0
        public void PeerInterfaceTest()
        {
            TestLauncherActor.Test(TestContext, () =>
            {
                const int key      = 10;
                const string value = "10";
                var peerActor      = new PeerActor <int, string>();
                var finder         = new Future <IPeerActor <int, string> >();

                peerActor.StoreNode(key, value);
                peerActor.FindPeer(key, finder);
                var result = finder.Result();
                Assert.IsTrue(result != null);
                var future = result.GetNode(key);
                result.DeleteNode(key);
                result.StoreNode(key, value);
                future = result.GetNode(key);
                Assert.AreEqual(value, future.Result());
            });
        }