Example #1
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 #2
0
        public void testReceiveAsynWithMethodWithStringParameterCallOnceReceiveAsynchronousMethodInConnector()
        {
            //Arrange
            Action<String> method = (message) => { };

            var connector = new Mock<UdpConnect>();
            connector.Setup(udpConnector => udpConnector.receiveAsynchronous(1, It.IsAny<Action<dynamic>>(), typeof(String)));

            UdpIntegration integration = new UdpIntegration(connector.Object);

            //Act
            integration.receiveByTime(1, method);

            //Assert
            connector.Verify(conn => conn.receiveAsynchronous(1, It.IsAny<Action<dynamic>>(), typeof(String)), Times.Once());
        }
Example #3
0
        private void btnDisconnect_Click(object sender, EventArgs e)
        {
            udpMessages = null;
            connector.disconnect();

            txtRemoteIP.Enabled   = true;
            txtRemotePort.Enabled = true;
            txtPort.Enabled       = true;
            btnConnect.Enabled    = true;
            btnDisconnect.Enabled = false;
            txtMessage.Enabled    = false;
            btnSend.Enabled       = false;

            verifyMessages.Enabled = false;
            verifyMessages.Stop();
            verifyMessages = null;
        }
        private void btnDisconnect_Click(object sender, EventArgs e)
        {
            udpMessages = null;
            connector.disconnect();

            txtRemoteIP.Enabled = true;
            txtRemotePort.Enabled = true;
            txtPort.Enabled = true;
            btnConnect.Enabled = true;
            btnDisconnect.Enabled = false;
            txtMessage.Enabled = false;
            btnSend.Enabled = false;

            verifyMessages.Enabled = false;
            verifyMessages.Stop();
            verifyMessages = null;
        }
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 testReceiveMessageCallReturnBytes()
        {
            //Arrange
            String message = "Teste";
            var data = Encoding.ASCII.GetBytes(message);

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

            var udp = new UdpIntegration(connector.Object);

            //Act
            var returnBytes = udp.receive();

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

            var connector = new Mock <UdpConnect>();

            connector.Setup(udpConnector => udpConnector.receive()).Returns(data);

            var udp = new UdpIntegration(connector.Object);

            //Act
            var returnBytes = udp.receive();

            //Assert
            Assert.AreEqual(data, returnBytes);
        }
Example #8
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 #9
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 #10
0
        public void testReceiveAsynWithMethodWithStringParameterCallOnceReceiveAsynchronousMethodInConnector()
        {
            //Arrange
            Action <String> method = (message) => { };

            var connector = new Mock <UdpConnect>();

            connector.Setup(udpConnector => udpConnector.receiveAsynchronous(1, It.IsAny <Action <dynamic> >(), typeof(String)));

            UdpIntegration integration = new UdpIntegration(connector.Object);


            //Act
            integration.receiveByTime(1, method);

            //Assert
            connector.Verify(conn => conn.receiveAsynchronous(1, It.IsAny <Action <dynamic> >(), typeof(String)), Times.Once());
        }
Example #11
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());
        }
        private void btnConnect_Click(object sender, EventArgs e)
        {
            string remoteIP = txtRemoteIP.Text;
            int remotePort = int.Parse(txtRemotePort.Text);
            int port = int.Parse(txtPort.Text);

            connector = new UdpConnector(remoteIP, remotePort, port);
            udpMessages = new UdpIntegration(connector);

            txtRemoteIP.Enabled = false;
            txtRemotePort.Enabled = false;
            txtPort.Enabled = false;
            btnConnect.Enabled = false;
            btnDisconnect.Enabled = true;
            txtMessage.Enabled = true;
            btnSend.Enabled = true;

            verifyMessages = new System.Timers.Timer();
            verifyMessages.Interval = 500;
            verifyMessages.Enabled = true;

            verifyMessages.Elapsed += new ElapsedEventHandler(receive);
        }
Example #13
0
        private void btnConnect_Click(object sender, EventArgs e)
        {
            string remoteIP   = txtRemoteIP.Text;
            int    remotePort = int.Parse(txtRemotePort.Text);
            int    port       = int.Parse(txtPort.Text);


            connector   = new UdpConnector(remoteIP, remotePort, port);
            udpMessages = new UdpIntegration(connector);

            txtRemoteIP.Enabled   = false;
            txtRemotePort.Enabled = false;
            txtPort.Enabled       = false;
            btnConnect.Enabled    = false;
            btnDisconnect.Enabled = true;
            txtMessage.Enabled    = true;
            btnSend.Enabled       = true;

            verifyMessages          = new System.Timers.Timer();
            verifyMessages.Interval = 500;
            verifyMessages.Enabled  = true;

            verifyMessages.Elapsed += new ElapsedEventHandler(receive);
        }
Example #14
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 #15
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 #16
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);
        }