Inheritance: SmsStatus
        public void SendSingleSmsNow_SendingThenFail()
        {
            var sendOneMessageNow = new SendOneMessageNow();

            var smsService = MockRepository.GenerateMock<ISmsService>();
            var timeoutCalculator = MockRepository.GenerateMock<ITimeoutCalculator>();

            const string sid = "12";
            var smsSending = new SmsSending(sid, 0.06m);
            var smsFailed = new SmsFailed(sid, "c", "m");
            smsService.Expect(s => s.Send(sendOneMessageNow)).Return(smsSending);
            smsService.Expect(s => s.CheckStatus(smsSending.Sid)).Return(smsFailed);
            var timeoutTimespan = new TimeSpan();
            timeoutCalculator.Expect(t => t.RequiredTimeout(Arg<int>.Is.Anything)).Return(timeoutTimespan);

            Test.Initialize();
            Test.Saga<SmsActioner.SmsActioner>()
                .WithExternalDependencies(a => {
                    a.SmsService = smsService;
                    a.TimeoutCalculator = timeoutCalculator;
                })
                    .ExpectTimeoutToBeSetIn<SmsPendingTimeout>((timeoutMessage, timespan) => timespan == timeoutTimespan)
                .When(a => a.Handle(sendOneMessageNow))
                    .ExpectNotPublish<MessageSent>()
                .WhenSagaTimesOut()
                .AssertSagaCompletionIs(true);
        }
        public void SendSingleSmsNow_Failure()
        {
            var sendOneMessageNow = new SendOneMessageNow();

            var smsService = MockRepository.GenerateMock<ISmsService>();
            var smsSent = new SmsFailed("sid", "code", "message");
            smsService.Expect(s => s.Send(sendOneMessageNow)).Return(smsSent);

            Test.Initialize();
            Test.Saga<SmsActioner.SmsActioner>()
                .WithExternalDependencies(a => a.SmsService = smsService)
                    .ExpectPublish<MessageFailedSending>()
                .When(a => a.Handle(sendOneMessageNow))
                .AssertSagaCompletionIs(true);
        }
        public void SendSingleSmsNowQueuedThenFail()
        {
            var sendOneMessageNow = new SendOneMessageNow();

            var smsService = MockRepository.GenerateMock<ISmsService>();

            const string sid = "12";
            var smsQueued = new SmsQueued(sid);
            var smsFailed = new SmsFailed(sid, "c", "m", "m", "s");
            smsService.Expect(s => s.Send(sendOneMessageNow)).Return(smsQueued);
            smsService.Expect(s => s.CheckStatus(smsQueued.Sid)).Return(smsFailed);

            Test.Initialize();
            Test.Saga<SmsActioner>()
                .WithExternalDependencies(a => a.SmsService = smsService)
                    .ExpectTimeoutToBeSetIn<SmsPendingTimeout>((timeoutMessage, timespan) => timespan == TimeSpan.FromSeconds(10))
                .When(a => a.Handle(sendOneMessageNow))
                    .ExpectNotPublish<MessageSent>()
                .WhenSagaTimesOut()
                .AssertSagaCompletionIs(true);
        }
        public void SendOneMessageNow_SmsFailed()
        {
            var sendOneMessageNow = new SendOneMessageNow
                {
                    ConfirmationEmailAddress = "*****@*****.**",
                    CorrelationId = Guid.NewGuid(),
                    SmsData = new SmsData("mobile", "message"),
                    SmsMetaData = new SmsMetaData { Tags = new List<string> { "tag1", "tag2" }, Topic = "topic" }
                };

            var smsService = MockRepository.GenerateMock<ISmsService>();
            var smsFailed = new SmsFailed("sid", "faile", "why why why");

            smsService
                .Expect(s => s.Send(sendOneMessageNow))
                .Return(smsFailed);
            var data = new SmsActionerData();

            Test.Initialize();
            Test.Saga<SmsActioner.SmsActioner>()
                .WithExternalDependencies(a =>
                    {
                        a.SmsService = smsService;
                        a.Data = data;
                    })
                .WhenReceivesMessageFrom("somewhere")
                    .ExpectPublish<MessageFailedSending>(message =>
                        message.ConfirmationEmailAddress == sendOneMessageNow.ConfirmationEmailAddress &&
                        message.CorrelationId == sendOneMessageNow.CorrelationId &&
                        message.SmsData == sendOneMessageNow.SmsData &&
                        message.SmsMetaData == sendOneMessageNow.SmsMetaData &&
                        message.SmsFailed == smsFailed
                    )
                .When(a => a.Handle(sendOneMessageNow))
                .AssertSagaCompletionIs(true);

            smsService.VerifyAllExpectations();
        }