Example #1
0
        private void btnSend_Click(object sender, EventArgs e)
        {
            udpMessages.send(txtMessage.Text);
            string header = udpMessages + ":" + txtPort.Text + " (Me) \r\n";

            txtConversation.AppendText(header);
            txtConversation.AppendText("  " + txtMessage.Text + " \r\n");
            txtMessage.Text = string.Empty;

            txtMessage.Focus();
        }
Example #2
0
        public void testSendMessageWithoutConnectionReturnException()
        {
            //Arrange
            String message = "Teste";
            var    data    = Encoding.ASCII.GetBytes(message);

            var connector = new UdpConnector("127.0.0.1", 9999, 9998);


            var udp = new UdpIntegration(connector);

            //Act and Assert
            udp.close();
            udp.send(message);
        }
Example #3
0
        public void testSendShortMessageCallReturnBytesLength()
        {
            //Arrange
            short message = 5;
            var   data    = BitConverter.GetBytes(message);

            var connector = new Mock <UdpConnect>();

            connector.Setup(udpConnector => udpConnector.send(data, data.Length)).Returns(data.Length);

            var udp = new UdpIntegration(connector.Object);

            //Act
            int returnBytes = udp.send(message);

            //Assert
            Assert.AreEqual(data.Length, returnBytes);
        }
Example #4
0
        public void testSendStringMessageCallReturnBytesLength()
        {
            //Arrange
            String message = "Teste";
            var    data    = Encoding.ASCII.GetBytes(message);

            var connector = new Mock <UdpConnect>();

            connector.Setup(udpConnector => udpConnector.send(data, data.Length)).Returns(data.Length);

            var udp = new UdpIntegration(connector.Object);

            //Act
            int returnBytes = udp.send(message);

            //Assert
            Assert.AreEqual(data.Length, returnBytes);
        }
Example #5
0
        public void testSendMessageCallSendInConnector()
        {
            //Arrange
            String message = "Teste";
            var    data    = Encoding.ASCII.GetBytes(message);

            var connector = new Mock <UdpConnect>();

            connector.Setup(udpConnector => udpConnector.send(data, data.Length)).Returns(data.Length);


            var udp = new UdpIntegration(connector.Object);

            //Act
            int returnBytes = udp.send(message);

            //Assert
            connector.Verify(conn => conn.send(data, data.Length), Times.Once());
        }
Example #6
0
        public void testSendMessageWithoutConnectionReturnException()
        {
            //Arrange
            String message = "Teste";
            var data = Encoding.ASCII.GetBytes(message);

            var connector = new UdpConnector("127.0.0.1", 9999, 9998);

            var udp = new UdpIntegration(connector);

            //Act and Assert
            udp.close();
            udp.send(message);
        }
Example #7
0
        public void testSendMessageCallSendInConnector()
        {
            //Arrange
            String message = "Teste";
            var data = Encoding.ASCII.GetBytes(message);

            var connector = new Mock<UdpConnect>();
            connector.Setup(udpConnector => udpConnector.send(data, data.Length)).Returns(data.Length);

            var udp = new UdpIntegration(connector.Object);

            //Act
            int returnBytes = udp.send(message);

            //Assert
            connector.Verify(conn => conn.send(data, data.Length), Times.Once());
        }
Example #8
0
        public void testSendStringMessageCallReturnBytesLength()
        {
            //Arrange
            String message = "Teste";
            var data = Encoding.ASCII.GetBytes(message);

            var connector = new Mock<UdpConnect>();
            connector.Setup(udpConnector => udpConnector.send(data, data.Length)).Returns(data.Length);

            var udp = new UdpIntegration(connector.Object);

            //Act
            int returnBytes = udp.send(message);

            //Assert
            Assert.AreEqual(data.Length, returnBytes);
        }
Example #9
0
        public void testSendShortMessageCallReturnBytesLength()
        {
            //Arrange
            short message = 5;
            var data = BitConverter.GetBytes(message);

            var connector = new Mock<UdpConnect>();
            connector.Setup(udpConnector => udpConnector.send(data, data.Length)).Returns(data.Length);

            var udp = new UdpIntegration(connector.Object);

            //Act
            int returnBytes = udp.send(message);

            //Assert
            Assert.AreEqual(data.Length, returnBytes);
        }