public void ShouldReturnDeliveryImpossibleStatus()
        {
            var serviceMock = new AttSmsServiceMock(MessageDeliveryStatus.DeliveryImpossible, 0);
            var sms         = new SmsMessage(new List <PhoneNumber>()
            {
                new PhoneNumber("343434")
            }, "body");

            sms.MessageId = "test";

            var messageStatusUpdated = new ManualResetEvent(false);
            var status = MessageDeliveryStatus.Initial;

            var listener = new SmsDeliveryListener(serviceMock, sms, TimeSpan.FromMilliseconds(100), TimeSpan.FromSeconds(2));

            listener.StatusChangedEvent += (s, e) =>
            {
                status = e.MessageStatus;
                messageStatusUpdated.Set();
            };
            listener.ListenForMessageDelivered();

            Assert.IsTrue(messageStatusUpdated.WaitOne(TimeSpan.FromSeconds(1)));
            Assert.AreEqual(MessageDeliveryStatus.DeliveryImpossible, status);
        }
        public void ShouldCallGetMessageStatusUntilItIsChanged()
        {
            var serviceMock = new AttSmsServiceMock(MessageDeliveryStatus.DeliveredToTerminal, 3);
            var sms         = new SmsMessage(new List <PhoneNumber>()
            {
                new PhoneNumber("343434")
            }, "body");

            sms.MessageId = "test";

            var messageStatusUpdated = new ManualResetEvent(false);
            var listener             = new SmsDeliveryListener(serviceMock, sms, TimeSpan.FromMilliseconds(20), TimeSpan.FromSeconds(2));

            listener.StatusChangedEvent += (s, e) =>
            {
                messageStatusUpdated.Set();
            };

            listener.ListenForMessageDelivered();

            Assert.IsTrue(messageStatusUpdated.WaitOne(TimeSpan.FromSeconds(1)));
            Assert.AreEqual(4, serviceMock.TimesCalled);
        }