Beispiel #1
0
        public void AddHospitalHttpGetShouldReturnViewModelTest()
        {
            var mockHospitalsService   = new Mock <IHospitalsService>();
            var mockUserManagerService = this.GetUserManagerMock();
            var mockRecipientsService  = new Mock <IRecipientsService>();
            var mockBloodbanksService  = new Mock <IBloodBanksService>();
            var mockUsersService       = new Mock <IUsersService>();

            mockUsersService.Setup(x => x.GetUserById <HospitalProfileInputModel>("123"))
            .Returns(new HospitalProfileInputModel()
            {
                Id   = "123",
                Name = "Hospital1",
            });

            var controller = new HospitalsController(
                mockHospitalsService.Object,
                mockUserManagerService.Object,
                mockRecipientsService.Object,
                mockBloodbanksService.Object,
                mockUsersService.Object);

            var result = controller.AddHospital();

            Assert.IsType <ViewResult>(result);
        }
Beispiel #2
0
        public async Task GetHospitalsTest()
        {
            var listOfHospitals = new TheGuardian.Core.Models.Hospital();

            listOfHospitals = new TheGuardian.Core.Models.Hospital
            {
                Id      = 1,
                Name    = "TestName",
                Address = "TestAddress",
                City    = "City",
                State   = "State",
                Zip     = 11010,
                Phone   = "5164911125",
                Website = "TestHospital.com",
                AggClericalStaffRating = 5,
                AggFacilityRating      = 5,
                AggMedicalStaffRating  = 5,
                AggOverallRating       = 5,
            };

            var a = Mapper.MapHospital(listOfHospitals);
            Mock <IGuardianRepository> mockIGuardianRepository = new Mock <IGuardianRepository>();

            mockIGuardianRepository.Setup(x => x.GetHospitalsAsync()).Verifiable();
            var hospitalsController = new HospitalsController(mockIGuardianRepository.Object);
            var allHospitals        = await hospitalsController.GetHospitals();

            allHospitals.Should().NotBeNull();
        }
Beispiel #3
0
        public void AllHospitalsHttpShoulReturnNotNullTest()
        {
            var mockUsersService     = new Mock <IUsersService>();
            var mockHospitalsService = new Mock <IHospitalsService>();

            mockHospitalsService
            .Setup(x => x.GetAllHospitals <HospitalInfoViewModel>(0, 0))
            .Returns(new List <HospitalInfoViewModel>()
            {
                new HospitalInfoViewModel
                {
                    Id   = "123",
                    Name = "Hospital1",
                },
            });
            var mockUserManagerService = this.GetUserManagerMock();
            var mockRecipientsService  = new Mock <IRecipientsService>();
            var mockBloodbanksService  = new Mock <IBloodBanksService>();

            var controller = new HospitalsController(
                mockHospitalsService.Object,
                mockUserManagerService.Object,
                mockRecipientsService.Object,
                mockBloodbanksService.Object,
                mockUsersService.Object);

            Assert.NotNull(mockHospitalsService.Object);
        }
Beispiel #4
0
        public void AllHospitalsHttpShouldBeEmptyTest()
        {
            var mockHospitalsService   = new Mock <IHospitalsService>();
            var mockUserManagerService = this.GetUserManagerMock();
            var mockRecipientsService  = new Mock <IRecipientsService>();
            var mockBloodbanksService  = new Mock <IBloodBanksService>();
            var mockUsersService       = new Mock <IUsersService>();
            var viewModel = new AllHospitalsViewModel();

            var controller = new HospitalsController(
                mockHospitalsService.Object,
                mockUserManagerService.Object,
                mockRecipientsService.Object,
                mockBloodbanksService.Object,
                mockUsersService.Object);

            var result = controller.AllHospitals(viewModel);

            Assert.IsType <ViewResult>(result);

            var viewResult = result as ViewResult;

            Assert.IsType <AllHospitalsViewModel>(viewResult.Model);

            viewModel = viewResult.Model as AllHospitalsViewModel;
            var actualResult = viewModel.Hospitals.Count();

            Assert.Equal(0, actualResult);
        }
Beispiel #5
0
        public void WhenIViewTheHospitalList()
        {
            var ratingsProcessingService = new RatingsProcessingService();
            var ratingsRepository        = new RatingsRepository();
            var surveyService            = new SurveyService(ratingsRepository, ratingsProcessingService);
            var controller = new HospitalsController(surveyService);

            _actionResult = controller.Index();
        }
Beispiel #6
0
        public void AddHospitalHttpPostInvalidInputShouldThrowAnyExceptionTest()
        {
            var mockHospitalsService   = new Mock <IHospitalsService>();
            var mockUserManagerService = this.GetUserManagerMock();
            var mockRecipientsService  = new Mock <IRecipientsService>();
            var mockBloodbanksService  = new Mock <IBloodBanksService>();
            var mockUsersService       = new Mock <IUsersService>();
            var input = new HospitalProfileInputModel();

            var controller = new HospitalsController(
                mockHospitalsService.Object,
                mockUserManagerService.Object,
                mockRecipientsService.Object,
                mockBloodbanksService.Object,
                mockUsersService.Object);

            Assert.ThrowsAnyAsync <Exception>(() => controller.AddHospital(input));
        }
