コード例 #1
0
        public void Test_AddMessageToClient(string ipAddressClient, int maskClient, string actualResult)
        {
            var client = new Client(ipAddressClient, maskClient);

            _messageStore.AddMessageToClient(actualResult, client);

            var result = _messageStore.ClientMessageDictionary[client][0];

            Assert.AreEqual(result, actualResult);
        }
コード例 #2
0
        public void Test_SendMessage_ThrowArgumentException(string exceptionMessage, string ipAddress, int mask, string message)
        {
            string ipAddressServer = "192.168.4.5";
            int    maskServer      = 56;

            var messageStore = new MessageStore();

            var networkElements = new List <NetworkElement>()
            {
                new Server(ipAddressServer, maskServer),
                _client
            };

            ((Server)networkElements[0]).AddedMessageToClient += (string message, Client client) =>
            {
                messageStore.AddMessageToClient(message, client);
            };

            Assert.That(() => _client.SendMessage(ipAddress, mask, message, networkElements), Throws.ArgumentException.With.Message.EqualTo(exceptionMessage));
        }
コード例 #3
0
        public void Test_SendMessage(string ipAddress, int mask, string actualResult)
        {
            var messageStore = new MessageStore();

            var networkElements = new List <NetworkElement>()
            {
                new Server(ipAddress, mask),
                _client
            };

            ((Server)networkElements[0]).AddedMessageToClient += (string message, Client client) =>
            {
                messageStore.AddMessageToClient(message, client);
            };

            _client.SendMessage(ipAddress, mask, actualResult, networkElements);

            string result = messageStore.ClientMessageDictionary[_client][0];

            Assert.AreEqual(result, actualResult);
        }