-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…1466) * Replace hardcoded case types * Refactor test data * Map to bookings api * Use bookings api pr url * TODOs * Replace with ResponseTestData * More code coverage * Sonar fixes * Test updates * Revert test url * Update nuget packages
- Loading branch information
1 parent
98753a4
commit 53e65e7
Showing
44 changed files
with
450 additions
and
165 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
56 changes: 56 additions & 0 deletions
56
AdminWebsite/AdminWebsite.UnitTests/Controllers/ReferenceData/HearingTypesControllerTests.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,56 @@ | ||
using System.Linq; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using AdminWebsite.Controllers.ReferenceData; | ||
using AdminWebsite.Mappers; | ||
using AdminWebsite.Services; | ||
using BookingsApi.Contract.V2.Responses; | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace AdminWebsite.UnitTests.Controllers.ReferenceData; | ||
|
||
public class HearingTypesControllerTests | ||
{ | ||
private Mock<IReferenceDataService> _referenceDataService; | ||
private HearingTypesController _controller; | ||
|
||
[SetUp] | ||
public void SetUp() | ||
{ | ||
_referenceDataService = new Mock<IReferenceDataService>(); | ||
_controller = new HearingTypesController(_referenceDataService.Object); | ||
} | ||
|
||
[Test] | ||
public async Task Should_return_list_of_hearing_types() | ||
{ | ||
// Arrange | ||
var types = new List<CaseTypeResponseV2> | ||
{ | ||
new() | ||
{ | ||
Id = 1, | ||
Name = "Name1", | ||
ServiceId = "123", | ||
IsAudioRecordingAllowed = true | ||
}, | ||
new() | ||
{ | ||
Id = 2, | ||
Name = "Name2", | ||
ServiceId = "456", | ||
IsAudioRecordingAllowed = false | ||
} | ||
}; | ||
|
||
_referenceDataService.Setup(x => x.GetNonDeletedCaseTypesAsync(It.IsAny<CancellationToken>())) | ||
.ReturnsAsync(types); | ||
|
||
// Act | ||
var response = await _controller.GetHearingTypes(); | ||
|
||
// Assert | ||
var result = (OkObjectResult)response.Result; | ||
result.Value.Should().BeEquivalentTo(types.Select(t => t.Map())); | ||
} | ||
} |
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
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
29 changes: 29 additions & 0 deletions
29
AdminWebsite/AdminWebsite.UnitTests/Mappers/HearingTypeResponseMapperTests.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,29 @@ | ||
using AdminWebsite.Mappers; | ||
using BookingsApi.Contract.V2.Responses; | ||
|
||
namespace AdminWebsite.UnitTests.Mappers; | ||
|
||
public class HearingTypeResponseMapperTests | ||
{ | ||
[Test] | ||
public void Should_map_v2() | ||
{ | ||
// Arrange | ||
var type = new CaseTypeResponseV2 | ||
{ | ||
Id = 1, | ||
Name = "Name", | ||
ServiceId = "123", | ||
IsAudioRecordingAllowed = true | ||
}; | ||
|
||
// Act | ||
var result = type.Map(); | ||
|
||
// Assert | ||
result.Id.Should().Be(type.Id); | ||
result.Group.Should().Be(type.Name); | ||
result.ServiceId.Should().Be(type.ServiceId); | ||
result.IsAudioRecordingAllowed.Should().Be(type.IsAudioRecordingAllowed); | ||
} | ||
} |
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
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
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
Oops, something went wrong.