Example #1
0
        public void ShouldCheckTypeOfInstanceResultAfterEditFromVisitsController_WithMock()
        {
            var visits   = new Mock <IVisitRepository>();
            var doctors  = new Mock <IDoctorRepository>();
            var patients = new Mock <IPatientRepository>();

            _visitsController = new VisitsController(visits.Object, doctors.Object, patients.Object);

            var expectedType = typeof(ActionResult);
            var value        = _visitsController.Edit(new Visit());

            Assert.IsInstanceOfType(value, expectedType);
        }
Example #2
0
        public void ShouldCheckInstanceTypeFromVisitsControllerEdit_WithMock()
        {
            var visits   = new Mock <IVisitRepository>();
            var doctors  = new Mock <IDoctorRepository>();
            var patients = new Mock <IPatientRepository>();

            visits.Setup(x => x.GetVisitById(1)).Returns(new Visit());
            _visitsController = new VisitsController(visits.Object, doctors.Object, patients.Object);

            var expected = new Visit();
            var result   = _visitsController.Edit(1);
            var actual   = ((ViewResult)result).Model as Visit;

            ReferenceEquals(actual, expected);
        }
            public void CallUpdateOnce_WhenPostedValidViewModel()
            {
                // Arrange
                var visitsServiceMock         = new Mock <IVisitsService>();
                var municipalitiesServiceMock = new Mock <IMunicipalitiesService>();
                var usersServiceMock          = new Mock <IUserService>();
                var pageServiceMock           = new Mock <IPageService <Visit> >();

                var controller = new VisitsController(visitsServiceMock.Object, municipalitiesServiceMock.Object, usersServiceMock.Object, pageServiceMock.Object);

                var visitModel        = new Visit();
                var visitDetailsModel = new VisitDetailsViewModel();

                visitsServiceMock.Setup(vs => vs.Update(visitModel));
                visitsServiceMock.Setup(vs => vs.GetById(It.IsAny <Guid>())).Returns(visitModel);

                // Act
                controller.Edit(visitDetailsModel);

                // Assert
                visitsServiceMock.Verify(vs => vs.Update(visitModel), Times.Once());
            }