Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,9 @@ private async Task<List<ValidationException>> GetValidationExceptionsByNhsNumber
{
var exceptions = await _validationExceptionDataServiceClient.GetByFilter(x =>
x.NhsNumber == nhsNumber &&
x.Category.HasValue &&
(x.Category.Value == (int)ExceptionCategory.NBO ||
x.Category.Value == (int)ExceptionCategory.Confusion ||
x.Category.Value == (int)ExceptionCategory.Superseded));
(x.Category == (int)ExceptionCategory.NBO ||
x.Category == (int)ExceptionCategory.Confusion ||
x.Category == (int)ExceptionCategory.Superseded));

if (exceptions == null || !exceptions.Any())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ namespace NHS.CohortManager.ScreeningDataServices;
using Model;
using Model.DTO;
using Model.Enums;
using Model.Pagination;

/// <summary>
/// Azure Function for retrieving and managing validation exceptions.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -859,6 +859,9 @@ public async Task GetValidationExceptionsByType_ExceptionIdInvalidFormat_Returns
[DataRow("12345678901", DisplayName = "Too long (11 digits)")]
[DataRow("943476591A", DisplayName = "Contains letter")]
[DataRow("94347659!9", DisplayName = "Contains special character")]
[DataRow("9434765`19", DisplayName = "Contains backtick")]
[DataRow("9434765'19", DisplayName = "Contains apostrophe")]
[DataRow("`", DisplayName = "Just a backtick")]
public async Task GetValidationExceptionsByType_NhsNumberInvalidFormat_ReturnsBadRequest(string invalidNhsNumber)
{
// Arrange
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -717,4 +717,41 @@ public async Task GetExceptionsByNhsNumber_NhsNumberHasExceptionAndReport_Return
result.Reports.Should().Contain(report => report.Category == (int)ExceptionCategory.Confusion);
result.SearchValue.Should().Be(nhsNumber);
}

[TestMethod]
public async Task GetExceptionsByNhsNumber_NullCategory_FiltersOutNullCategories()
{
// Arrange
var nhsNumber = "8888888888";
var testExceptions = new List<ExceptionManagement>
{
new() { ExceptionId = 10, NhsNumber = nhsNumber, Category = null, DateCreated = DateTime.UtcNow },
new() { ExceptionId = 11, NhsNumber = nhsNumber, Category = (int)ExceptionCategory.NBO, DateCreated = DateTime.UtcNow }
};
_validationExceptionDataServiceClient.Setup(x => x.GetByFilter(It.IsAny<Expression<Func<ExceptionManagement, bool>>>())).ReturnsAsync(testExceptions);

// Act
var result = await validationExceptionData.GetExceptionsByNhsNumber(nhsNumber);

// Assert
result.Exceptions.Should().HaveCount(1);
result.Exceptions.Should().OnlyContain(e => e.Category == (int)ExceptionCategory.NBO);
result.SearchValue.Should().Be(nhsNumber);
}

[TestMethod]
public async Task GetExceptionsByNhsNumber_WithSpecialCharactersInNhsNumber_HandlesCorrectly()
{
// Arrange
var nhsNumber = "9999999999";
var testExceptions = _exceptionList.Where(e => e.NhsNumber == nhsNumber).ToList();
_validationExceptionDataServiceClient.Setup(x => x.GetByFilter(It.IsAny<Expression<Func<ExceptionManagement, bool>>>())).ReturnsAsync(testExceptions);

// Act
var result = await validationExceptionData.GetExceptionsByNhsNumber(nhsNumber);

// Assert
result.Should().NotBeNull();
result.SearchValue.Should().Be(nhsNumber);
}
}
Loading