コード例 #1
0
        AppointmentController CreateAppointmentController()
        {
            var testAppointments = FakeAppointmentData.CreateTestAppointments();
            var repository = new FakeAppointmentRepository(testAppointments);

            return new AppointmentController(repository);
        }
コード例 #2
0
        public void BookAppointmentCompleteAction_With_ViewModel_Should_Return_View_And_Repository_Should_Contain_New_Appointment_Added()
        {
            // Arrange
            var identityMock = new Mock<ControllerContext>();

            var eHealthIdentity = FakeIdentity.CreateIdentity("anita");
            var testData = FakeAppointmentData.CreateTestAppointments();
            var repository = new FakeAppointmentRepository(testData);
            var controller = new AppointmentController(repository);
            var testApptVM = FakeAppointmentData.CreateTestAppointmentViewModel();

            //Mocks
            controller.ControllerContext = identityMock.Object;
            identityMock.SetupGet(p => p.HttpContext.User.Identity).Returns(eHealthIdentity);
            //Mock send email function
             var  emailMock = new Mock<Email>();
             emailMock.Setup(x => x.SendEmail()).Returns(true);
             testApptVM.Email = emailMock.Object;

            //Act
            ViewResult result = (ViewResult)controller.BookAppointmentComplete(testApptVM);

            //Assert
            Assert.IsTrue(repository.GetAppointmentCount() > 5);
            Assert.IsInstanceOfType(result.ViewData.Model, typeof(AppointmentViewModel));
        }