public async Task Remove_ShouldReturnNotFoundIfQuestionNotExists() { var questionRepository = new QuestionRepositoryBuilder().Build(); var questionController = new QuestionsControllerBuilder().WithRepository(questionRepository) .Build(); var notFoundResult = await questionController.Remove(1); Assert.IsInstanceOfType(notFoundResult, typeof(NotFoundResult)); }
public async Task Remove_ShouldRemoveQuestion() { var questionRepository = new QuestionRepositoryBuilder().Build(); var questionController = new QuestionsControllerBuilder().WithRepository(questionRepository) .Build(); var savedQuestion = (await questionController.Add(_questionModel)).Cast <CreatedAtRouteResult, Question>(); var allQuestions = (await questionController.Get()).Cast <OkObjectResult, List <QuestionModel> >(); Assert.AreEqual(1, allQuestions.Count); var okResult = await questionController.Remove(savedQuestion.Id); allQuestions = (await questionController.Get()).Cast <OkObjectResult, List <QuestionModel> >(); Assert.IsInstanceOfType(okResult, typeof(OkResult)); Assert.AreEqual(0, allQuestions.Count); }