Ejemplo n.º 1
0
        public void ShouldTriggerMessageIgnoredWhenPeerNotFound()
        {
            using (SenderFixture fixture = new SenderFixture())
                using (SenderSession session = fixture.Start())
                {
                    PeerHash peer = PeerHash.Random();

                    Trigger handler = Trigger.Bind(ref session.Hooks.OnMessageIgnored, data =>
                    {
                        data.Peer.Should().NotBeNull();
                        data.Type.Should().Be("found");
                        data.Payload.Should().NotBeNull();
                    });

                    session.Sender.Send(peer, new SenderFound());
                    handler.Wait().Should().BeTrue();
                }
        }
Ejemplo n.º 2
0
        public void ShouldTriggerKeepAliveSent()
        {
            using (SenderFixture fixture = new SenderFixture())
                using (SenderSession session = fixture.Start())
                {
                    PeerHash          peer       = PeerHash.Random();
                    NetworkConnection connection = A.Fake <NetworkConnection>();

                    Trigger handler = Trigger.Bind(ref session.Hooks.OnKeepAliveSent, data =>
                    {
                        data.Peer.Should().Be(peer);
                    });

                    session.Sender.Add(peer, connection);
                    session.Sender.SendKeepAlive(peer);

                    handler.Wait().Should().BeTrue();
                }
        }
Ejemplo n.º 3
0
        public void ShouldTriggerMessageIgnoredWhenMessageNotMapped()
        {
            using (SenderFixture fixture = new SenderFixture())
                using (SenderSession session = fixture.Start())
                {
                    PeerHash          peer       = PeerHash.Random();
                    NetworkConnection connection = A.Fake <NetworkConnection>();

                    Trigger handler = Trigger.Bind(ref session.Hooks.OnMessageIgnored, data =>
                    {
                        data.Peer.Should().NotBeNull();
                        data.Type.Should().Be("unknown");
                        data.Payload.Should().NotBeNull();
                    });

                    session.Sender.Add(peer, connection);
                    session.Sender.Send(peer, new SenderUnknown());

                    handler.Wait().Should().BeTrue();
                }
        }