public void ThrowsExceptionWhenFailingToDeleteMessages()
            {
                // Arrange
                var manager = new SmsManager(_serialPort);

                _serialPort.When(sp => sp.Write(Arg.Is <string>(a => a == "AT\r"))).Do(c =>
                {
                    _serialPort.ReadExisting().Returns("\r\nOK\r\n");
                    manager._receiveNow.Set();
                });
                _serialPort.When(sp => sp.Write(Arg.Is <string>(a => a == "AT+CMGF=1\r"))).Do(c =>
                {
                    _serialPort.ReadExisting().Returns("\r\nOK\r\n");
                    manager._receiveNow.Set();
                });
                _serialPort.When(sp => sp.Write(Arg.Is <string>(a => a == "AT+CMGD=1,3\r"))).Do(c =>
                {
                    _serialPort.ReadExisting().Returns("\r\nERROR\r\n");
                    manager._receiveNow.Set();
                });

                // Act
                // Assert
                Assert.That(() => manager.DeleteMsg(_serialPort, "AT+CMGD=1,3"),
                            Throws.Exception.TypeOf <ApplicationException>()
                            .With.Message.EqualTo("No success message was received."));
            }
            public void SuccessfullyDeletesReadMessages()
            {
                // Arrange
                var manager = new SmsManager(_serialPort);

                _serialPort.When(sp => sp.Write(Arg.Is <string>(a => a == "AT\r"))).Do(c =>
                {
                    _serialPort.ReadExisting().Returns("\r\nOK\r\n");
                    manager._receiveNow.Set();
                });
                _serialPort.When(sp => sp.Write(Arg.Is <string>(a => a == "AT+CMGF=1\r"))).Do(c =>
                {
                    _serialPort.ReadExisting().Returns("\r\nOK\r\n");
                    manager._receiveNow.Set();
                });
                _serialPort.When(sp => sp.Write(Arg.Is <string>(a => a == "AT+CMGD=1,3\r"))).Do(c =>
                {
                    _serialPort.ReadExisting().Returns("\r\nOK\r\n");
                    manager._receiveNow.Set();
                });

                // Act
                bool result = manager.DeleteMsg(_serialPort, "AT+CMGD=1,3");

                // Assert
                Assert.AreEqual(true, result);
            }