Skip to content

Commit 5fb3a8b

Browse files
committed
Fix csharpier not running in pipeline
1 parent 1739672 commit 5fb3a8b

File tree

140 files changed

+6298
-2779
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

140 files changed

+6298
-2779
lines changed

.github/workflows/backend_lint_and_test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,4 @@ jobs:
6363
- name: Run csharpier format
6464
run: |
6565
dotnet tool restore
66-
dotnet csharpier --check
66+
dotnet csharpier . --check

backend/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,8 @@ psql U Username -d postgres -h host_name_or_adress -p port -f ouput_file_name.sl
257257

258258
### CSharpier
259259

260-
In everyday development we use [CSharpier](https://csharpier.com/) to auto-format code on save. Installation procedure is described [here](https://csharpier.com/docs/About). No configuration should be required.
260+
In everyday development we use [CSharpier](https://csharpier.com/) to auto-format code on save. Installation procedure is described [here](https://csharpier.com/docs/About). No configuration should be required. To run csharpier locally, go to the backend folder and run:
261+
`dotnet csharpier . --check`
261262

262263
### Dotnet format
263264

backend/api.test/Client/AreaTests.cs

Lines changed: 63 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
using Api.Test.Database;
1414
using Microsoft.AspNetCore.Mvc.Testing;
1515
using Xunit;
16+
1617
namespace Api.Test.Client
1718
{
1819
[Collection("Database collection")]
@@ -23,27 +24,27 @@ public class AreaTests : IClassFixture<TestWebApplicationFactory<Program>>
2324
private readonly JsonSerializerOptions _serializerOptions =
2425
new()
2526
{
26-
Converters =
27-
{
28-
new JsonStringEnumConverter()
29-
},
30-
PropertyNameCaseInsensitive = true
27+
Converters = { new JsonStringEnumConverter() },
28+
PropertyNameCaseInsensitive = true,
3129
};
3230

3331
public AreaTests(TestWebApplicationFactory<Program> factory)
3432
{
35-
_client = factory.CreateClient(new WebApplicationFactoryClientOptions
36-
{
37-
AllowAutoRedirect = false,
38-
BaseAddress = new Uri("https://localhost:8000")
39-
});
33+
_client = factory.CreateClient(
34+
new WebApplicationFactoryClientOptions
35+
{
36+
AllowAutoRedirect = false,
37+
BaseAddress = new Uri("https://localhost:8000"),
38+
}
39+
);
4040
_client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(
4141
TestAuthHandler.AuthenticationScheme
4242
);
4343

44-
object? context = factory.Services.GetService(typeof(FlotillaDbContext)) as FlotillaDbContext ?? throw new ArgumentNullException(nameof(factory));
44+
object? context =
45+
factory.Services.GetService(typeof(FlotillaDbContext)) as FlotillaDbContext
46+
?? throw new ArgumentNullException(nameof(factory));
4547
_databaseUtilities = new DatabaseUtilities((FlotillaDbContext)context);
46-
4748
}
4849

4950
[Fact]
@@ -56,38 +57,38 @@ public async Task AreaTest()
5657
{
5758
X = 1,
5859
Y = 2,
59-
Z = 2
60+
Z = 2,
6061
},
6162
Orientation = new Orientation
6263
{
6364
X = 0,
6465
Y = 0,
6566
Z = 0,
66-
W = 1
67-
}
67+
W = 1,
68+
},
6869
};
6970

7071
string testInstallation = "TestInstallationAreaTest";
7172
var installationQuery = new CreateInstallationQuery
7273
{
7374
InstallationCode = testInstallation,
74-
Name = testInstallation
75+
Name = testInstallation,
7576
};
7677

7778
string testPlant = "TestPlantAreaTest";
7879
var plantQuery = new CreatePlantQuery
7980
{
8081
InstallationCode = testInstallation,
8182
PlantCode = testPlant,
82-
Name = testPlant
83+
Name = testPlant,
8384
};
8485

8586
string testDeck = "testDeckAreaTest";
8687
var deckQuery = new CreateDeckQuery
8788
{
8889
InstallationCode = testInstallation,
8990
PlantCode = testPlant,
90-
Name = testDeck
91+
Name = testDeck,
9192
};
9293

9394
string testArea = "testAreaAreaTest";
@@ -97,7 +98,7 @@ public async Task AreaTest()
9798
PlantCode = testPlant,
9899
DeckName = testDeck,
99100
AreaName = testArea,
100-
DefaultLocalizationPose = testPose
101+
DefaultLocalizationPose = testPose,
101102
};
102103

