Beispiel #1
0
        public void NetworkControllerSubscriptionMessageIsProcessed()
        {
            byte[] b = new byte[1024];

            NetworkController nc     = new NetworkController();
            FakeServer        server = new FakeServer();

            nc.Servers.Add(server);
            Networking.NetworkController = nc;
            Networking.Start();

            FakeSender sender = new FakeSender();

            SenderBase.FactoryMethod = e => sender;

            Message msg = new Message();

            msg.Data   = b;
            msg.Sender = EllaConfiguration.Instance.NodeId + 1;
            msg.Type   = MessageType.Discover;

            IPEndPoint ep = new IPEndPoint(IPAddress.Parse("234.234.234.4"), 3456);

            server.DiscoveryMessageEvent(msg, ep);

            PublisherWithCallbackMethod p = new PublisherWithCallbackMethod();

            Start.Publisher(p);


            server.SubscriptionMessage(typeof(bool));
            Thread.Sleep(1000);
            Assert.IsTrue(sender._messages.ContainsKey(MessageType.SubscribeResponse));
        }
Beispiel #2
0
        public void ReplyToApplicationMessagePublisherToSubscriber()
        {
            PublisherWithCallbackMethod tp = new PublisherWithCallbackMethod();

            Start.Publisher(tp);
            TestSubscriber s = new TestSubscriber();

            s.SubscribeToBool();
            tp.SendMessage();
            Thread.Sleep(500);
            Assert.IsTrue(tp._replyReceived);
        }
Beispiel #3
0
        public void RemoteSubscriptionsWithSameReferenceFromDifferentNodesAreAccepted()
        {
            var tp = new PublisherWithCallbackMethod();

            Start.Publisher(tp);

            SubscriptionController.SubscribeRemoteSubscriber(typeof(bool), 2,
                                                             new IPEndPoint(IPAddress.Parse("127.0.0.1"), 45000), 33);

            Assert.AreEqual(1, tp.callback);

            SubscriptionController.SubscribeRemoteSubscriber(typeof(bool), 3,
                                                             new IPEndPoint(IPAddress.Parse("127.0.0.1"), 45000), 33);
            Assert.AreEqual(2, tp.callback);
        }
Beispiel #4
0
        public void PublisherWithCallbackMethod()
        {
            PublisherWithCallbackMethod p = new PublisherWithCallbackMethod();

            Start.Publisher(p);

            TestSubscriber s = new TestSubscriber();

            s.SubscribeForPublisherWithCallbackMethod();

            TestSubscriber x = new TestSubscriber();

            x.SubscribeForPublisherWithCallbackMethod();

            Thread.Sleep(1000);

            Assert.IsTrue(p.callback.Equals(2));
        }