示例#1
0
        public void Plan_MaintenanceJob_That_Spans_Two_Days_Should_Throw_Exception()
        {
            // arrange
            DateTime date = DateTime.Today;
            var      initializingEvents = new Event[] {
                new WorkshopPlanningCreatedEventBuilder().WithDate(date).Build()
            };
            WorkshopPlanning sut = new WorkshopPlanning(date, initializingEvents);

            MaintenanceJobBuilder maintenanceJobBuilder = new MaintenanceJobBuilder();

            maintenanceJobBuilder
            .WithStartTime(DateTime.Today.AddHours(-2));     // to make the job span 2 days
            PlanMaintenanceJob command = new PlanMaintenanceJobCommandBuilder()
                                         .WithMaintenanceJobBuilder(maintenanceJobBuilder)
                                         .Build();

            // act
            var thrownException =
                Assert.Throws <BusinessRuleViolationException>(() => sut.PlanMaintenanceJob(command));

            // assert
            Assert.Equal("Start-time and end-time of a Maintenance Job must be within a 1 day.",
                         thrownException.Message);
        }
 public MaintenanceJobPlannedEventBuilder WithStartTime(DateTime startTime)
 {
     MaintenanceJobBuilder.WithStartTime(startTime);
     return(this);
 }