103104
var installationContent = new StringContent(
@@ -126,7 +127,10 @@ public async Task AreaTest()
126127

127128
// Act
128129
string installationUrl = "/installations";
129-
var installationResponse = await _client.PostAsync(installationUrl, installationContent);
130+
var installationResponse = await _client.PostAsync(
131+
installationUrl,
132+
installationContent
133+
);
130134
string plantUrl = "/plants";
131135
var plantResponse = await _client.PostAsync(plantUrl, plantContent);
132136
string deckUrl = "/decks";
@@ -139,7 +143,9 @@ public async Task AreaTest()
139143
Assert.True(plantResponse.IsSuccessStatusCode);
140144
Assert.True(deckResponse.IsSuccessStatusCode);
141145
Assert.True(areaResponse.IsSuccessStatusCode);
142-
var area = await areaResponse.Content.ReadFromJsonAsync<AreaResponse>(_serializerOptions);
146+
var area = await areaResponse.Content.ReadFromJsonAsync<AreaResponse>(
147+
_serializerOptions
148+
);
143149
Assert.NotNull(area);
144150
}
145151

@@ -149,7 +155,10 @@ public async Task MissionIsCreatedInInspectionArea()
149155
// Arrange - Initialise area
150156
var installation = await _databaseUtilities.ReadOrNewInstallation();
151157
var plant = await _databaseUtilities.ReadOrNewPlant(installation.InstallationCode);
152-
var deck = await _databaseUtilities.ReadOrNewDeck(installation.InstallationCode, plant.PlantCode);
158+
var deck = await _databaseUtilities.ReadOrNewDeck(
159+
installation.InstallationCode,
160+
plant.PlantCode
161+
);
153162

154163
// Arrange - Robot
155164
var robot = await _databaseUtilities.NewRobot(RobotStatus.Available, installation);
@@ -161,7 +170,7 @@ public async Task MissionIsCreatedInInspectionArea()
161170
{
162171
AnalysisType = AnalysisType.CarSeal,
163172
InspectionTarget = new Position(),
164-
InspectionType = InspectionType.Image
173+
InspectionType = InspectionType.Image,
165174
};
166175
var tasks = new List<CustomTaskQuery>
167176
{
@@ -170,8 +179,8 @@ public async Task MissionIsCreatedInInspectionArea()
170179
Inspection = inspection,
171180
TagId = "test",
172181
RobotPose = new Pose(),
173-
TaskOrder = 0
174-
}
182+
TaskOrder = 0,
183+
},
175184
};
176185
var missionQuery = new CustomMissionQuery
177186
{
@@ -180,7 +189,7 @@ public async Task MissionIsCreatedInInspectionArea()
180189
InstallationCode = installation.InstallationCode,
181190
InspectionAreaName = deck.Name,
182191
Name = testMissionName,
183-
Tasks = tasks
192+
Tasks = tasks,
184193
};
185194

