Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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);
        }