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); }
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()); }
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; }
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()); }
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); }
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); }
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); }
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); }
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()); }
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); }
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); }
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); }