Exemple #1
0
        public async Task ShouldReturnVersionResponseWhenGetVersionCalled()
        {
            //Given
            _swarmClient.GetVersion().Returns(Task.FromResult(_any.Create <VersionResponse>()));
            var systemService     = new SwarmApi.Services.SystemService(_swarmClient, _loggerFactory);
            var serviceController = new SystemController(systemService);

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

            var result = response as JsonResult;

            //Then
            Assert.NotNull(result);
            Assert.Equal(200, result.StatusCode);
        }
Exemple #2
0
        public async Task ShouldReturnInternalServerErrorWhenGetVersionCalledWithError()
        {
            //Given
            _swarmClient.When(x => x.GetVersion()).Do(_ => throw new ArgumentException());
            var systemService     = new SwarmApi.Services.SystemService(_swarmClient, _loggerFactory);
            var serviceController = new SystemController(systemService);

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

            var result = response as ContentResult;

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