public void ReceiveOverwriteTest() { // given: EnergyPort with data in the receive buffer var ep = new EnergyPort { CurrentIOMode = IOMode.Input, CurrentReceiveMode = EnergyPort.ReceiveMode.Overwrite }; var packet1 = new Packet(1); ep.Receive(packet1); var packet2 = new Packet(2); // when: receiving the second packet var result = ep.Receive(packet2); // then: // first packet overwritten Assert.That(ep.ReceiveBuffer, Is.SameAs(packet2)); // returned true Assert.That(result, Is.True); }
public void ReceiveDenyTest() { // given: EnergyPort with data in the receive buffer var ep = new EnergyPort { CurrentIOMode = IOMode.Input, CurrentReceiveMode = EnergyPort.ReceiveMode.Deny }; var packet1 = new Packet(1); ep.Receive(packet1); var packet2 = new Packet(2); // when: receiving the second packet var result = ep.Receive(packet2); // then: // ReceiveBuffer did not change Assert.That(ep.ReceiveBuffer, Is.EqualTo(packet1)); // returned false Assert.That(result, Is.False); }
public void ReceiveTest() { // given: EnergyPort var ep = new EnergyPort() { CurrentIOMode = IOMode.Input }; var packet = new Packet(1); // when: receiving data var result = ep.Receive(packet); // then: // data in the receive buffer Assert.That(ep.ReceiveBuffer, Is.SameAs(packet)); // returned true Assert.That(result, Is.True); }
public void CollectReceiveBuffer() { // given: EnergyPort with Packet var ep = new EnergyPort() { CurrentIOMode = IOMode.Input }; var packet = new Packet(1); ep.Receive(packet); // when: collecting the receive buffer var receivedObject = ep.CollectReceivedData(); // then: // object received Assert.That(receivedObject, Is.SameAs(packet)); // buffer empty Assert.That(ep.ReceiveBuffer, Is.Null); }