Пример #1
0
        public void Successful_Scenario_Test(byte calibrationState, byte calibrationError, CalibrationStatus status, string errorMessage)
        {
            SetupWrite(ftdiMock, new byte[] { 0xca }, new byte[] { 0x29 });
            SetupRead(ftdiMock, new byte[] { 0xca }, new byte[] { 0x00, calibrationState, calibrationError });

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

            result.Success.Should().BeTrue();
            result.CalibrationStatus.Should().Be(status);
            result.Error.Should().Be(errorMessage);
        }
Пример #2
0
        public void Exception_Test(byte errorCode, Type ex)
        {
            SetupWrite(ftdiMock, new byte[] { 0xca }, new byte[] { 0x29 });
            SetupRead(ftdiMock, new byte[] { 0xca }, new byte[] { errorCode });

            var    sut = new QueryCalibrationCommand();
            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 });
        }