public async void ShouldOpenPortOnlyOneTimesIfPortIsAlreadyOpen() { var mock = new Mock <IHartCommunication>(); mock.Setup(item => item.Open()).Returns(OpenResult.Opened); var service = new HartCommunicationService(mock.Object); var openResult = await service.OpenAsync(); openResult.Should().Be(OpenResult.Opened); await service.OpenAsync(); mock.Verify(item => item.Open(), Times.Exactly(1)); }
public async void ShouldReturnOpenResultErrorIfPortCannotOpened(OpenResult openResult) { var mock = new Mock <IHartCommunication>(); mock.Setup(item => item.Open()).Returns(openResult); var service = new HartCommunicationService(mock.Object); (await service.OpenAsync()).Should().Be(openResult); }
public async void ShouldOpenPort() { var mock = new Mock <IHartCommunication>(); mock.Setup(item => item.Open()).Returns(OpenResult.Opened); var service = new HartCommunicationService(mock.Object); var openResult = await service.OpenAsync(); openResult.Should().Be(OpenResult.Opened); }
public async void ShouldSetPortStateFromOpeningToOpened() { var mock = new Mock <IHartCommunication>(); mock.Setup(item => item.Open()).Returns(OpenResult.Opened); var service = new HartCommunicationService(mock.Object); var states = new List <Services.PortState>(); service.LogChanges(() => service.PortState, states); await service.OpenAsync(); states.Count.Should().Be(2); states[0].Should().Be(Services.PortState.Opening); states[1].Should().Be(Services.PortState.Opened); }