Beispiel #1
0
        public async Task <IActionResult> GetSystemInfoAsync()
        {
            try
            {
                var response = await _swarmClient.GetSystemInfo();

                _logger.LogInformation("Fetch system info.");
                return(Json(response));
            }
            catch (Exception ex)
            {
                return(CreateErrorResponse(ex, "Cannot fetch information about system."));
            }
        }
Beispiel #2
0
        public async Task ShouldReturnSystemInfoResponseWhenGetSystemInfoCalled()
        {
            //Given
            _swarmClient.GetSystemInfo().Returns(Task.FromResult(_any.Create <SystemInfoResponse>()));
            var systemService     = new SwarmApi.Services.SystemService(_swarmClient, _loggerFactory);
            var serviceController = new SystemController(systemService);

            //When
            var response = await serviceController.GetSystemInfo();

            var result = response as JsonResult;

            //Then
            Assert.NotNull(result);
            Assert.Equal(200, result.StatusCode);
        }