Example #1
0
        public void ShouldCheckTypeOfInstanceAfterDeleteFromVisitsController_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 expectedType = typeof(Visit);
            var result       = _visitsController.Delete(1);
            var value        = ((ViewResult)result).Model as Visit;

            Assert.IsInstanceOfType(value, expectedType);
        }
Example #2
0
        public void ShouldCheckResultWhenDoctorIdIsWrongAfterDeleteFromVisitsController_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 expectedErrorCode = 404;
            var result            = _visitsController.Delete(10);
            var viewResult        = (HttpNotFoundResult)result;
            var actual            = viewResult.StatusCode;

            Assert.AreEqual(expectedErrorCode, actual);
        }
Example #3
0
        public async Task VisitsController_Delete_Test()
        {
            bool called             = false;
            var  visitRepository    = new Data.Repositories.Fakes.StubIVisitRepository();
            var  employeeRepository = new Data.Repositories.Fakes.StubIEmployeeRepository();

            var visit = new Visit()
            {
                VisitId = 1,
            };

            visitRepository.DeleteAsyncInt32 = (id) =>
            {
                Assert.IsTrue(id == visit.VisitId);
                called = true;
                return(Task.FromResult(string.Empty));
            };

            var target = new VisitsController(visitRepository, new SecurityHelper(), employeeRepository);
            await target.Delete(visit.VisitId);

            Assert.IsTrue(called);
        }