-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #317 from DFE-Digital/feature/dashboard-filter-pro…
…ject-managed-by Added API tests
- Loading branch information
Showing
4 changed files
with
95 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
...oolProjects/Dfe.ManageFreeSchoolProjects.API.Tests/Integration/ProjectManagersApiTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
using Dfe.ManageFreeSchoolProjects.API.Contracts.Dashboard; | ||
using Dfe.ManageFreeSchoolProjects.API.Contracts.Project; | ||
using Dfe.ManageFreeSchoolProjects.API.Contracts.ResponseModels; | ||
using Dfe.ManageFreeSchoolProjects.API.Tests.Fixtures; | ||
using Dfe.ManageFreeSchoolProjects.API.Tests.Helpers; | ||
using Dfe.ManageFreeSchoolProjects.Data.Entities.Existing; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Net; | ||
using System.Net.Http.Json; | ||
using System.Threading.Tasks; | ||
|
||
namespace Dfe.ManageFreeSchoolProjects.API.Tests.Integration | ||
{ | ||
[Collection(ApiTestCollection.ApiTestCollectionName)] | ||
public class ProjectManagersApiTests : ApiTestsBase | ||
{ | ||
public ProjectManagersApiTests(ApiTestFixture apiTestFixture) : base(apiTestFixture) | ||
{ | ||
} | ||
|
||
[Fact] | ||
public async Task When_Get_ProjectManagers_Returns_ProjectManagers_200() | ||
{ | ||
using var context = _testFixture.GetContext(); | ||
|
||
var projectOne = DatabaseModelBuilder.BuildProject(); | ||
var projectTwo = DatabaseModelBuilder.BuildProject(); | ||
|
||
context.Kpi.AddRange(projectOne, projectTwo); | ||
|
||
await context.SaveChangesAsync(); | ||
|
||
var projectManagersResponse = await _client.GetAsync($"/api/v1/client/project-managers"); | ||
projectManagersResponse.StatusCode.Should().Be(HttpStatusCode.OK); | ||
|
||
var responseContent = await projectManagersResponse.Content | ||
.ReadFromJsonAsync<ApiSingleResponseV2<GetProjectManagersResponse>>(); | ||
var projectManagers = responseContent.Data.ProjectManagers; | ||
|
||
var expectedProjectManagers = new List<string>() | ||
{ | ||
projectOne.KeyContactsFsgLeadContact, projectTwo.KeyContactsFsgLeadContact | ||
}; | ||
|
||
projectManagers.Should().HaveCountGreaterThanOrEqualTo(2); | ||
projectManagers.Should().Contain(projectOne.KeyContactsFsgLeadContact); | ||
projectManagers.Should().Contain(projectTwo.KeyContactsFsgLeadContact); | ||
|
||
} | ||
|
||
} | ||
} |
3 changes: 2 additions & 1 deletion
3
Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
wwwroot/dist | ||
wwwroot/assets | ||
wwwroot/assets | ||
wwwroot/package-lock.json |