|
2 | 2 | using Api.Controllers.Models; |
3 | 3 | using Api.Database.Models; |
4 | 4 | using Api.Services; |
| 5 | +using Api.Services.Models; |
5 | 6 | using Api.Test.Database; |
6 | 7 | using Microsoft.Extensions.DependencyInjection; |
7 | 8 | using Testcontainers.PostgreSql; |
@@ -72,5 +73,58 @@ await DatabaseUtilities.NewMissionRun( |
72 | 73 | // We expect two new missions since a return home mission will also be scheduled |
73 | 74 | Assert.Equal(nReportsBefore + 1, nReportsAfter); |
74 | 75 | } |
| 76 | + |
| 77 | + [Fact] |
| 78 | + public async Task CheckThatReturnHomeIsNotDeletedWhenPreviousMissionWasOutsideInspectionArea() |
| 79 | + { |
| 80 | + // Arrange |
| 81 | + var installation = await DatabaseUtilities.NewInstallation(); |
| 82 | + var plant = await DatabaseUtilities.NewPlant(installation.InstallationCode); |
| 83 | + var inspectionArea1 = await DatabaseUtilities.NewInspectionArea( |
| 84 | + installation.InstallationCode, |
| 85 | + plant.PlantCode, |
| 86 | + inspectionAreaName: "Inspection area 1", |
| 87 | + new InspectionAreaPolygon |
| 88 | + { |
| 89 | + ZMin = 0, |
| 90 | + ZMax = 10, |
| 91 | + Positions = [new XYPosition(x: 0, y: 0), new XYPosition(x: 0, y: 10), new XYPosition(x: 10, y: 10), new XYPosition(x: 10, y: 0)] |
| 92 | + } |
| 93 | + ); |
| 94 | + var inspectionArea2 = await DatabaseUtilities.NewInspectionArea( |
| 95 | + installation.InstallationCode, |
| 96 | + plant.PlantCode, |
| 97 | + inspectionAreaName: "Inspection area 2", |
| 98 | + new InspectionAreaPolygon |
| 99 | + { |
| 100 | + ZMin = 0, |
| 101 | + ZMax = 10, |
| 102 | + Positions = [new XYPosition(x: 0, y: 0), new XYPosition(x: 0, y: -10), new XYPosition(x: -10, y: -10), new XYPosition(x: -10, y: 0)] |
| 103 | + } |
| 104 | + ); |
| 105 | + |
| 106 | + var taskOutsideInspectionArea = new MissionTask(new Pose(-5, -5, 0, 0, 0, 0, 0), MissionTaskType.Inspection); |
| 107 | + |
| 108 | + var robot = await DatabaseUtilities.NewRobot(RobotStatus.Available, installation, inspectionArea2); |
| 109 | + await DatabaseUtilities.NewMissionRun( |
| 110 | + installation.InstallationCode, |
| 111 | + robot, |
| 112 | + inspectionArea1, |
| 113 | + writeToDatabase: true, |
| 114 | + tasks: [taskOutsideInspectionArea] |
| 115 | + ); |
| 116 | + |
| 117 | + // Act |
| 118 | + await MissionSchedulingService.StartNextMissionRunIfSystemIsAvailable(robot); |
| 119 | + |
| 120 | + // Assert |
| 121 | + var reportsAfter = await MissionRunService.ReadAll( |
| 122 | + new MissionRunQueryStringParameters() |
| 123 | + ); |
| 124 | + |
| 125 | + Assert.Single(reportsAfter); |
| 126 | + Assert.True(reportsAfter[0].IsReturnHomeMission()); |
| 127 | + Assert.Equal(MissionStatus.Ongoing, reportsAfter[0].Status); |
| 128 | + } |
75 | 129 | } |
76 | 130 | } |
0 commit comments