Example #1
0
        public void SendSingleSmsNowQueuedTwiceThenSuccess()
        {
            var sendOneMessageNow = new SendOneMessageNow();

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

            const string sid        = "12";
            var          smsQueued  = new SmsQueued(sid);
            var          smsSuccess = new SmsSent(new SmsConfirmationData("r", DateTime.Now, 3.3m));

            smsService.Expect(s => s.Send(sendOneMessageNow)).Return(smsQueued);
            smsService.Expect(s => s.CheckStatus(smsQueued.Sid)).Repeat.Once().Return(smsQueued);
            smsService.Expect(s => s.CheckStatus(smsQueued.Sid)).Return(smsSuccess);

            Test.Initialize();
            Test.Saga <SmsActioner.SmsActioner>()
            .WithExternalDependencies(a => a.SmsService = smsService)
            .ExpectTimeoutToBeSetIn <SmsPendingTimeout>((timeoutMessage, timespan) => timespan == TimeSpan.FromSeconds(10))
            .When(a => a.Handle(sendOneMessageNow))
            .ExpectNotPublish <MessageSent>()
            .ExpectTimeoutToBeSetIn <SmsPendingTimeout>((timeoutMessage, timespan) => timespan == TimeSpan.FromSeconds(10))
            .WhenSagaTimesOut()
            .ExpectPublish <MessageSent>()
            .ExpectReplyToOriginator <MessageSuccessfullyDelivered>()
            .ExpectSendLocal <MessageSuccessfullyDelivered>()
            .WhenSagaTimesOut();
        }
Example #2
0
        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.SmsActioner>()
            .WithExternalDependencies(a => a.SmsService = smsService)
            .ExpectTimeoutToBeSetIn <SmsPendingTimeout>((timeoutMessage, timespan) => timespan == TimeSpan.FromSeconds(10))
            .When(a => a.Handle(sendOneMessageNow))
            .ExpectNotPublish <MessageSent>()
            .ExpectReplyToOriginator <MessageFailedSending>()
            .ExpectSendLocal <MessageFailedSending>()
            .WhenSagaTimesOut()
            .AssertSagaCompletionIs(true);
        }