public void Creates_Appropriate_Message(StaticMessage message)
        {
            var creator = new StaticMessageCreator();
            var bytes   = creator.CreateMessage(message);

            Assert.AreEqual(bytes, message.Bytes);
        }
示例#2
0
        public void Receive_Firmware_Message_From_Live_Arduino_Running_Standard_Firmata_2_3()
        {
            var smc   = new StaticMessageCreator();
            var bytes = smc.CreateMessage(new QueryFirmwareMessage());

            port.Write(bytes, 0, bytes.Length);

            // Wait for the arduino to reply
            Thread.Sleep(100);

            while (port.BytesToRead > 0)
            {
                var incomingByte = (byte)port.ReadByte();
                Assert.IsTrue(handler.CanHandle(incomingByte));
                handler.Handle(incomingByte);
            }

            mockBroker.Verify(p => p.CreateEvent(
                                  It.Is <SysexFirmwareMessage>(mes => mes.MajorVersion == 2 && mes.MinorVersion == 3)), Times.Once());
        }
 public void Throws_Error_On_Wrong_Message()
 {
     var creator = new StaticMessageCreator();
     Assert.Throws<MessageCreatorException>(() => creator.CreateMessage(new AnalogMessage()));
 }
 public void Creates_Appropriate_Message(StaticMessage message)
 {
     var creator = new StaticMessageCreator();
     var bytes = creator.CreateMessage(message);
     Assert.AreEqual(bytes,message.Bytes);
 }
        public void Throws_Error_On_Wrong_Message()
        {
            var creator = new StaticMessageCreator();

            Assert.Throws <MessageCreatorException>(() => creator.CreateMessage(new AnalogMessage()));
        }