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"));
        }
        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"));
        }
        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"));
        }
        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"));
        }
        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"));
        }
        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"));
        }
        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);
        }
        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"));
        }
        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);
        }
        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"));
        }