예제 #1
0
        public void TestMethod1()
        {
            Mock<IStudentsRepository> mockRepo = new Mock<IStudentsRepository>();

            StudentsController studentsController = new StudentsController(mockRepo.Object);

            Student s = new Student
            {
                Firstname = "Daniel",
                Lastname = "Something"
            };

            studentsController.Create(s, null);

            mockRepo.Verify(a => a.InsertOrUpdate(s, null));
            mockRepo.Verify(a => a.Save());
        }
        public void TestMethodEmail()
        {
            Mock<IStudentsRepository> mockRepo =
                new Mock<IStudentsRepository>();
            Mock<IEmailer> fakeEmailer = new Mock<IEmailer>();

            StudentsController controller =
                new StudentsController(mockRepo.Object, fakeEmailer.Object);

            Student s = new Student
            {
                Firstname = "Daniel",
                Lastname = "Something"
            };

            //controller.Create(s, null);

            fakeEmailer.Verify(a=>a.Send("Welcome to our website..."));
        }
        public void TestMethod1()
        {
            //Arrange
            Mock<IStudentsRepository> mockRepo =
                new Mock<IStudentsRepository>();

            StudentsController controller =
                new StudentsController(mockRepo.Object, null);

            Student s = new Student
            {
                Firstname = "Daniel",
                Lastname = "Something"
            };

            //Act - Where you call the method to test
            //controller.Create(s, null);

            //Assert - verify that insertorupdate was called
            mockRepo.Verify(a=>a.InsertOrUpdate(s));
            mockRepo.Verify(a=>a.Save());
        }