Ejemplo n.º 1
0
        public async Task GetByIdOkTest()
        {
            //Arrange
            var service      = new Mock <IUserService>();
            var userResponse = UserGenerator.GetTestUserResponse();

            service.Setup(e => e.GetByIdAsync(It.IsAny <int>())).ReturnsAsync(userResponse);

            var controller = new UsersController(service.Object, _mapper);

            //Act
            var result = await controller.GetById(userResponse.User.Id);

            //Assert
            var actionResult = Assert.IsType <OkObjectResult>(result);
            var userResource = Assert.IsAssignableFrom <UserResource>(actionResult.Value);

            UserAssertHelper.AssertEquals(userResponse.User, userResource);
        }