Skip to content

Commit de8d857

Browse files
neildsouthwoodheadio
authored andcommitted
improving test coverage
Signed-off-by: Neil South <[email protected]>
1 parent 5fba84d commit de8d857

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

src/Database/MongoDB/Integration.Test/SourceApplicationEntityRepositoryTest.cs

+16
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,20 @@ public async Task GivenAAETitleName_WhenFindByNameAsyncIsCalled_ExpectItToReturn
113113
Assert.Null(actual);
114114
}
115115

116+
[Fact]
117+
public async Task GivenAETitle_WhenFindByAETitleAsyncIsCalled_ExpectItToReturnMatchingEntity()
118+
{
119+
var store = new SourceApplicationEntityRepository(_serviceScopeFactory.Object, _logger.Object, _options, _databaseFixture.Options);
120+
121+
var actual = await store.FindByAETAsync("AET1").ConfigureAwait(false);
122+
Assert.NotNull(actual);
123+
Assert.Equal("AET1", actual.FirstOrDefault()!.AeTitle);
124+
Assert.Equal("AET1", actual.FirstOrDefault()!.Name);
125+
126+
actual = await store.FindByAETAsync("AET6").ConfigureAwait(false);
127+
Assert.Empty(actual);
128+
}
129+
116130
[Fact]
117131
public async Task GivenASourceApplicationEntity_WhenRemoveIsCalled_ExpectItToDeleted()
118132
{
@@ -158,5 +172,7 @@ public async Task GivenASourceApplicationEntity_WhenUpdatedIsCalled_ExpectItToSa
158172
Assert.NotNull(dbResult);
159173
Assert.Equal(expected.AeTitle, dbResult!.AeTitle);
160174
}
175+
176+
161177
}
162178
}

src/InformaticsGateway/Test/Services/Http/SourceAeTitleControllerTest.cs

+18
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,24 @@ public async Task GetAeTitle_ShallReturnProblemOnFailure()
196196
_repository.Verify(p => p.FindByNameAsync(value, It.IsAny<CancellationToken>()), Times.Once());
197197
}
198198

199+
[RetryFact(5, 250, DisplayName = "GetAeTitle from AETitle - Shall return problem on failure")]
200+
public async Task GetAeTitleViaAETitle_ShallReturnProblemOnFailure()
201+
{
202+
var value = "AET";
203+
_repository.Setup(p => p.FindByAETAsync(It.IsAny<string>(), It.IsAny<CancellationToken>())).Throws(new Exception("error"));
204+
205+
var result = await _controller.GetAeTitleByAET(value);
206+
207+
var objectResult = result.Result as ObjectResult;
208+
Assert.NotNull(objectResult);
209+
var problem = objectResult.Value as ProblemDetails;
210+
Assert.NotNull(problem);
211+
Assert.Equal("Error querying DICOM sources.", problem.Title);
212+
Assert.Equal("error", problem.Detail);
213+
Assert.Equal((int)HttpStatusCode.InternalServerError, problem.Status);
214+
_repository.Verify(p => p.FindByAETAsync(value, It.IsAny<CancellationToken>()), Times.Once());
215+
}
216+
199217
#endregion GetAeTitle
200218

201219
#region Create

0 commit comments

Comments
 (0)