private static DemographicController GetDemographicControllerObject() { IUnitOfWork unitofWork; if(ConfigurationManager.AppSettings["UseDatabase"].ToUpper().ToString()=="TRUE") unitofWork = new UnitOfWork(); else unitofWork = new UnitOfWorkFake(); DemographicService demoService = new DemographicService(unitofWork); StateService stateService = new StateService(unitofWork); DemographicController demoController = new DemographicController(demoService, stateService, unitofWork); return demoController; }
public void test_get_by_id() { //Arrange Mock<IUnitOfWork> mockUOW = new Mock<IUnitOfWork>(); DemographicService DemographicService = new DemographicService(mockUOW.Object); mockUOW.Setup(m => m.MemberRepository.GetByID(It.IsAny<int>())).Returns(new Demographic()); //Act DemographicService.GetByID(3); //Assert mockUOW.VerifyAll(); }
public void test_get_all() { //Arrange Mock<IUnitOfWork> mockUOW = new Mock<IUnitOfWork>(); DemographicService DemographicService = new DemographicService(mockUOW.Object); mockUOW.Setup(s => s.MemberRepository.GetAll()).Returns(new List<Demographic> { new Demographic()}); //Act List<Demographic> list= DemographicService.GetAll(); //Arrange Assert.AreEqual(1, list.Count()); }
public DemographicController(DemographicService demographicService, StateService stateService, IUnitOfWork unitOfWork) { _unitOfWork = unitOfWork; _demographicService = demographicService; _stateService = stateService; }