Beispiel #1
0
        public void Finish_Should_Finish_An_Existing_Job()
        {
            // arrange
            CustomerBuilder       customerBuilder       = new CustomerBuilder();
            VehicleBuilder        vehicleBuilder        = new VehicleBuilder();
            MaintenanceJobBuilder maintenanceJobBuilder = new MaintenanceJobBuilder();
            Customer customer = customerBuilder
                                .Build();
            Vehicle vehicle = vehicleBuilder
                              .WithCustomerId(customer.CustomerId)
                              .Build();
            MaintenanceJob sut = maintenanceJobBuilder
                                 .WithCustomer(customer)
                                 .WithVehicle(vehicle)
                                 .Build();

            DateTime actualStartTime = maintenanceJobBuilder.StartTime.AddMinutes(30);
            DateTime actualEndTime   = maintenanceJobBuilder.EndTime.AddMinutes(15);
            string   notes           = $"Mechanic notes {maintenanceJobBuilder.Id}";

            // act
            sut.Finish(actualStartTime, actualEndTime, notes);

            // assert
            Assert.Equal(maintenanceJobBuilder.Id, sut.Id);
            Assert.Equal(maintenanceJobBuilder.StartTime, sut.StartTime);
            Assert.Equal(maintenanceJobBuilder.EndTime, sut.EndTime);
            Assert.Equal(customer, sut.Customer);
            Assert.Equal(vehicle, sut.Vehicle);
            Assert.Equal(maintenanceJobBuilder.Description, sut.Description);
            Assert.Equal(actualStartTime, sut.ActualStartTime.Value);
            Assert.Equal(actualEndTime, sut.ActualEndTime.Value);
            Assert.Equal(notes, sut.Notes);
            Assert.Equal("Completed", sut.Status);
        }
        public void Finish_Should_Finish_An_Existing_Job()
        {
            // arrange
            MaintenanceJobBuilder maintenanceJobBuilder = new MaintenanceJobBuilder();
            MaintenanceJob        sut = maintenanceJobBuilder
                                        .Build();

            DateTime actualStartTime = maintenanceJobBuilder.StartTime.AddMinutes(30);
            DateTime actualEndTime   = maintenanceJobBuilder.EndTime.AddMinutes(15);
            string   notes           = $"Mechanic notes {maintenanceJobBuilder.JobId}";

            // act
            sut.Finish(actualStartTime, actualEndTime, notes);

            // assert
            Assert.Equal(maintenanceJobBuilder.JobId, sut.Id);
            Assert.Equal(maintenanceJobBuilder.StartTime, sut.StartTime);
            Assert.Equal(maintenanceJobBuilder.EndTime, sut.EndTime);
            Assert.Equal(maintenanceJobBuilder.CustomerBuilder.Id, sut.Customer.Id);
            Assert.Equal(maintenanceJobBuilder.CustomerBuilder.Name, sut.Customer.Name);
            Assert.Equal(maintenanceJobBuilder.CustomerBuilder.TelephoneNumber, sut.Customer.TelephoneNumber);
            Assert.Equal(maintenanceJobBuilder.VehicleBuilder.LicenseNumber, sut.Vehicle.Id);
            Assert.Equal(maintenanceJobBuilder.VehicleBuilder.Brand, sut.Vehicle.Brand);
            Assert.Equal(maintenanceJobBuilder.VehicleBuilder.Type, sut.Vehicle.Type);
            Assert.Equal(maintenanceJobBuilder.VehicleBuilder.OwnerId, sut.Vehicle.OwnerId);
            Assert.Equal(maintenanceJobBuilder.Description, sut.Description);
            Assert.Equal(actualStartTime, sut.ActualStartTime.Value);
            Assert.Equal(actualEndTime, sut.ActualEndTime.Value);
            Assert.Equal(notes, sut.Notes);
            Assert.Equal("Completed", sut.Status);
        }
Beispiel #3
0
        public void Plan_Should_Create_A_New_Job()
        {
            // arrange
            CustomerBuilder       customerBuilder       = new CustomerBuilder();
            VehicleBuilder        vehicleBuilder        = new VehicleBuilder();
            MaintenanceJobBuilder maintenanceJobBuilder = new MaintenanceJobBuilder();
            Customer customer = customerBuilder
                                .Build();
            Vehicle vehicle = vehicleBuilder
                              .WithCustomerId(customer.CustomerId)
                              .Build();
            MaintenanceJob sut = maintenanceJobBuilder
                                 .WithCustomer(customer)
                                 .WithVehicle(vehicle)
                                 .Build();

            // act
            // sut.Plan() is called by the Testdata Builder

            // assert
            Assert.Equal(maintenanceJobBuilder.Id, sut.Id);
            Assert.Equal(maintenanceJobBuilder.StartTime, sut.StartTime);
            Assert.Equal(maintenanceJobBuilder.EndTime, sut.EndTime);
            Assert.Equal(customer, sut.Customer);
            Assert.Equal(vehicle, sut.Vehicle);
            Assert.Equal(maintenanceJobBuilder.Description, sut.Description);
            Assert.Null(sut.ActualStartTime);
            Assert.Null(sut.ActualEndTime);
            Assert.Null(sut.Notes);
            Assert.Equal("Planned", sut.Status);
        }
