diff --git a/src/Client/Test/AeTitleServiceTest.cs b/src/Client/Test/AeTitleServiceTest.cs index 3a1cea13e..3e9f7b89f 100644 --- a/src/Client/Test/AeTitleServiceTest.cs +++ b/src/Client/Test/AeTitleServiceTest.cs @@ -460,5 +460,64 @@ public async Task CEcho_ReturnsAProblem() Assert.Equal($"HTTP Status: {problem.Status}. {problem.Detail}", result.Message); } + + [Fact(DisplayName = "AET - Plugins")] + public async Task Plugins() + { + var plugins = new Dictionary + { + {"A","1" }, + {"B","2" }, + {"C","3" }, + }; + + var json = JsonSerializer.Serialize(plugins, Configuration.JsonSerializationOptions); + + var rootUri = new Uri("http://localhost:5000"); + var uriPath = "config/monaiaetitle/plug-ins"; + + var httpResponse = new HttpResponseMessage + { + StatusCode = HttpStatusCode.OK, + Content = new StringContent(json, Encoding.UTF8, "application/json") + }; + + var httpClient = SetupHttpClientMock(rootUri, HttpMethod.Get, httpResponse); + + var service = new AeTitleService(uriPath, httpClient, _logger.Object); + + var exception = await Record.ExceptionAsync(async () => await service.Plugins(CancellationToken.None)); + Assert.Null(exception); + } + + [Fact(DisplayName = "AET - Plugins returns a problem")] + public async Task Plugins_ReturnsAProblem() + { + var problem = new ProblemDetails + { + Title = "Problem Title", + Detail = "Problem Detail", + Status = 500 + }; + + var json = JsonSerializer.Serialize(problem, Configuration.JsonSerializationOptions); + + var rootUri = new Uri("http://localhost:5000"); + var uriPath = "config/destination"; + + var httpResponse = new HttpResponseMessage + { + StatusCode = HttpStatusCode.InternalServerError, + Content = new StringContent(json, Encoding.UTF8, "application/json") + }; + + var httpClient = SetupHttpClientMock(rootUri, HttpMethod.Get, httpResponse); + + var service = new AeTitleService(uriPath, httpClient, _logger.Object); + + var result = await Assert.ThrowsAsync(async () => await service.Plugins(CancellationToken.None)); + + Assert.Equal($"HTTP Status: {problem.Status}. {problem.Detail}", result.Message); + } } }