public void Test_AnswersController_GetAnswers_ReturnsListOfAnswers() { AnswersController controller = new AnswersController(_context); var result = controller.GetAnswers(); Assert.IsNotEmpty(result.Result.Value); }
public async Task GetAnswers_WithQuestionId_ReturnsAnswerList() { //Arrange var questionId = AutoFaker.Generate <int>(); var answers = AutoFaker.Generate <List <Answer> >(); var answersDto = AutoFaker.Generate <List <AnswerDto> >(); _answerService.Setup(x => x.GetAnswers(It.IsAny <int>())) .ReturnsAsync(answers); _mapper.Setup(x => x.Map <List <AnswerDto> >(answers)) .Returns(answersDto); //Act var result = await _sut.GetAnswers(questionId); //Assert result.Should().BeOfType <OkObjectResult>(); ((OkObjectResult)result).StatusCode.Should().Be(StatusCodes.Status200OK); ((OkObjectResult)result).Value.Should().BeEquivalentTo(answersDto); }