public async Task Download_ShouldRedirectToCourseIndex_GivenUserIsNotTrainerOrEnrolledStudent() { // Arrange var userManager = UserManagerMock.GetMock; userManager.GetUserId(TestUserId); var examService = ExamServiceMock.GetMock; examService.CanBeDownloadedByUser(false); var controller = new ExamsController( userManager.Object, cloudinaryService: null, courseService: null, examService.Object) { TempData = TempDataMock.GetMock }; using (controller) { // Act var result = await controller.Download(TestExamId); // Assert controller.TempData.AssertErrorMsg(WebConstants.ExamDownloadUnauthorizedMsg); this.AssertRedirectToCoursesIndex(result); userManager.Verify(); examService.Verify(); } }
public async Task GetEnrolledExamsForUserAsync_ValidRequest_ReturnsOkObjectResult() { var user = new ClaimsPrincipal(new ClaimsIdentity(new Claim[] { new Claim(ClaimTypes.NameIdentifier, "1"), })); var mapperMock = new Mock <IMapper>(); var repositoryMock = new Mock <IRepositoryWrapper>(); repositoryMock.Setup(r => r.UserExamRepository.GetEnrolledExamsForUserAsync(It.IsAny <int>())).ReturnsAsync(new List <Exam>()); mapperMock.Setup(m => m.Map <IEnumerable <ExamForListDto> >(It.IsAny <IEnumerable <Exam> >())).Returns(new List <ExamForListDto>()); var controllerMock = new ExamsController(repositoryMock.Object, mapperMock.Object); controllerMock.ControllerContext = new ControllerContext() { HttpContext = new DefaultHttpContext() { User = user } }; var result = await controllerMock.GetEnrolledExamsForUserAsync(); Assert.IsType <OkObjectResult>(result); }
public async Task Download_ShouldRedirectToUrl_GivenValidInput() { // Arrange var userManager = UserManagerMock.GetMock; userManager.GetUserId(TestUserId); var examService = ExamServiceMock.GetMock; examService .CanBeDownloadedByUser(true) .GetDownloadUrlAsync(FileUrl); var controller = new ExamsController( userManager.Object, cloudinaryService: null, courseService: null, examService.Object); using (controller) { // Act var result = await controller.Download(TestExamId); // Assert var redirectResult = Assert.IsType <RedirectResult>(result); Assert.Equal(FileUrl, redirectResult.Url); userManager.Verify(); examService.Verify(); } }
public void Exams_Controller_Test_On_EditModel_With_Invalid_Id() { //Arrange Guid id = new Guid("f616cc8c-2223-4145-b7d0-232a1f6f0795"); string title = "TestT"; string observations = "TestF"; DateTime dateStart = DateTime.Now; DateTime dateEnd = DateTime.Now.AddDays(1); Exam expectedExams = new Exam(title, observations, dateStart, dateEnd); expectedExams.Id = id; Guid faultId = new Guid("1e4966f0-68f7-4f24-9f4f-53d528787be5"); ExamModel expectedModel = new ExamModel(); expectedModel.Title = " "; var repo = Substitute.For <IRepository>(); var sut = new ExamsController(repo); repo.Update(expectedExams); //Act var actual = sut.Edit(faultId, expectedExams).Result; //Assert Assert.IsInstanceOfType(actual, typeof(NotFoundResult)); }
public async Task Download_ShouldRedirectToCourseIndex_GivenInvalidUser() { // Arrange var userManager = UserManagerMock.GetMock; userManager.GetUserId(null); var controller = new ExamsController( userManager.Object, cloudinaryService: null, courseService: null, examService: null) { TempData = TempDataMock.GetMock }; using (controller) { // Act var result = await controller.Download(TestExamId); // Assert controller.TempData.AssertErrorMsg(WebConstants.InvalidUserMsg); this.AssertRedirectToCoursesIndex(result); userManager.Verify(); } }
public void Exams_Controller_Test_On_Details_With_Existent_Id() { //Arrange Guid id = new Guid("f616cc8c-2223-4145-b7d0-232a1f6f0795"); string title = "TestT"; string observations = "TestF"; DateTime dateStart = DateTime.Now; DateTime dateEnd = DateTime.Now.AddDays(1); Exam expectedExams = new Exam(title, observations, dateStart, dateEnd); expectedExams.Id = id; var repo = Substitute.For <IRepository>(); var sut = new ExamsController(repo); repo.GetById <Exam>(id).Returns(expectedExams); //Act var actual = sut.Details(id).Result as ViewResult; //Assert Assert.IsInstanceOfType(actual, typeof(ViewResult)); var viewResult = actual; Assert.AreEqual(expectedExams, viewResult.Model); }
public async Task Redirect_To_Index_After_Successful_Creation() { // Arrange var fixture = new Fixture(); fixture.Behaviors.OfType <ThrowingRecursionBehavior>().ToList() .ForEach(b => fixture.Behaviors.Remove(b)); fixture.Behaviors.Add(new OmitOnRecursionBehavior()); var context = GetFakeContext(); var examDbSetMock = new Mock <DbSet <Exam> >(); var examQuestionDbSetMock = new Mock <DbSet <ExamQuestion> >(); context.Questions.AddRange(fixture.CreateMany <Question>(7).ToList()); context.Exams = examDbSetMock.Object; context.ExamQuestions = examQuestionDbSetMock.Object; context.SaveChanges(); var controller = new ExamsController(context, GetUserManagerMock().Object); var viewModel = fixture.Create <ExamCreationViewModel>(); viewModel.QuestionAmount = 3; // Act var result = await controller.Create(viewModel); // Assert examDbSetMock.Verify(dbSet => dbSet.AddAsync(It.IsNotNull <Exam>(), default), Times.Once); examQuestionDbSetMock.Verify(dbSet => dbSet.AddRangeAsync(It.IsNotNull <ICollection <ExamQuestion> >(), default), Times.Once); Assert.NotNull(result); Assert.IsAssignableFrom <RedirectToActionResult>(result); Assert.Equal("Exams", ((RedirectToActionResult)result).ControllerName); Assert.Equal("Index", ((RedirectToActionResult)result).ActionName); }
public void Exams_Controller_Test_On_CreateModel_With_Valid_Model() { //Arrange Guid id = new Guid("f616cc8c-2223-4145-b7d0-232a1f6f0795"); string title = "TestT"; string observations = "TestF"; DateTime dateStart = DateTime.Now; DateTime dateEnd = DateTime.Now.AddDays(1); Exam expectedExams = new Exam(title, observations, dateStart, dateEnd); expectedExams.Id = id; ExamModel expectedModel = new ExamModel(); var repo = Substitute.For <IRepository>(); var sut = new ExamsController(repo); repo.Create(expectedExams); //Act var actual = sut.Create(expectedModel).Result; //Assert Assert.IsInstanceOfType(actual, typeof(RedirectToActionResult)); }
public async Task GetExam_ValidExamIdPassed_ReturnsOkObjectResult() { var user = new ClaimsPrincipal(new ClaimsIdentity(new Claim[] { new Claim(ClaimTypes.NameIdentifier, "1"), })); var mapperMock = new Mock <IMapper>(); var repositoryMock = new Mock <IRepositoryWrapper>(); repositoryMock.Setup(r => r.ExamRepository.GetExamAsync(It.IsAny <int>())).ReturnsAsync(new Exam()); var controllerMock = new ExamsController(repositoryMock.Object, mapperMock.Object); controllerMock.ControllerContext = new ControllerContext() { HttpContext = new DefaultHttpContext() { User = user } }; var result = await controllerMock.GetExamAsync(1); Assert.IsType <OkObjectResult>(result); }
public void SelectClosedQuestionsTest() { //Arrange mockMethod.mockDataIntoDB(); ExamsController ExamsController = new ExamsController(); int AmountOfSelecetedQuestions = 4; int courseID = 1; UseSqlite(); using (var context = GetDBContext()) { Course SelectedCourse = context.Course .Include(c => c.ClosedQuestionsList) .Include(q => q.OpenedQuestionsList) .Where(course => course.CourseID == courseID) .Select(seleceteCourse => seleceteCourse).Single(); //Act var CQuestions = SelectedCourse.ClosedQuestionsList.DistinctBy(q => q.Question).ToList(); CQuestions = ExamsController.SelectClosedQuestions(CQuestions, AmountOfSelecetedQuestions); //Assert Assert.Equal(4, CQuestions.Count()); } }
public async Task CreateExamAsync_InvalidRequest_ReturnsBadRequestResult() { var user = new ClaimsPrincipal(new ClaimsIdentity(new Claim[] { new Claim(ClaimTypes.NameIdentifier, "1"), })); var examForCreation = new ExamForCreationDto() { Password = "******" }; var mapperMock = new Mock <IMapper>(); var repositoryMock = new Mock <IRepositoryWrapper>(); repositoryMock.Setup(r => r.SaveAllAsync()).ReturnsAsync(false); repositoryMock.Setup(r => r.ExamRepository.Add(It.IsAny <Exam>())); mapperMock.Setup(m => m.Map <Exam>(It.IsAny <ExamForCreationDto>())).Returns(new Exam()); var controllerMock = new ExamsController(repositoryMock.Object, mapperMock.Object); controllerMock.ControllerContext = new ControllerContext() { HttpContext = new DefaultHttpContext() { User = user } }; var result = await controllerMock.CreateExamAsync(examForCreation); Assert.IsType <BadRequestObjectResult>(result); }
public async Task AddUserToExamAsync_InvalidPasswordPassed_ReturnsUnauthorizedResult() { var user = new ClaimsPrincipal(new ClaimsIdentity(new Claim[] { new Claim(ClaimTypes.NameIdentifier, "1"), })); string password = "******"; var mapperMock = new Mock <IMapper>(); var repositoryMock = new Mock <IRepositoryWrapper>(); repositoryMock.Setup(r => r.ExamRepository.GetExamAsync(It.IsAny <int>())).ReturnsAsync(new Exam() { PasswordHash = new byte[5], PasswordSalt = new byte[5] }); mapperMock.Setup(m => m.Map <IEnumerable <ExamForListDto> >(It.IsAny <IEnumerable <Exam> >())).Returns(new List <ExamForListDto>()); var controllerMock = new ExamsController(repositoryMock.Object, mapperMock.Object); controllerMock.ControllerContext = new ControllerContext() { HttpContext = new DefaultHttpContext() { User = user } }; var result = await controllerMock.AddUserToExamAsync(1, 1, password); Assert.IsType <UnauthorizedResult>(result); }
public async Task DeleteExamAsync_NotAuthorizedCall_ReturnsUnauthorizedResult() { var user = new ClaimsPrincipal(new ClaimsIdentity(new Claim[] { new Claim(ClaimTypes.NameIdentifier, "1"), })); var mapperMock = new Mock <IMapper>(); var repositoryMock = new Mock <IRepositoryWrapper>(); repositoryMock.Setup(r => r.ExamRepository.GetExamAsync(It.IsAny <int>())).ReturnsAsync(new Exam() { AuthorId = 2 }); repositoryMock.Setup(r => r.ExamRepository.Delete(It.IsAny <Exam>())); repositoryMock.Setup(r => r.SaveAllAsync()).ReturnsAsync(true); var controllerMock = new ExamsController(repositoryMock.Object, mapperMock.Object); controllerMock.ControllerContext = new ControllerContext() { HttpContext = new DefaultHttpContext() { User = user } }; var result = await controllerMock.DeleteExamAsync(1); Assert.IsType <UnauthorizedResult>(result); }
public void Exams_Controller_Test_On_EditModel_With_Invalid_Model() { //Arrange Guid id = new Guid("f616cc8c-2223-4145-b7d0-232a1f6f0795"); string title = "TestT"; string observations = "TestF"; DateTime dateStart = DateTime.Now; DateTime dateEnd = DateTime.Now.AddDays(1); Exam expectedExams = new Exam(title, observations, dateStart, dateEnd); expectedExams.Id = id; ExamModel expectedModel = new ExamModel(); expectedModel.Title = " "; var repo = Substitute.For <IRepository>(); var sut = new ExamsController(repo); repo.Update(expectedExams); //Act sut.ModelState.AddModelError("FirstName", "Firstname Required"); var actual = sut.Edit(id, expectedExams).Result; //Assert Assert.IsInstanceOfType(actual, typeof(ViewResult)); }
public void Create_ReturnsAView() { var controller = new ExamsController(); var result = controller.Create() as ViewResult; Assert.IsNotNull(result); }
public ExamControllerTests() { createExamModel = new CreatingExamModel(); updateExamModel = new UpdateExamModel(); mockRepo = new Mock <IExamService>(); mockRepoGrade = new Mock <IGradeService>(); controller = new ExamsController(mockRepo.Object, mockRepoGrade.Object); }
public void CreatePost_AddsQuestionToTheRepository() { var mockQuestionsRepository = MockRepository.GenerateMock<QuestionsRepository>(); var stubQuestion = MockRepository.GenerateStub<Question>(); var controller = new ExamsController(mockQuestionsRepository, null, null); controller.Create(stubQuestion); mockQuestionsRepository.AssertWasCalled(m => m.Add(stubQuestion)); }
public async Task Return_Not_Found_On_Details_When_Id_Doesnt_Match_Any_Existing_Object() { // Arrange var controller = new ExamsController(GetFakeContext(), GetUserManagerMock().Object); // Act var result = await controller.Details(4); // Assert Assert.IsAssignableFrom <NotFoundResult>(result); }
public async Task Return_Not_Found_On_Details_With_No_Id() { // Arrange var controller = new ExamsController(GetFakeContext(), GetUserManagerMock().Object); // Act var result = await controller.Details(null); // Assert Assert.IsAssignableFrom <NotFoundResult>(result); }
public void CreatePost_ReturnsRedirectOnSuccess() { var stubQuestionsRepository = MockRepository.GenerateMock<QuestionsRepository>(); var controller = new ExamsController(stubQuestionsRepository, null, null); ActionResult result = controller.Create(null); Assert.IsInstanceOfType(result, typeof(RedirectToRouteResult)); var redirectResult = (RedirectToRouteResult)result; Assert.AreEqual("Index", redirectResult.RouteValues["action"]); }
public void Resolve_GetsQuestionById() { var mockQuestionsRepository = MockRepository.GenerateStub <QuestionsRepository>(); var stubViewQuestionMapper = MockRepository.GenerateStub <ViewQuestionMapper>(); var controller = new ExamsController(mockQuestionsRepository, null, stubViewQuestionMapper); controller.Resolve(1); mockQuestionsRepository.AssertWasCalled(m => m.GetById(1)); }
public async Task GetUserAnswersAsync_ValidExamAndUserIdPassed_ReturnsOkObjectResult() { var mapperMock = new Mock <IMapper>(); var repositoryMock = new Mock <IRepositoryWrapper>(); repositoryMock.Setup(r => r.UserAnswerRepository.GetUserAnswersAsync(It.IsAny <int>(), It.IsAny <int>())).ReturnsAsync(new List <UserAnswer>()); var controllerMock = new ExamsController(repositoryMock.Object, mapperMock.Object); var result = await controllerMock.GetUserAnswersAsync(1, 1); Assert.IsType <OkObjectResult>(result); }
public void CreatePost_AddsQuestionToTheRepository() { var mockQuestionsRepository = MockRepository.GenerateMock <QuestionsRepository>(); var stubQuestion = MockRepository.GenerateStub <Question>(); var controller = new ExamsController(mockQuestionsRepository, null, null); controller.Create(stubQuestion); mockQuestionsRepository.AssertWasCalled(m => m.Add(stubQuestion)); }
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 CreatePost_ReturnsRedirectOnSuccess() { var stubQuestionsRepository = MockRepository.GenerateMock <QuestionsRepository>(); var controller = new ExamsController(stubQuestionsRepository, null, null); ActionResult result = controller.Create(null); Assert.IsInstanceOfType(result, typeof(RedirectToRouteResult)); var redirectResult = (RedirectToRouteResult)result; Assert.AreEqual("Index", redirectResult.RouteValues["action"]); }
public void Exams_Controller_Test_On_Create() { //Arrange var repo = Substitute.For <IRepository>(); var sut = new ExamsController(repo); //Act var actual = sut.Create(); //Assert Assert.IsInstanceOfType(actual, typeof(ViewResult)); }
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 Resolve_ReturnsQuestionView() { var stubQuestionsRepository = MockRepository.GenerateStub <QuestionsRepository>(); var stubViewQuestionMapper = MockRepository.GenerateMock <ViewQuestionMapper>(); var mockViewQuestion = MockRepository.GenerateMock <ViewQuestion>(); stubViewQuestionMapper.Stub(s => s.GetViewQuestion(Arg <Question> .Is.Anything)).Return(mockViewQuestion); var controller = new ExamsController(stubQuestionsRepository, null, stubViewQuestionMapper); var result = controller.Resolve(0) as ViewResult; Assert.AreEqual(mockViewQuestion, result.ViewData.Model); }
public void Throw_ArgumentException_When_Calling_Retrieve_Questions_With_Non_Positive_Limit_Argument() { // Arrange var controller = new ExamsController(GetFakeContext(), GetUserManagerMock().Object); // Act var positiveResult = controller.RetrieveQuestions(1, 0); // Assert Assert.IsAssignableFrom <List <Question> >(positiveResult); Assert.Throws <ArgumentException>(() => controller.RetrieveQuestions(0, 0)); Assert.Throws <ArgumentException>(() => controller.RetrieveQuestions(-1, 0)); }
public void Resolve_GetsAViewModelObject() { var mockViewQuestionMapper = MockRepository.GenerateMock <ViewQuestionMapper>(); var stubQuestionsRepository = MockRepository.GenerateStub <QuestionsRepository>(); var stubQuestion = MockRepository.GenerateStub <Question>(); stubQuestionsRepository.Stub(s => s.GetById(Arg <int> .Is.Anything)).Return(stubQuestion); var controller = new ExamsController(stubQuestionsRepository, null, mockViewQuestionMapper); controller.Resolve(0); mockViewQuestionMapper.AssertWasCalled(m => m.GetViewQuestion(stubQuestion)); }
public void Exams_Controller_Test_On_Edit_With_NonExistent_Id() { //Arrange Guid id = new Guid("f616cc8c-2223-4145-b7d0-232a1f6f0795"); var repo = Substitute.For <IRepository>(); var sut = new ExamsController(repo); repo.GetById <Exam>(id); //Act var actual = sut.Edit(id).Result; //Assert Assert.IsInstanceOfType(actual, typeof(NotFoundResult)); }
public void Exams_Controller_Test_On_Delete_With_Null_Id() { //Arrange var id = Guid.Empty; var repo = Substitute.For <IRepository>(); var sut = new ExamsController(repo); repo.GetById <Exam>(id); //Act var actual = sut.Delete(id).Result; //Assert Assert.IsInstanceOfType(actual, typeof(NotFoundResult)); }
public void ExamsController_InitializesViewQuestionMapper() { var examsController = new ExamsController(); Assert.IsNotNull(examsController.GetFieldValue<ViewQuestionMapper>("_viewQuestionMapper")); }
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 ResolvePost_WhenSourceCodeCannotBeExecuted_ShowsTheErrorList() { var mockCorrectionProcess = MockRepository.GenerateStub<CorrectionProcess>(); mockCorrectionProcess.Stub(s => s.CheckAnswer(Arg<Question>.Is.Anything)).Return(new CorrectionResult { Errors = new List <string> { "Error1", "Error2" } }); var stubViewQuestionMapper = MockRepository.GenerateStub<ViewQuestionMapper>(); var controller = new ExamsController(null, mockCorrectionProcess, stubViewQuestionMapper); controller.Resolve(null); Assert.AreEqual("Error1", controller.ModelState[""].Errors[0].ErrorMessage); Assert.AreEqual("Error2", controller.ModelState[""].Errors[1].ErrorMessage); }
public void ResolvePost_WhenThereAreNoErrors_ReturnsRedirectOnSuccess() { var stubCorrectionProcess = MockRepository.GenerateStub<CorrectionProcess>(); var stubCorrectionResult = MockRepository.GenerateStub<CorrectionResult>(); stubCorrectionProcess.Stub(s => s.CheckAnswer(Arg<Question>.Is.Anything)).Return(stubCorrectionResult); var stubViewQuestionMapper = MockRepository.GenerateStub<ViewQuestionMapper>(); var controller = new ExamsController(null, stubCorrectionProcess, stubViewQuestionMapper); ActionResult result = controller.Resolve(null); Assert.IsInstanceOfType(result, typeof(RedirectToRouteResult)); var redirectResult = (RedirectToRouteResult)result; Assert.AreEqual("Result", redirectResult.RouteValues["action"]); }
public void Resolve_GetsAViewModelObject() { var mockViewQuestionMapper = MockRepository.GenerateMock<ViewQuestionMapper>(); var stubQuestionsRepository = MockRepository.GenerateStub<QuestionsRepository>(); var stubQuestion = MockRepository.GenerateStub<Question>(); stubQuestionsRepository.Stub(s => s.GetById(Arg<int>.Is.Anything)).Return(stubQuestion); var controller = new ExamsController(stubQuestionsRepository, null, mockViewQuestionMapper); controller.Resolve(0); mockViewQuestionMapper.AssertWasCalled(m=>m.GetViewQuestion(stubQuestion)); }
public void Resolve_GetsQuestionById() { var mockQuestionsRepository = MockRepository.GenerateStub<QuestionsRepository>(); var stubViewQuestionMapper = MockRepository.GenerateStub<ViewQuestionMapper>(); var controller = new ExamsController(mockQuestionsRepository, null, stubViewQuestionMapper); controller.Resolve(1); mockQuestionsRepository.AssertWasCalled(m => m.GetById(1)); }
public void Resolve_ReturnsQuestionView() { var stubQuestionsRepository = MockRepository.GenerateStub<QuestionsRepository>(); var stubViewQuestionMapper = MockRepository.GenerateMock<ViewQuestionMapper>(); var mockViewQuestion = MockRepository.GenerateMock<ViewQuestion>(); stubViewQuestionMapper.Stub(s => s.GetViewQuestion(Arg<Question>.Is.Anything)).Return(mockViewQuestion); var controller = new ExamsController(stubQuestionsRepository, null, stubViewQuestionMapper); var result = controller.Resolve(0) as ViewResult; Assert.AreEqual(mockViewQuestion, result.ViewData.Model); }
public void ExamsController_InitializesCorrectionProcess() { var examsController = new ExamsController(); Assert.IsNotNull(examsController.GetFieldValue<CorrectionProcess>("_correctionProcess")); }
public void ExamsController_InitializesQuestionsRepository() { var examsController = new ExamsController(); Assert.IsNotNull(examsController.GetFieldValue<QuestionsRepository>("_questionsRepository")); }
public void ResolvePost_GetsQuestionWithViewQuestionMapper() { var mockViewQuestionMapper = MockRepository.GenerateMock<ViewQuestionMapper>(); var stubViewQuestion = MockRepository.GenerateStub<ViewQuestion>(); var stubCorrectionProcess = MockRepository.GenerateStub<CorrectionProcess>(); stubCorrectionProcess.Stub(s => s.CheckAnswer(Arg<Question>.Is.Anything)).Return( MockRepository.GenerateStub<CorrectionResult>()); var controller = new ExamsController(null, stubCorrectionProcess, mockViewQuestionMapper); controller.Resolve(stubViewQuestion); mockViewQuestionMapper.AssertWasCalled(m=>m.GetQuestion(stubViewQuestion)); }
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)); }