Example #1
0
        public void XHMZP()
        {
            // Arrange
            string order = "";

            void Receive(ExampleMsg message)
            {
                order += "a";
            }

            void ReceiveTwo(ExampleMsg message)
            {
                order += "b";
            }

            // Act
            MsgCtrl.Bind <ExampleMsg>(Receive, 10);
            MsgCtrl.Bind <ExampleMsg>(ReceiveTwo, -10);

            ExampleMsg msg = MsgCtrl.Allocate <ExampleMsg>();

            MsgCtrl.Send(msg);

            // Assert
            Assert.AreEqual("ba", order);
        }
Example #2
0
        public void ZSKML()
        {
            // Arrange
            int    receivedInt    = 0;
            float  receivedFloat  = 0;
            string receivedString = null;
            object receivedObject = null;

            void Receive(ExampleMsg message)
            {
                MsgCtrl.Bind <ExampleMsg>(ReceiveTwo);
            }

            void ReceiveTwo(ExampleMsg message)
            {
                receivedInt    = message.Int;
                receivedFloat  = message.Float;
                receivedString = message.String;
                receivedObject = message.Object;
            }

            object objectToReceive = new object();

            // Act
            MsgCtrl.Bind <ExampleMsg>(Receive);

            ExampleMsg msg = MsgCtrl.Allocate <ExampleMsg>();

            msg.Int    = 10;
            msg.Float  = 10.5f;
            msg.String = "Test";
            msg.Object = objectToReceive;
            MsgCtrl.Send(msg);

            // Assert
            Assert.Multiple(() =>
            {
                Assert.AreEqual(0, receivedInt);
                Assert.AreEqual(0f, receivedFloat);
                Assert.IsNull(receivedString);
                Assert.IsNull(receivedObject);
            });

            // Act
            msg        = MsgCtrl.Allocate <ExampleMsg>();
            msg.Int    = 10;
            msg.Float  = 10.5f;
            msg.String = "Test";
            msg.Object = objectToReceive;
            MsgCtrl.Send(msg);

            // Assert
            Assert.Multiple(() =>
            {
                Assert.AreEqual(10, receivedInt);
                Assert.AreEqual(10.5f, receivedFloat);
                Assert.AreEqual("Test", receivedString);
                Assert.AreEqual(objectToReceive, receivedObject);
            });
        }
Example #3
0
        public void YZDMS()
        {
            // Arrange
            AttributeTest attributeTest = new AttributeTest();

            // Act
            ExampleMsg msg = MsgCtrl.Allocate <ExampleMsg>();

            MsgCtrl.Send(msg);

            // Assert
            Assert.AreEqual(1, attributeTest.ReceivedMessages);
        }
Example #4
0
        public void DEZSX()
        {
            // Arrange
            AttributeTest attributeTest = new AttributeTest();

            // Act
            attributeTest.Unregister();
            ExampleMsg msg = MsgCtrl.Allocate <ExampleMsg>();

            MsgCtrl.Send(msg);

            // Assert
            Assert.AreEqual(0, attributeTest.ReceivedMessages);
        }
Example #5
0
        public void PDRDZ()
        {
            // Arrange
            void Receive(ExampleMsg message)
            {
            }

            MsgCtrl.Bind <ExampleMsg>(Receive);

            // Act
            ExampleMsg msg = MsgCtrl.Allocate <ExampleMsg>();

            // Assert
            Assert.AreEqual(0, MessagesPool <ExampleMsg> .NumberOfFreeMessages);

            // Act
            MsgCtrl.Deallocate(msg);

            // Assert
            Assert.AreEqual(1, MessagesPool <ExampleMsg> .NumberOfFreeMessages);
        }
Example #6
0
 public void Receive(ExampleMsg message)
 {
     ++ReceivedMessages;
 }