Ejemplo n.º 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();
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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());
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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());
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }