예제 #1
0
 public void TestInitialize()
 {
     townRepository.Setup(x => x.GetAll()).Returns(towns.AsQueryable());
     townRepository.Setup(x => x.GetAllList()).Returns(townRepository.Object.GetAll().ToList());
     townRepository.Setup(x => x.Count()).Returns(townRepository.Object.GetAll().Count());
     controller = new RegionController(townRepository.Object, null, null, null);
     helper = new RegionAndAddTownTestHelper(controller, townRepository.Object);
 }
예제 #2
0
 public void TestInitialize()
 {
     townRepository.Setup(x => x.GetAll()).Returns(towns.AsQueryable());
     townRepository.SynchronizeValues<Town, ITownRepository>();
     regionRepository.Setup(x => x.GetAll()).Returns(new List<OptimizeRegion>().AsQueryable());
     regionRepository.SynchronizeValues<OptimizeRegion, IRegionRepository>();
     regionRepository.MockRepositorySaveItems<OptimizeRegion, IRegionRepository>();
     controller = new RegionController(townRepository.Object, null, null, regionRepository.Object);
 }
 public TownRepositoryWithOptimizeRegionTestHelper(
     IEnumerable<Town> towns, IEnumerable<OptimizeRegion> regions)
 {
     this.towns = towns;
     this.regions = regions;
     townRepository.Setup(x => x.GetAll()).Returns(towns.AsQueryable());
     townRepository.Setup(x => x.GetAllList()).Returns(townRepository.Object.GetAll().ToList());
     townRepository.Setup(x => x.Count()).Returns(townRepository.Object.GetAll().Count());
     controller = new RegionController(townRepository.Object, null, null, regionRepository.Object);
 }
 public void TestInitialize()
 {
     townRepository.Setup(x => x.GetAll()).Returns(towns.AsQueryable());
     townRepository.Setup(x => x.GetAllList()).Returns(townRepository.Object.GetAll().ToList());
     townRepository.Setup(x => x.Count()).Returns(townRepository.Object.GetAll().Count());
     regionRepository.Setup(x => x.GetAll()).Returns(new List<OptimizeRegion>().AsQueryable());
     regionRepository.Setup(x => x.GetAllList()).Returns(regionRepository.Object.GetAll().ToList());
     regionRepository.Setup(x => x.Count()).Returns(regionRepository.Object.GetAll().Count());
     regionRepository.MockAddOneRegionOperation();
     controller = new RegionController(townRepository.Object, null, null, regionRepository.Object);
 }
예제 #5
0
 public void TestAddTown_EmptyInput()
 {
     controller = new RegionController(repository.Object, null, null, null);
     viewModel.CityName = "Foshan";
     viewModel.NewCityName="";
     viewModel.DistrictName = "";
     viewModel.NewDistrictName = "";
     viewModel.TownName = "";
     viewModel.NewTownName = "";
     controller.AddTown(viewModel);
     Assert.AreEqual(controller.TempData["error"], "输入有误!城市、区域、镇区都不能为空。");
 }
예제 #6
0
 public void TestAddTown_NormalInput(string cityName, string districtName, string townName)
 {
     controller = new RegionController(repository.Object, null, null, null);
     viewModel.CityName = cityName;
     viewModel.NewCityName = "";
     viewModel.DistrictName = "";
     viewModel.NewDistrictName = districtName;
     viewModel.TownName = "";
     viewModel.NewTownName = townName;
     Assert.AreEqual(repository.Object.Count(), 0);
     controller.AddTown(viewModel);
     IQueryable<Town> resultTowns = repository.Object.GetAll();
     Assert.AreEqual(resultTowns.Count(), 1);
     Assert.AreEqual(resultTowns.ElementAt(0).CityName, cityName);
     Assert.AreEqual(resultTowns.ElementAt(0).DistrictName, districtName);
     Assert.AreEqual(resultTowns.ElementAt(0).TownName, townName);
 }
 public RegionAndDeleteTownTestHelper(RegionController controller, ITownRepository townRepository)
 {
     this.controller = controller;
     this.townRepository = townRepository;
     service = new QueryDistinctCityNamesService(townRepository.GetAll());
 }
 public TownRepositoryRegionTestHelper(IEnumerable<Town> towns)
 {
     controller = new RegionController(townRepository.Object, null, null, null);
     this.towns = towns;
 }