Esempio n. 1
0
        public void ConstructorTest()
        {
            var sut = new FirmwareVersionCommand();

            sut.CommandCode.Should().Be(0x03);
            sut.AcknowledgeCode.Should().Be(0x03);
            sut.RequiredBaudRate.Should().Be(250000);
            sut.Timeout.Should().Be(1000);
        }
Esempio n. 2
0
        public void Successful_Scenario_Test(byte fwLow, byte fwHigh, string expectedVersion)
        {
            SetupWrite(ftdiMock, new byte[] { 0x03 });
            SetupRead(ftdiMock, new byte[] { 0x03, fwLow, fwHigh });

            var sut    = new FirmwareVersionCommand();
            var result = sut.Execute(ftdiMock.Object);

            result.Success.Should().BeTrue();
            result.Version.Should().Be(expectedVersion);
        }
Esempio n. 3
0
        public void Exception_Test(byte errorCode, Type ex)
        {
            SetupWrite(ftdiMock, new byte[] { 0x03 });
            SetupRead(ftdiMock, new byte[] { errorCode, 0x00, 0x00 });

            var    sut = new FirmwareVersionCommand();
            Action act = () => sut.Execute(ftdiMock.Object);

            TestDelegate test = new TestDelegate(act);

            MethodInfo method  = typeof(Assert).GetMethod("Throws", new[] { typeof(TestDelegate) });
            MethodInfo generic = method.MakeGenericMethod(ex);

            generic.Invoke(this, new object[] { test });
        }
Esempio n. 4
0
        public void TestFirmwareVersionCommand()
        {
            var sut = new FirmwareVersionCommand();

            Assert.That(sut.CommandString, Is.EqualTo("PV\n"));
        }