コード例 #1
0
        public void PostInvalidRequestMessageTooLong()
        {
            var scheduleModel = new Schedule { Number = "number", MessageBody = "blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah", ScheduledTimeUtc = DateTime.Now.AddHours(1) };
            var smsScheduleService = new SmsScheduleService();
            var result = smsScheduleService.OnPost(scheduleModel) as SmsScheduleResponse;

            Assert.That(result.ResponseStatus.Errors[0].Message, Is.EqualTo("Sms message exceeds 160 character length"));
        }
コード例 #2
0
        public void PostInvalidRequestNoNumber()
        {
            var scheduleModel = new Schedule { Number = null, MessageBody = "body", ScheduledTimeUtc = DateTime.Now.AddHours(1) };
            var smsScheduleService = new SmsScheduleService();
            var result = smsScheduleService.OnPost(scheduleModel) as SmsScheduleResponse;

            Assert.That(result.ResponseStatus.Errors[0].Message, Is.EqualTo("Number required"));
        }
コード例 #3
0
        public void PostInvalidRequestScheduleNotSet()
        {
            var scheduleModel = new Schedule {
                Number = "number", MessageBody = "body"
            };
            var smsScheduleService = new SmsScheduleService();
            var result             = smsScheduleService.OnPost(scheduleModel) as SmsScheduleResponse;

            Assert.That(result.ResponseStatus.Errors[0].Message, Is.EqualTo("Start time must be set"));
        }
コード例 #4
0
        public void PostInvalidRequestScheduleInPast()
        {
            var scheduleModel = new Schedule {
                Number = "number", MessageBody = "body", ScheduledTimeUtc = DateTime.Now.AddDays(-11)
            };
            var smsScheduleService = new SmsScheduleService();
            var result             = smsScheduleService.OnPost(scheduleModel) as SmsScheduleResponse;

            Assert.That(result.ResponseStatus.Errors[0].Message, Is.EqualTo("Start time must not be in the past"));
        }
コード例 #5
0
        public void PostInvalidRequestMessageTooLong()
        {
            var scheduleModel = new Schedule {
                Number = "number", MessageBody = "blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah", ScheduledTimeUtc = DateTime.Now.AddHours(1)
            };
            var smsScheduleService = new SmsScheduleService();
            var result             = smsScheduleService.OnPost(scheduleModel) as SmsScheduleResponse;

            Assert.That(result.ResponseStatus.Errors[0].Message, Is.EqualTo("Sms message exceeds 160 character length"));
        }
コード例 #6
0
        public void PostInvalidRequestNoMessage()
        {
            var scheduleModel = new Schedule {
                Number = "number", MessageBody = null, ScheduledTimeUtc = DateTime.Now.AddHours(1)
            };
            var smsScheduleService = new SmsScheduleService();
            var result             = smsScheduleService.OnPost(scheduleModel) as SmsScheduleResponse;

            Assert.That(result.ResponseStatus.Errors[0].Message, Is.EqualTo("Sms message required"));
        }
コード例 #7
0
        public void GetFound()
        {
            var ravenDocStore = MockRepository.GenerateMock<IRavenDocStore>();
            ravenDocStore.Expect(r => r.GetStore()).Return(base.DocumentStore);
            var smsScheduleService = new SmsScheduleService { RavenDocStore = ravenDocStore };

            var request = new Schedule { ScheduleMessageId = scheduleMessageId };
            var response = smsScheduleService.OnGet(request) as ScheduleModel;

            Assert.That(response.ScheduleMessageId, Is.EqualTo(request.ScheduleMessageId));
            ravenDocStore.VerifyAllExpectations();
        }
コード例 #8
0
        public void GetNotFound()
        {
            var ravenDocStore = MockRepository.GenerateMock<IRavenDocStore>();
            ravenDocStore.Expect(r => r.GetStore()).Return(base.DocumentStore);
            var smsScheduleService = new SmsScheduleService { RavenDocStore = ravenDocStore };

            var request = new Schedule { ScheduleMessageId = Guid.NewGuid() };
            var response = smsScheduleService.OnGet(request) as SmsScheduleResponse;

            Assert.That(response.RequestId, Is.EqualTo(request.ScheduleMessageId));
            Assert.That(response.ResponseStatus.ErrorCode, Is.EqualTo("NotFound"));
            ravenDocStore.VerifyAllExpectations();
        }
