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);
        }
        public async void ShouldSetPortStateFromOpenedToClosed()
        {
            var mock = new Mock <IHartCommunication>();

            mock.Setup(item => item.Close()).Returns(CloseResult.Closed);
            var service = new HartCommunicationService(mock.Object)
            {
                PortState = Services.PortState.Opened
            };

            var states = new Queue <Services.PortState>();

            states.Enqueue(Services.PortState.Closing);
            states.Enqueue(Services.PortState.Closed);
            service.LogChanges(() => service.PortState, states);

            await service.CloseAsync();

            states.Count.Should().Be(0);
        }