public void BuildingManager_Can_Set_Cotractor_For_Maitenance()
        {
            // Arrange
            MaintenanceRequest maintenanceRequest = new MaintenanceRequest(person, "Kvar", "Ne radi grijanje.", "Stan Mile, prvi kat.");

            RepairService serviceTypeForMock = new RepairService("Ličenje");
            Mock<IRepairServicesRepository> repairServicesRepositoryMock = new Mock<IRepairServicesRepository>();
            repairServicesRepositoryMock.Setup(x => x.GetById(23)).Returns(serviceTypeForMock);

            RepairService serviceType = repairServicesRepositoryMock.Object.GetById(23);
            Maintenance maintenance = new Maintenance(maintenanceRequest, Urgency.High, serviceType, building);

            LegalPerson legalPerson = new LegalPerson("12345678901", "Mile d.o.o.");
            Contractor contractor = new Contractor(legalPerson).AddRepairService(serviceType);

            BuildingManager buildingManager = maintenance.BuildingManager;
            buildingManager.AddContractor(contractor);

            // Act
            buildingManager.SetContractorForMaintenance(contractor, maintenance);

            // Assert
            Assert.IsNotNull(maintenance.Contractor);
            Assert.AreEqual(new PersonSnapshot(contractor.LegalPerson), maintenance.Contractor );
        }
예제 #2
0
 public Maintenance(MaintenanceRequest maintenanceRequest, Urgency urgency, RepairService serviceType, Building building)
 {
     this.maintenanceRequest = maintenanceRequest;
     this.building = building;
     this.urgency = urgency;
     this.serviceType = serviceType;
     statusOfMaintenance = StatusOfMaintenance.NotStarted;
 }
        public void Can_Create_MaintenanceRequest()
        {
            // Arrange
            LegalPerson person = new LegalPerson("12345678901", "Mile");

            // Act
            MaintenanceRequest maintenanceRequest = new MaintenanceRequest(person, "Kvar", "Ne radi grijanje.", "Stan Mile, prvi kat.");

            // Assert
            Assert.IsNotNull(maintenanceRequest, "MaintenanceRequest was not created.");
        }
        public void Date_And_Time_Of_Request_Are_Current_After_Creation()
        {
            // Arrange
            LegalPerson person = new LegalPerson("12345678901", "Mile");
            DateTime theTimeBefore = DateTime.Now.AddMilliseconds(-1);

            // Act
            MaintenanceRequest maintenanceRequest = new MaintenanceRequest(person, "Kvar", "Ne radi grijanje.", "Stan Mile, prvi kat.");

            // Assert
            Assert.IsTrue(maintenanceRequest.DateTimeOfRequest > theTimeBefore);
            Assert.IsTrue(maintenanceRequest.DateTimeOfRequest < DateTime.Now.AddMilliseconds(1));
        }
        public void Person_Can_Issue_Maitenance_Request()
        {
            // Arrange
            MaintenanceRequest maintenanceRequest = new MaintenanceRequest(person, "Kvar", "Ne radi grijanje.", "Stan Mile, prvi kat.");

            RepairService serviceTypeForMock = new RepairService("Popravci grijanja i toplana");
            Mock<IRepairServicesRepository> repairServicesRepositoryMock = new Mock<IRepairServicesRepository>();
            repairServicesRepositoryMock.Setup(x => x.GetById(23)).Returns(serviceTypeForMock);

            RepairService serviceType = repairServicesRepositoryMock.Object.GetById(23);

            // Act
            Maintenance maintenance = new Maintenance(maintenanceRequest, Urgency.High, serviceType, building);

            // Assert
            Assert.AreEqual(maintenanceRequest, maintenance.MaintenanceRequest);
            Assert.AreEqual(StatusOfMaintenance.NotStarted, maintenance.StatusOfMaintenance);
            Assert.IsNotNull(maintenance.Urgency, "Hitnost nije definirana.");
            Assert.AreEqual(Urgency.High, maintenance.Urgency);
            Assert.IsNotNull(maintenance.ServiceType, "Usluga popravka nije definirana.");
            Assert.AreEqual(serviceType, maintenance.ServiceType);
        }