Example #1
0
        public void ConstructorTest()
        {
            var sut = new SetImagingParameterCommand(2, 50, 1);

            sut.CommandCode.Should().Be(0xca);
            sut.AcknowledgeCode.Should().Be(0xca);
            sut.SubCommandCode.Should().Be(0x91);
            sut.RequiredBaudRate.Should().Be(250000);
            sut.Timeout.Should().Be(1000);
        }
Example #2
0
        public void Exception_Test(byte errorCode, Type ex)
        {
            SetupWrite(ftdiMock, new byte[] { 0xca }, new byte[] { 0x91 });
            SetupRead(ftdiMock, new byte[] { 0xca }, new byte[] { errorCode });

            var    sut = new SetImagingParameterCommand(2, 50, 1);
            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 });
        }
Example #3
0
        public void Successful_Scenario_Test()
        {
            byte gain     = 0x05;
            var  exposure = new byte[] { 0x23, 0x04 };

            var exposureTime = BitConverter.ToUInt16(exposure, 0);

            if (!BitConverter.IsLittleEndian)
            {
                exposureTime = BitConverter.ToUInt16(exposure.Reverse().ToArray(), 0);
            }

            byte threshold = 0x5;

            SetupWrite(ftdiMock, new byte[] { 0xca }, new byte[] { 0x91 }, new byte[] { gain, exposure[0], exposure[1], threshold });
            SetupRead(ftdiMock, new byte[] { 0xca }, new byte[] { 0x00 });

            var sut    = new SetImagingParameterCommand(gain, exposureTime, threshold);
            var result = sut.Execute(ftdiMock.Object);

            result.Success.Should().BeTrue();
        }