public void TestLeaderOfId()
        {
            var targetId = Id.Of(3);

            _outboundStream.Actor.Leader(targetId);

            var channel = _channelProvider.ChannelFor(targetId);
            var message = OperationalMessage.MessageFrom(Mock(channel).Writes[0]);

            Assert.True(message.IsLeader);
            Assert.Equal(_localNodeId, message.Id);
        }
Esempio n. 2
0
        public void TestSendTo()
        {
            var targetId = Id.Of(3);

            var buffer = new MemoryStream(Properties.OperationalBufferSize());

            var rawMessage1 = BuildRawMessageBuffer(buffer, _message1);

            _outboundStream.Actor.SendTo(rawMessage1, targetId);

            Assert.Equal(_message1, Mock(_channelProvider.ChannelFor(targetId)).Writes[0]);

            var anotherTargetId = Id.Of(2);

            _outboundStream.Actor.SendTo(rawMessage1, anotherTargetId);

            Assert.Equal(_message1, Mock(_channelProvider.ChannelFor(anotherTargetId)).Writes[0]);
        }
Esempio n. 3
0
        public void TestBroadcastToSelectNodes()
        {
            var buffer = new MemoryStream(Properties.OperationalBufferSize());

            var rawMessage1 = BuildRawMessageBuffer(buffer, _message1);
            var rawMessage2 = BuildRawMessageBuffer(buffer, _message2);
            var rawMessage3 = BuildRawMessageBuffer(buffer, _message3);

            var selectNodes = new List <Wire.Node.Node>();

            selectNodes.Add(Config.NodeMatching(Id.Of(3)));

            _outbound.Broadcast(selectNodes, rawMessage1);
            _outbound.Broadcast(selectNodes, rawMessage2);
            _outbound.Broadcast(selectNodes, rawMessage3);

            var mock = (MockManagedOutboundChannel)_channelProvider.ChannelFor(Id.Of(3));

            Assert.Equal(_message1, mock.Writes[0]);
            Assert.Equal(_message2, mock.Writes[1]);
            Assert.Equal(_message3, mock.Writes[2]);
        }