Skip to content

Commit 6dcde4f

Browse files
added integration tests for project/multiple endpoint
1 parent 036cffd commit 6dcde4f

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

API.Tests/Controllers/ProjectControllerTests.cs

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,5 +147,54 @@ public async Task Update_Tag_Returns_Expected_Result_For_All_Roles(UserRole role
147147
// Assert
148148
response.StatusCode.Should().Be(expectedResult);
149149
}
150+
151+
152+
[Theory]
153+
[InlineData(UserRole.Alumni, HttpStatusCode.OK)]
154+
[InlineData(UserRole.Admin, HttpStatusCode.OK)]
155+
[InlineData(UserRole.DataOfficer, HttpStatusCode.OK)]
156+
[InlineData(UserRole.PrUser, HttpStatusCode.OK)]
157+
[InlineData(UserRole.RegisteredUser, HttpStatusCode.OK)]
158+
public async Task GetProjects_By_Multiple_Ids_Returns_OK_Result_For_All_Roles(UserRole role, HttpStatusCode expectedResult)
159+
{
160+
// Arrange
161+
await AuthenticateAs(role);
162+
163+
int[] existingProjectIds = new int[] { 1,2,3,10,15,20,30 };
164+
165+
// Act
166+
HttpResponseMessage response = await TestClient.PostAsJsonAsync("project/multiple", existingProjectIds);
167+
168+
// Assert
169+
response.StatusCode.Should().Be(expectedResult);
170+
}
171+
172+
173+
[Theory]
174+
[InlineData(UserRole.Alumni, 7)]
175+
[InlineData(UserRole.Admin, 7)]
176+
[InlineData(UserRole.DataOfficer, 7)]
177+
[InlineData(UserRole.PrUser, 7)]
178+
[InlineData(UserRole.RegisteredUser, 7)]
179+
public async Task GetProjects_By_Multiple_Ids_Returns_Correct_Count_Result_For_All_Roles(UserRole role, int expectedCount)
180+
{
181+
// Arrange
182+
await AuthenticateAs(role);
183+
184+
int[] existingProjectIds = new int[] { 1, 2, 3, 10, 15, 20, 30 };
185+
186+
// Act
187+
HttpResponseMessage response = await TestClient.PostAsJsonAsync("Project/multiple", existingProjectIds);
188+
string result = await response.Content.ReadAsStringAsync();
189+
190+
// Assert
191+
if(response.IsSuccessStatusCode)
192+
{
193+
List<ProjectOutput> projectOutputs = JsonConvert.DeserializeObject<List<ProjectOutput>>(result);
194+
Assert.Equal(expectedCount, projectOutputs.Count);
195+
}
196+
197+
Assert.True(false);
198+
}
150199
}
151200
}

0 commit comments

Comments
 (0)