示例#1
0
        public void NotSaveTheNewStudentIfInvalidStudent()
        {
            var mockStudentView      = MockRepository.GenerateMock <IStudentView>();
            var mockStudentRepsitory = MockRepository.GenerateMock <IStudentRepository>();
            var sut = new StudentRegistrationPresenter(mockStudentView, mockStudentRepsitory);

            sut.RegisterNewStudent(null);

            mockStudentRepsitory.AssertWasNotCalled(sr => sr.Save(null));
        }
示例#2
0
        public void SetWasStudentSavedToFalseIfInvalidStudent()
        {
            var mockStudentView      = MockRepository.GenerateMock <IStudentView>();
            var mockStudentRepsitory = MockRepository.GenerateMock <IStudentRepository>();
            var sut = new StudentRegistrationPresenter(mockStudentView, mockStudentRepsitory);

            sut.RegisterNewStudent(null);

            mockStudentView.AssertWasCalled(sv => sv.WasStudentSaved = false);
        }
示例#3
0
        public void SetWasStudentSavedToTrueIfValidStudentAndShouldSaveTrueOnView()
        {
            var mockStudentView = MockRepository.GenerateMock <IStudentView>();

            // Remember that the property `ShouldSaveStudent` on the `mockStudentView` returns the default value for
            // the return type if I do not explicitly set the return value.
            mockStudentView.Stub(sv => sv.ShouldSaveStudent).Return(true);
            var mockStudentRepsitory = MockRepository.GenerateMock <IStudentRepository>();
            var sut = new StudentRegistrationPresenter(mockStudentView, mockStudentRepsitory);

            var newStudent = new Student();

            sut.RegisterNewStudent(newStudent);

            mockStudentView.AssertWasCalled(sv => sv.WasStudentSaved = true);
        }