186195
var missionContent = new StringContent(
@@ -194,17 +203,25 @@ public async Task MissionIsCreatedInInspectionArea()
194203
var missionResponse = await _client.PostAsync(missionUrl, missionContent);
195204

196205
Assert.True(missionResponse.IsSuccessStatusCode);
197-
var mission = await missionResponse.Content.ReadFromJsonAsync<MissionRun>(_serializerOptions);
206+
var mission = await missionResponse.Content.ReadFromJsonAsync<MissionRun>(
207+
_serializerOptions
208+
);
198209
Assert.NotNull(mission);
199210
Assert.NotNull(mission.MissionId);
200211
string inspectionAreaUrl = "/decks";
201-
var inspectionareaMissionsResponse = await _client.GetAsync(inspectionAreaUrl + $"/{deck.Id}/mission-definitions");
212+
var inspectionareaMissionsResponse = await _client.GetAsync(
213+
inspectionAreaUrl + $"/{deck.Id}/mission-definitions"
214+
);
202215

203216
// Assert
204217
Assert.True(inspectionareaMissionsResponse.IsSuccessStatusCode);
205-
var missions = await inspectionareaMissionsResponse.Content.ReadFromJsonAsync<IList<MissionDefinitionResponse>>(_serializerOptions);
218+
var missions = await inspectionareaMissionsResponse.Content.ReadFromJsonAsync<
219+
IList<MissionDefinitionResponse>
220+
>(_serializerOptions);
206221
Assert.NotNull(missions);
207-
Assert.Single(missions.Where(m => m.Id.Equals(mission.MissionId, StringComparison.Ordinal)));
222+
Assert.Single(
223+
missions.Where(m => m.Id.Equals(mission.MissionId, StringComparison.Ordinal))
224+
);
208225
}
209226

210227
[Fact]
@@ -214,9 +231,9 @@ public async Task EmergencyDockTest()
214231
var installation = await _databaseUtilities.ReadOrNewInstallation();
215232
string installationCode = installation.InstallationCode;
216233

217-
218234
// Act
219-
string goToDockingPositionUrl = $"/emergency-action/{installationCode}/abort-current-missions-and-send-all-robots-to-safe-zone";
235+
string goToDockingPositionUrl =
236+
$"/emergency-action/{installationCode}/abort-current-missions-and-send-all-robots-to-safe-zone";
220237
var missionResponse = await _client.PostAsync(goToDockingPositionUrl, null);
221238

222239
// Assert
@@ -233,7 +250,10 @@ public async Task UpdateDefaultLocalizationPoseOnDeck()
233250
// Arrange
234251
var installation = await _databaseUtilities.ReadOrNewInstallation();
235252
var plant = await _databaseUtilities.ReadOrNewPlant(installation.InstallationCode);
236-
var deck = await _databaseUtilities.ReadOrNewDeck(installation.InstallationCode, plant.PlantCode);
253+
var deck = await _databaseUtilities.ReadOrNewDeck(
254+
installation.InstallationCode,
255+
plant.PlantCode
256+
);
237257

238258
string deckId = deck.Id;
239259

@@ -246,16 +266,16 @@ public async Task UpdateDefaultLocalizationPoseOnDeck()
246266
{
247267
X = 1,
248268
Y = 2,
249-
Z = 3
269+
Z = 3,
250270
},
251271
Orientation = new Orientation
252272
{
253273
X = 0,
254274
Y = 0,
255275
Z = 0,
256-
W = 1
257-
}
258-
}
276+
W = 1,
277+
},
278+
},
259279
};
260280
var content = new StringContent(
261281
JsonSerializer.Serialize(query),
@@ -266,13 +286,17 @@ public async Task UpdateDefaultLocalizationPoseOnDeck()
266286
// Act
267287
var putResponse = await _client.PutAsync(url, content);
268288
Assert.True(putResponse.IsSuccessStatusCode);
269-
var putDeck = await putResponse.Content.ReadFromJsonAsync<DeckResponse>(_serializerOptions);
289+
var putDeck = await putResponse.Content.ReadFromJsonAsync<DeckResponse>(
290+
_serializerOptions
291+
);
270292

271293
// Assert
272294
Assert.NotNull(putDeck);
273295
Assert.NotNull(putDeck.DefaultLocalizationPose);
274296
Assert.True(putDeck.DefaultLocalizationPose.Position.Z.Equals(query.Pose.Position.Z));
275-
Assert.True(putDeck.DefaultLocalizationPose.Orientation.W.Equals(query.Pose.Orientation.W));
297+
Assert.True(
298+
putDeck.DefaultLocalizationPose.Orientation.W.Equals(query.Pose.Orientation.W)
299+
);
276300
}
277301
}
278302
}

0 commit comments

Comments
 (0)