public async Task Should_retrieve_all_allocated_users_by_allocated_by() { var response = new List <AllocationDetailsResponse>() { new AllocationDetailsResponseBuilder().AllocatedBy(AllocationData.ALLOCATED_BY).Build() }; var client = new Mock <ITestApiClient>(); client .Setup(x => x.GetAllocateUsersByAllocatedByAsync(It.IsAny <string>())) .ReturnsAsync(response); var controller = new AllocationController(client.Object, _loggerMock.Object); var result = await controller.GetAllocatedUsers(AllocationData.ALLOCATED_BY); var typedResult = (ObjectResult)result; typedResult.StatusCode.Should().Be((int)HttpStatusCode.OK); var allocationDetails = (List <AllocationDetailsResponse>)typedResult.Value; allocationDetails.Should().NotBeNull(); allocationDetails.Should().BeEquivalentTo(response); }
public async Task Should_throw_internal_server() { var client = new Mock <ITestApiClient>(); client .Setup(x => x.GetAllocateUsersByAllocatedByAsync(It.IsAny <string>())) .ThrowsAsync(ExceptionsData.INTERNAL_SERVER_EXCEPTION); var controller = new AllocationController(client.Object, _loggerMock.Object); var result = await controller.GetAllocatedUsers(string.Empty); var typedResult = (ObjectResult)result; typedResult.StatusCode.Should().Be((int)HttpStatusCode.InternalServerError); }