Beispiel #1
0
        public void FailsToSendsGetWidgetMessageAndDisposes()
        {
            // Arrange
            var fakeDriver         = Substitute.For <FtdiDriver>();
            var stubMessageFactory = Substitute.For <EnttecMessageFactory>();

            fakeDriver.OpenDevice()
            .Returns(true);
            fakeDriver.Write(Arg.Any <byte[]>()).Returns(false);
            var sut = new DmxUsbProDevice(fakeDriver, stubMessageFactory);

            // Act
            var isConnected = sut.Connect();

            // Assert
            Assert.False(isConnected);
            fakeDriver.Received(2).Dispose();

            // Cleanup
            sut.Dispose();
        }
Beispiel #2
0
        public void CantFindAnyDevices()
        {
            // Arrange
            var fakeDriver = Substitute.For <FtdiDriver>();

            fakeDriver.OpenDevice()
            .Returns(false);
            var stubMessageFactory = Substitute.For <EnttecMessageFactory>();
            var sut = new DmxUsbProDevice(fakeDriver, stubMessageFactory);

            DmxUsbProDevice.Logger = _logger;

            // Act
            var isConnected = sut.Connect();

            // Assert
            Assert.False(isConnected);

            // Cleanup
            sut.Dispose();
        }