public void ServerCanSendMessageToAllExceptOneClient()
        {
            Message msg = new Message() { Items = { new Item() { Type = ItemType.SuccessfulJoin, Data = 666 } } };
            NetBuffer tmpBuffer = new NetBuffer();

            stubNetServer.Stub(x => x.CreateBuffer()).Return(tmpBuffer);

            serverMessageSender.SendToAllExcept(msg, NetChannel.Unreliable, stubNetConnection);

            stubNetServer.AssertWasCalled(x => x.SendToAll(Arg<NetBuffer>.Is.Equal(tmpBuffer),
                                                        Arg<NetChannel>.Is.Equal(NetChannel.Unreliable), Arg<INetConnection>.Is.Equal(stubNetConnection)));
            Assert.AreEqual(666, tmpBuffer.ReadMessage().Items[0].Data);
        }
        public void ServerCanSendMessagesToAllClients()
        {
            Message msg = new Message() { Items = { new Item() { Type = ItemType.DisconnectingClient, Data = 999 } } };
            NetBuffer tmpBuffer = new NetBuffer();

            stubNetServer.Stub(x => x.CreateBuffer()).Return(tmpBuffer);

            serverMessageSender.SendToAll(msg, NetChannel.Unreliable);

            stubNetServer.AssertWasCalled(x => x.SendToAll(Arg<NetBuffer>.Is.Equal(tmpBuffer),
                                                        Arg<NetChannel>.Is.Equal(NetChannel.Unreliable)));
            Assert.AreEqual(999, tmpBuffer.ReadMessage().Items[0].Data);
        }
        public void ClientProcessesAndSendsToServer()
        {
            NetBuffer tmpBuffer = new NetBuffer();
            Message msg = new Message() { Items = { new Item() { Type = ItemType.NewClient, Data = 10 } } };
            stubNetClient.Stub(x => x.CreateBuffer()).Return(tmpBuffer);
            stubNetClient.Stub(x => x.Status).Return(NetConnectionStatus.Connected);

            clientNetworkSession.Send(msg, NetChannel.ReliableUnordered);

            stubNetClient.AssertWasCalled(x => x.CreateBuffer());
            stubNetClient.AssertWasCalled(x => x.SendMessage(tmpBuffer, NetChannel.ReliableUnordered));
            Assert.AreEqual(10, tmpBuffer.ReadMessage().Items[0].Data);
        }