public void Index_GetsViewQuestionObjects() { var mockViewQuestionMapper = MockRepository.GenerateMock <ViewQuestionMapper>(); var stubQuestionsRepository = MockRepository.GenerateStub <QuestionsRepository>(); var controller = new ExamsController(stubQuestionsRepository, null, mockViewQuestionMapper); controller.Index(); mockViewQuestionMapper.AssertWasCalled(m => m.GetViewQuestionsFromList(stubQuestionsRepository)); }
public void Index_ReturnAllViewQuestions() { var mockViewQuestionMapper = MockRepository.GenerateMock <ViewQuestionMapper>(); var stubViewQuestionList = MockRepository.GenerateStub <List <ViewQuestion> >(); mockViewQuestionMapper.Stub(s => s.GetViewQuestionsFromList(Arg <IEnumerable <Question> > .Is.Anything)).Return( stubViewQuestionList); var controller = new ExamsController(null, null, mockViewQuestionMapper); var result = controller.Index() as ViewResult; Assert.AreEqual(stubViewQuestionList, result.ViewData.Model); }
// ne peut pas etre tester car on utiliser User claims dans index pour filtrer par role public async Task Return_Index_View_With_Exams_List() { // Arrange var fixture = new Fixture(); var ExamsController = new ExamsController(GetFakeContext(), GetMockedUserManager()); // Act var result = await ExamsController.Index(); // Assert Assert.NotNull(result); var viewResult = Assert.IsAssignableFrom <ViewResult>(result); var Exams = Assert.IsAssignableFrom <List <Exam> >(viewResult.Model); }
public void Exams_Controller_Test_On_Index() { //Arrange var repo = Substitute.For <IRepository>(); ICollection <Exam> expectedExams = new[] { new Exam() }; repo.GetAll <Exam>().Returns(expectedExams); var sut = new ExamsController(repo); //Act var actual = sut.Index().Result as ViewResult; //Assert Assert.IsInstanceOfType(actual, typeof(ViewResult)); var viewResult = actual; Assert.AreEqual(expectedExams, viewResult.Model); }
public void Index_ReturnAllViewQuestions() { var mockViewQuestionMapper = MockRepository.GenerateMock<ViewQuestionMapper>(); var stubViewQuestionList = MockRepository.GenerateStub<List<ViewQuestion>>(); mockViewQuestionMapper.Stub(s => s.GetViewQuestionsFromList(Arg<IEnumerable<Question>>.Is.Anything)).Return( stubViewQuestionList); var controller = new ExamsController(null, null, mockViewQuestionMapper); var result = controller.Index() as ViewResult; Assert.AreEqual(stubViewQuestionList, result.ViewData.Model); }
public void Index_GetsViewQuestionObjects() { var mockViewQuestionMapper = MockRepository.GenerateMock<ViewQuestionMapper>(); var stubQuestionsRepository = MockRepository.GenerateStub<QuestionsRepository>(); var controller = new ExamsController(stubQuestionsRepository, null, mockViewQuestionMapper); controller.Index(); mockViewQuestionMapper.AssertWasCalled(m => m.GetViewQuestionsFromList(stubQuestionsRepository)); }