Beispiel #4
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 void Plan_Should_Create_A_New_Job()
        {
            // arrange
            MaintenanceJobBuilder maintenanceJobBuilder = new MaintenanceJobBuilder();
            MaintenanceJob        sut = maintenanceJobBuilder
                                        .Build();

            // act
            // sut.Plan() is called by the Testdata Builder

            // assert
            Assert.Equal(maintenanceJobBuilder.JobId, sut.Id);
            Assert.Equal(maintenanceJobBuilder.StartTime, sut.StartTime);
            Assert.Equal(maintenanceJobBuilder.EndTime, sut.EndTime);
            Assert.Equal(maintenanceJobBuilder.CustomerBuilder.Id, sut.Customer.Id);
            Assert.Equal(maintenanceJobBuilder.CustomerBuilder.Name, sut.Customer.Name);
            Assert.Equal(maintenanceJobBuilder.CustomerBuilder.TelephoneNumber, sut.Customer.TelephoneNumber);
            Assert.Equal(maintenanceJobBuilder.VehicleBuilder.LicenseNumber, sut.Vehicle.Id);
            Assert.Equal(maintenanceJobBuilder.VehicleBuilder.Brand, sut.Vehicle.Brand);
            Assert.Equal(maintenanceJobBuilder.VehicleBuilder.Type, sut.Vehicle.Type);
            Assert.Equal(maintenanceJobBuilder.VehicleBuilder.OwnerId, sut.Vehicle.OwnerId);
            Assert.Equal(maintenanceJobBuilder.Description, sut.Description);
            Assert.Null(sut.ActualStartTime);
            Assert.Null(sut.ActualEndTime);
            Assert.Null(sut.Notes);
            Assert.Equal("Planned", sut.Status);
        }
Beispiel #6
0
        public void Update_Should_Update_Existing_Job()
        {
            // arrange
            MaintenanceJobBuilder maintenanceJobBuilder = new MaintenanceJobBuilder();
            MaintenanceJob        sut = maintenanceJobBuilder
                                        .Build();

            var description = "Description has been updated";

            // act
            sut.Update(sut.StartTime, sut.EndTime, sut.Vehicle, sut.Customer, description);

            // assert
            Assert.Equal(maintenanceJobBuilder.JobId, sut.Id);
            Assert.Equal(maintenanceJobBuilder.StartTime, sut.StartTime);
            Assert.Equal(maintenanceJobBuilder.EndTime, sut.EndTime);
            Assert.Equal(maintenanceJobBuilder.CustomerBuilder.Id, sut.Customer.Id);
            Assert.Equal(maintenanceJobBuilder.CustomerBuilder.Name, sut.Customer.Name);
            Assert.Equal(maintenanceJobBuilder.CustomerBuilder.TelephoneNumber, sut.Customer.TelephoneNumber);
            Assert.Equal(maintenanceJobBuilder.VehicleBuilder.LicenseNumber, sut.Vehicle.Id);
            Assert.Equal(maintenanceJobBuilder.VehicleBuilder.Brand, sut.Vehicle.Brand);
            Assert.Equal(maintenanceJobBuilder.VehicleBuilder.Type, sut.Vehicle.Type);
            Assert.Equal(maintenanceJobBuilder.VehicleBuilder.OwnerId, sut.Vehicle.OwnerId);
            Assert.Equal(description, sut.Description);
            Assert.Null(sut.ActualStartTime);
            Assert.Null(sut.ActualEndTime);
            Assert.Null(sut.Notes);
            Assert.Equal("Planned", sut.Status);
        }
    public MaintenanceJobPlanned Build()
    {
        var customer = CustomerBuilder
                       .Build();

        var vehicle = VehicleBuilder
                      .WithOwnerId(customer.Id)
                      .Build();

        var job = MaintenanceJobBuilder
                  .WithCustomer(customer)
                  .WithVehicle(vehicle)
                  .Build();

        MaintenanceJobPlanned e = new MaintenanceJobPlanned(
            Guid.NewGuid(), job.Id, job.PlannedTimeslot.StartTime, job.PlannedTimeslot.EndTime,
            (customer.Id, customer.Name, customer.TelephoneNumber),
            (vehicle.Id, vehicle.Brand, vehicle.Type),
            job.Description
            );

        return(e);
    }
 private void SetDefaults()
 {
     CustomerBuilder       = new CustomerBuilder();
     VehicleBuilder        = new VehicleBuilder();
     MaintenanceJobBuilder = new MaintenanceJobBuilder();
 }
 public MaintenanceJobPlannedEventBuilder WithEndTime(DateTime endTime)
 {
     MaintenanceJobBuilder.WithEndTime(endTime);
     return(this);
 }
 public MaintenanceJobPlannedEventBuilder WithStartTime(DateTime startTime)
 {
     MaintenanceJobBuilder.WithStartTime(startTime);
     return(this);
 }
 public MaintenanceJobPlannedEventBuilder WithJobId(Guid jobId)
 {
     MaintenanceJobBuilder.WithJobId(jobId);
     return(this);
 }
Beispiel #12
0
 public PlanMaintenanceJobCommandBuilder WithMaintenanceJobBuilder(MaintenanceJobBuilder maintenanceJobBuilder)
 {
     MaintenanceJobBuilder = maintenanceJobBuilder;
     return(this);
 }