public void TestConstructor() { _sut = new PegasusAstroUsbSwitch(1) { Sdk = _mockSdk.Object }; Assert.That(_sut.Id, Is.EqualTo(1)); }
public async Task TestPollSerialPortClosed() { _sut = new PegasusAstroUsbSwitch(1) { Sdk = _mockSdk.Object }; _mockSdk.Setup(m => m.SendCommand <StatusResponse>(It.IsAny <StatusCommand>())) .Throws(new SerialPortClosedException()); var result = await _sut.Poll(); Assert.That(result, Is.False); }
public async Task TestSetValue(double value, string expectedCommand) { _sut = new PegasusAstroUsbSwitch(1) { Sdk = _mockSdk.Object }; var command = string.Empty; _mockSdk.Setup(m => m.SendCommand <SetUsbPowerResponse>(It.IsAny <SetUsbPowerCommand>())) .Callback <ICommand>(arg => { command = arg.CommandString; }); _sut.TargetValue = value; await _sut.SetValue(); Assert.That(command, Is.EqualTo(expectedCommand)); }
public async Task TestPoll(string deviceResponse, double expected) { _sut = new PegasusAstroUsbSwitch(1) { Sdk = _mockSdk.Object }; var response = new StatusResponse { DeviceResponse = deviceResponse }; _mockSdk.Setup(m => m.SendCommand <StatusResponse>(It.IsAny <StatusCommand>())) .Returns(Task.FromResult(response)); var result = await _sut.Poll(); Assert.That(result, Is.True); Assert.That(_sut.Value, Is.EqualTo(expected)); }