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); }
public async Task Get_ShouldReturnAllQuestions() { var questionRepository = new QuestionRepositoryBuilder().Build(); var questionController = new QuestionsControllerBuilder().WithRepository(questionRepository) .Build(); await questionController.Add(_questionModel); await questionController.Add(_questionModel2); var okResult = await questionController.Get(); var questions = okResult.Cast <OkObjectResult, List <QuestionModel> >(); Assert.IsInstanceOfType(okResult, typeof(OkObjectResult)); Assert.AreEqual(2, questions.Count); }