public async Task GetDocumentByUserId_ReturnsOkObjectResult()
        {
            //Arrange
            string userId = "gh34tg";

            _mockUserManager.Setup(x => x.GetUserAsync(It.IsAny <ClaimsPrincipal>()))
            .ReturnsAsync(new User()
            {
                Id = userId
            });
            _mockUserManager.Setup(x => x.GetRolesAsync(It.IsAny <User>())).ReturnsAsync(new List <string>()
            {
                Roles.Admin
            });
            _mockBiographyService
            .Setup(x => x.GetDocumentByUserId(userId))
            .ReturnsAsync(GetBlankBiographyDocumentDTO());

            //Act
            var document = await _blanksController.GetDocumentByUserId("1");

            OkObjectResult result = document as OkObjectResult;

            //Assert
            _mockBiographyService.Verify();
            Assert.NotNull(document);
            Assert.IsInstanceOf <ObjectResult>(document);
            Assert.AreEqual(StatusCodes.Status200OK, result.StatusCode);
        }
Exemplo n.º 2
0
        public async Task GetDocumentByUserId_ReturnsOkObjectResult()
        {
            //Arrange
            _mockBiographyService
            .Setup(x => x.GetDocumentByUserId("gh34tg"))
            .ReturnsAsync(GetBiographyDocumentsDTO());

            //Act
            var document = await _blanksController.GetDocumentByUserId("gh34tg");

            OkObjectResult result = document as OkObjectResult;

            //Assert
            _mockBiographyService.Verify();
            Assert.NotNull(document);
            Assert.IsInstanceOf <ObjectResult>(document);
            Assert.AreEqual(StatusCodes.Status200OK, result.StatusCode);
        }