public void Should_Reject_Book_Job_Command_For_The_Past_With_Input_Errors() { var request = new JobRequest {RequestedByDate = DateTime.Now.Subtract(TimeSpan.FromDays(3)), RequestedTask = GetKnownTaskId()}; var sut = new UberJobProcessor(new FakeMessageSender()); var result = sut.Process(request); result.Errors.Any(x => x.GetType() == typeof(JobInThePastError)).ShouldBeTrue(); }
public void Should_Schedule_Valid_Emergency_Job_Request_And_Send_Emergency_Job_Text_with_Date() { var request = new JobRequest{IsEmergency = true, RequestedByDate = DateTime.Now.AddDays(1), RequestedTask = GetKnownTaskId()}; var messenger = new FakeMessageSender(); var sut = new UberJobProcessor(messenger); var result = sut.Process(request); result.ScheduledToBeginOn.ShouldEqual(request.RequestedByDate); var textMessage = (EmergencyJobScheduled) messenger.SentMessage; textMessage.ScheduledDate.ShouldEqual(request.RequestedByDate); }
public void Should_Accept_Valid_Book_Job_Command() { var request = new JobRequest{RequestedByDate = DateTime.Now.AddDays(14), RequestedTask = GetKnownTaskId()}; var sut = new UberJobProcessor(new FakeMessageSender()); var result = sut.Process(request); result.Accepted.ShouldBeTrue(); }
public void Should_Schedule_Valid_Book_Job_Request_If_Scheduled_Work_Acceptable_for_Requested_Date() { var request = new JobRequest{RequestedByDate = DateTime.Now.AddDays(3), RequestedTask = GetKnownTaskId()}; var sut = new UberJobProcessor(new FakeMessageSender()); var result = sut.Process(request); result.ScheduledToBeginOn.Date.ShouldEqual(request.RequestedByDate.Date); }
public void Should_Schedule_Job_Based_On_Results() { var request = new JobRequest {RequestedByDate = DateTime.Now.AddDays(14), RequestedTask = GetKnownTaskId()}; var sut = new UberJobProcessor(new FakeMessageSender()); var result = sut.Process(request); result.ScheduledToBeginOn.CompareTo(request.RequestedByDate).ShouldBeInRange(-14, 0); }
public void Should_Reject_Valid_Book_Job_Request_If_Requested_Date_Full() { var request = new JobRequest{RequestedByDate = _dateWithTooManyScheduledJobs, RequestedTask = GetKnownTaskId()}; var sut = new UberJobProcessor(new FakeMessageSender()); var result = sut.Process(request); result.Errors.Any(x => x.GetType() == typeof(RequestedDateFullError)).ShouldBeTrue(); }
public void Should_Reject_Normal_Job_Request_If_Requested_Date_Sooner_Than_3_Days() { var request = new JobRequest{RequestedByDate = DateTime.Now.AddDays(2), RequestedTask = GetKnownTaskId()}; var sut = new UberJobProcessor(new FakeMessageSender()); var result = sut.Process(request); result.Errors.Any(x => x.GetType() == typeof(RequestedDateTooSoonError)).ShouldBeTrue(); }
public void Should_Reject_Book_Job_Command_For_Unknown_Task_Id_With_UnknownJobError() { var request = new JobRequest {RequestedByDate = DateTime.Now.AddDays(3), RequestedTask = 1231354957}; var sut = new UberJobProcessor(new FakeMessageSender()); var result = sut.Process(request); result.Errors.Any(x => x.GetType() == typeof(UnknownJobIdError)).ShouldBeTrue(); }