Skip to content

Commit 5fba84d

Browse files
neildsouthwoodheadio
authored andcommitted
adding new tests
Signed-off-by: Neil South <[email protected]>
1 parent 22cdee9 commit 5fba84d

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

src/Database/EntityFramework/Test/SourceApplicationEntityRepositoryTest.cs

+14
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,20 @@ public async Task GivenAAETitleName_WhenFindByNameAsyncIsCalled_ExpectItToReturn
108108
Assert.Null(actual);
109109
}
110110

111+
[Fact]
112+
public async Task GivenAAETitleName_WhenFindByAETAsyncIsCalled_ExpectItToReturnMatchingEntity()
113+
{
114+
var store = new SourceApplicationEntityRepository(_serviceScopeFactory.Object, _logger.Object, _options);
115+
116+
var actual = await store.FindByAETAsync("AET1").ConfigureAwait(false);
117+
Assert.NotNull(actual);
118+
Assert.Equal("AET1", actual.FirstOrDefault()!.AeTitle);
119+
Assert.Equal("AET1", actual.FirstOrDefault()!.Name);
120+
121+
actual = await store.FindByAETAsync("AET6").ConfigureAwait(false);
122+
Assert.Empty(actual);
123+
}
124+
111125
[Fact]
112126
public async Task GivenASourceApplicationEntity_WhenRemoveIsCalled_ExpectItToDeleted()
113127
{

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

+21
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,27 @@ public async Task GetAeTitle_ReturnsAMatch()
145145
_repository.Verify(p => p.FindByNameAsync(value, It.IsAny<CancellationToken>()), Times.Once());
146146
}
147147

148+
[RetryFact(5, 250, DisplayName = "GetAeTitle - Shall return matching object")]
149+
public async Task GetAeTitle_ViaAETitleReturnsAMatch()
150+
{
151+
var value = "AET";
152+
_repository.Setup(p => p.FindByAETAsync(It.IsAny<string>(), It.IsAny<CancellationToken>())).Returns(
153+
Task.FromResult(
154+
new SourceApplicationEntity[]{
155+
new SourceApplicationEntity
156+
{
157+
AeTitle = value,
158+
HostIp = "host",
159+
Name = $"{value}name",
160+
}}));
161+
162+
var result = await _controller.GetAeTitleByAET(value);
163+
var okObjectResult = result.Result as OkObjectResult;
164+
var response = okObjectResult.Value as SourceApplicationEntity[];
165+
Assert.Equal(value, response.FirstOrDefault().AeTitle);
166+
_repository.Verify(p => p.FindByAETAsync(value, It.IsAny<CancellationToken>()), Times.Once());
167+
}
168+
148169
[RetryFact(5, 250, DisplayName = "GetAeTitle - Shall return 404 if not found")]
149170
public async Task GetAeTitle_Returns404IfNotFound()
150171
{

0 commit comments

Comments
 (0)