Beispiel #7
0
        public void AddHospitalHttpGetShouldReturnNotFoundResultInCaseOfEmptyViewModelTest()
        {
            var mockHospitalsService   = new Mock <IHospitalsService>();
            var mockUserManagerService = this.GetUserManagerMock();
            var mockRecipientsService  = new Mock <IRecipientsService>();
            var mockBloodbanksService  = new Mock <IBloodBanksService>();
            var mockUsersService       = new Mock <IUsersService>();

            var controller = new HospitalsController(
                mockHospitalsService.Object,
                mockUserManagerService.Object,
                mockRecipientsService.Object,
                mockBloodbanksService.Object,
                mockUsersService.Object);

            var result = controller.AddHospital();

            Assert.IsType <ViewResult>(result);
        }
Beispiel #8
0
        public void DetailsHospitalShouldReturnCorrectViewModelTest()
        {
            var mockHospitalsService   = new Mock <IHospitalsService>();
            var mockUserManagerService = this.GetUserManagerMock();
            var mockRecipientsService  = new Mock <IRecipientsService>();
            var mockBloodbanksService  = new Mock <IBloodBanksService>();
            var mockUsersService       = new Mock <IUsersService>();
            var viewModel = new AllHospitalBloodBagsViewModel();

            var controller = new HospitalsController(
                mockHospitalsService.Object,
                mockUserManagerService.Object,
                mockRecipientsService.Object,
                mockBloodbanksService.Object,
                mockUsersService.Object);

            var result = controller.DetailsHospital("123", viewModel);

            Assert.IsType <RedirectToActionResult>(result);
        }
Beispiel #9
0
        public void AllHospitalsShouldReturnCorrectViewModelTest()
        {
            var mockHospitalsService   = new Mock <IHospitalsService>();
            var mockUserManagerService = this.GetUserManagerMock();
            var mockRecipientsService  = new Mock <IRecipientsService>();
            var mockBloodbanksService  = new Mock <IBloodBanksService>();
            var mockUsersService       = new Mock <IUsersService>();
            var viewModel = new AllHospitalsViewModel();

            var controller = new HospitalsController(
                mockHospitalsService.Object,
                mockUserManagerService.Object,
                mockRecipientsService.Object,
                mockBloodbanksService.Object,
                mockUsersService.Object);

            var result = controller.AllHospitals(viewModel);

            Assert.IsType <ViewResult>(result);
        }
Beispiel #10
0
        public void AddHospitalHttpPostValidInputShouldRedirectResultTest()
        {
            var mockHospitalsService   = new Mock <IHospitalsService>();
            var mockUserManagerService = this.GetUserManagerMock();
            var mockRecipientsService  = new Mock <IRecipientsService>();
            var mockBloodbanksService  = new Mock <IBloodBanksService>();
            var mockUsersService       = new Mock <IUsersService>();

            var controller = new HospitalsController(
                mockHospitalsService.Object,
                mockUserManagerService.Object,
                mockRecipientsService.Object,
                mockBloodbanksService.Object,
                mockUsersService.Object);

            var input = this.SeedData();

            var result = controller.AddHospital(input);

            Assert.IsType <RedirectToActionResult>(result.Result);
        }
        public void TestInitialize()

        {
            mock      = new Mock <IHospitalRepository>();
            hospitals = new List <Hospital>

            {
                new Hospital {
                    HospitalId = 1, HospitalName = "RVH", HospitalAddress = "1georgian dr", PhoneNumber = 9895921
                },
                new Hospital {
                    HospitalId = 2, HospitalName = "RVH2", HospitalAddress = "2georgian dr", PhoneNumber = 9895921
                },
                new Hospital {
                    HospitalId = 3, HospitalName = "RVH3", HospitalAddress = "3georgian dr", PhoneNumber = 9895921
                }
            };


            mock.Setup(m => m.Hospitals).Returns(hospitals.AsQueryable());

            controller = new HospitalsController(mock.Object);
        }
Beispiel #12
0
        public void AddHospitalHttpPostValidInputShouldRedirectToCorrectActionAndCotrollerTest()
        {
            var mockHospitalsService   = new Mock <IHospitalsService>();
            var mockUserManagerService = this.GetUserManagerMock();
            var mockRecipientsService  = new Mock <IRecipientsService>();
            var mockBloodbanksService  = new Mock <IBloodBanksService>();
            var mockUsersService       = new Mock <IUsersService>();

            var controller = new HospitalsController(
                mockHospitalsService.Object,
                mockUserManagerService.Object,
                mockRecipientsService.Object,
                mockBloodbanksService.Object,
                mockUsersService.Object);

            var input = this.SeedData();

            var result = controller.AddHospital(input).Result;

            var redirect = result as RedirectToActionResult;

            Assert.Equal($"AllHospRecip", redirect.ActionName);
            Assert.Equal($"Recipients", redirect.ControllerName);
        }
Beispiel #13
0
 public HospitalTest()
 {
     mockIGuardianRepository = new Mock <IGuardianRepository>();
     hospitalsController     = new HospitalsController(mockIGuardianRepository.Object);
 }
 public void SetUp()
 {
     base.TestSetUp();
     Target = new HospitalsController(GeoDataProvider.Object, AppLogger.Object, ResultsMapper.Object);
 }
Beispiel #15
0
 public HospitalsControllerTests()
 {
     controller = new HospitalsController(repository.Object, emailRepository.Object,
                                          phoneRepository.Object);
 }