コード例 #9
0
        public void PostValidRequest()
        {
            var bus           = MockRepository.GenerateMock <IBus>();
            var scheduleModel = new Schedule {
                Number = "number", MessageBody = "m", ScheduledTimeUtc = DateTime.Now.AddHours(1)
            };

            bus.Expect(b => b.Send(Arg <ScheduleSmsForSendingLater> .Is.Anything));

            var smsScheduleService = new SmsScheduleService {
                Bus = bus
            };
            var result = smsScheduleService.OnPost(scheduleModel) as SmsScheduleResponse;

            Assert.That(result.RequestId, Is.Not.EqualTo(Guid.NewGuid()));
            Assert.That(result.ResponseStatus, Is.Null);
        }
コード例 #10
0
        public void GetFound()
        {
            var ravenDocStore = MockRepository.GenerateMock <IRavenDocStore>();

            ravenDocStore.Expect(r => r.GetStore()).Return(base.DocumentStore);
            var smsScheduleService = new SmsScheduleService {
                RavenDocStore = ravenDocStore
            };

            var request = new Schedule {
                ScheduleMessageId = scheduleMessageId
            };
            var response = smsScheduleService.OnGet(request) as ScheduleModel;

            Assert.That(response.ScheduleMessageId, Is.EqualTo(request.ScheduleMessageId));
            ravenDocStore.VerifyAllExpectations();
        }
コード例 #11
0
        public void GetNotFound()
        {
            var ravenDocStore = MockRepository.GenerateMock <IRavenDocStore>();

            ravenDocStore.Expect(r => r.GetStore()).Return(base.DocumentStore);
            var smsScheduleService = new SmsScheduleService {
                RavenDocStore = ravenDocStore
            };

            var request = new Schedule {
                ScheduleMessageId = Guid.NewGuid()
            };
            var response = smsScheduleService.OnGet(request) as SmsScheduleResponse;

            Assert.That(response.RequestId, Is.EqualTo(request.ScheduleMessageId));
            Assert.That(response.ResponseStatus.ErrorCode, Is.EqualTo("NotFound"));
            ravenDocStore.VerifyAllExpectations();
        }
コード例 #12
0
        public void PostInvalidRequestScheduleInPast()
        {
            var scheduleModel = new Schedule { Number = "number", MessageBody = "body", ScheduledTimeUtc = DateTime.Now.AddDays(-11) };
            var smsScheduleService = new SmsScheduleService();
            var result = smsScheduleService.OnPost(scheduleModel) as SmsScheduleResponse;

            Assert.That(result.ResponseStatus.Errors[0].Message, Is.EqualTo("Start time must not be in the past"));
        }
コード例 #13
0
        public void PostValidRequest()
        {
            var bus = MockRepository.GenerateMock<IBus>();
            var scheduleModel = new Schedule { Number = "number", MessageBody = "m", ScheduledTimeUtc = DateTime.Now.AddHours(1) };

            bus.Expect(b => b.Send(Arg<ScheduleSmsForSendingLater>.Is.Anything));

            var smsScheduleService = new SmsScheduleService { Bus = bus };
            var result = smsScheduleService.OnPost(scheduleModel) as SmsScheduleResponse;

            Assert.That(result.RequestId, Is.Not.EqualTo(Guid.NewGuid()));
            Assert.That(result.ResponseStatus, Is.Null);
        }
コード例 #14
0
        public void PostInvalidRequestScheduleNotSet()
        {
            var scheduleModel = new Schedule { Number = "number", MessageBody = "body" };
            var smsScheduleService = new SmsScheduleService();
            var result = smsScheduleService.OnPost(scheduleModel) as SmsScheduleResponse;

            Assert.That(result.ResponseStatus.Errors[0].Message, Is.EqualTo("Start time must be set"));
        }