Exemple #1
0
        public async Task Should_throw_internal_server()
        {
            var client = new Mock <ITestApiClient>();

            client
            .Setup(x => x.AllocateSingleUserAsync(It.IsAny <AllocateUserRequest>()))
            .ThrowsAsync(ExceptionsData.INTERNAL_SERVER_EXCEPTION);

            var controller = new AllocationController(client.Object, _loggerMock.Object);
            var result     = await controller.AllocateSingleUser(_request);

            var typedResult = (ObjectResult)result;

            typedResult.StatusCode.Should().Be((int)HttpStatusCode.InternalServerError);
        }
Exemple #2
0
        public async Task Should_allocate_single_user()
        {
            var response = new UserDetailsResponseBuilder().Judge().Build();

            var client = new Mock <ITestApiClient>();

            client
            .Setup(x => x.AllocateSingleUserAsync(It.IsAny <AllocateUserRequest>()))
            .ReturnsAsync(response);

            var controller = new AllocationController(client.Object, _loggerMock.Object);

            var result = await controller.AllocateSingleUser(_request);

            var typedResult = (ObjectResult)result;

            typedResult.StatusCode.Should().Be((int)HttpStatusCode.OK);

            var userDetails = (UserDetailsResponse)typedResult.Value;

            userDetails.Should().NotBeNull();
            userDetails.Should().BeEquivalentTo(response);
        }