public void ConstructorTest() { var sut = new GetImagingParameterCommand(); sut.CommandCode.Should().Be(0xca); sut.AcknowledgeCode.Should().Be(0xca); sut.SubCommandCode.Should().Be(0x92); sut.RequiredBaudRate.Should().Be(250000); sut.Timeout.Should().Be(1000); }
public void Exception_Test(byte errorCode, Type ex) { SetupWrite(ftdiMock, new byte[] { 0xca }, new byte[] { 0x92 }); SetupRead(ftdiMock, new byte[] { 0xca }, new byte[] { errorCode }); var sut = new GetImagingParameterCommand(); 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 }); }
public void Successful_Scenario_Test() { byte expectedGain = 0x23; var expectedExposureTime = new byte[] { 0x33, 0x12 }; byte expectedThreshold = 0x65; SetupWrite(ftdiMock, new byte[] { 0xca }, new byte[] { 0x92 }); SetupRead(ftdiMock, new byte[] { 0xca }, new byte[] { 0x00, expectedGain, expectedExposureTime[0], expectedExposureTime[1], expectedThreshold }); var sut = new GetImagingParameterCommand(); var result = sut.Execute(ftdiMock.Object); result.Success.Should().BeTrue(); result.Gain.Should().Be(expectedGain); result.ExposureTime.Should().Be((ushort)((expectedExposureTime[1] << 8) + expectedExposureTime[0])); result.Threshold.Should().Be(expectedThreshold); }