public void AssertTest()
 {
     viewModel.Initialize(towns);
     Assert.IsNotNull(viewModel.CityList);
     Assert.IsNotNull(viewModel.DistrictList);
     Assert.IsNotNull(viewModel.TownList);
     Assert.AreEqual(viewModel.CityList.Count, service.QueryCount());
     Assert.AreEqual(viewModel.DistrictList.Count, 0);
     Assert.AreEqual(viewModel.TownList.Count, 0);
 }
        public void AssertTest(ITownRepository repository, ITown town)
        {
            viewModel.InitializeTownList(repository, town);
            Assert.IsNotNull(viewModel.CityList);
            Assert.IsNotNull(viewModel.DistrictList);
            Assert.IsNotNull(viewModel.TownList);

            if (town == null)
            {
                Assert.IsNull(viewModel.CityName);
                Assert.IsNull(viewModel.DistrictName);
                Assert.IsNull(viewModel.TownName);
                Assert.AreEqual(viewModel.CityList.Count, service.QueryCount());
                Assert.AreEqual(viewModel.DistrictList.Count, 0);
                Assert.AreEqual(viewModel.TownList.Count, 0);
            }
            else
            {
                Assert.IsNotNull(viewModel.CityList);
                Assert.IsNotNull(viewModel.DistrictList);
                Assert.IsNotNull(viewModel.TownList);
                Assert.AreEqual(viewModel.CityName, town.CityName);
                Assert.AreEqual(viewModel.DistrictName, town.DistrictName);
                Assert.AreEqual(viewModel.TownName, town.TownName);
                viewModel.AssertRegionList(towns, town);
            }
        }
        public void AssertTest(int cityId    = 0, int districtId    = 0, int townId    = 0,
                               int newCityId = 0, int newDistrictId = 0, int newTownId = 0)
        {
            ViewResult      result    = controller.Region();
            RegionViewModel viewModel = result.Model as RegionViewModel;

            Assert.IsNotNull(viewModel);
            Assert.AreEqual(viewModel.CityName, townRepository.GetAll().First().CityName);
            Assert.AreEqual(viewModel.DistrictName, townRepository.GetAll().First().DistrictName);
            Assert.AreEqual(viewModel.TownName, townRepository.GetAll().First().TownName);

            UpdateServices(viewModel);
            Assert.AreEqual(viewModel.CityList.Count, cityService.QueryCount());
            Assert.AreEqual(viewModel.DistrictList.Count, districtService.QueryCount());
            Assert.AreEqual(viewModel.TownList.Count, townService.QueryCount());

            Town addConditions
                = SetAddConditions(cityId, districtId, townId, newCityId, newDistrictId, newTownId, viewModel);

            controller.AddTown(viewModel);

            if (addConditions.IsAddConditionsValid())
            {
                Assert.IsNull(controller.TempData["error"]);
                Assert.AreEqual(controller.TempData["success"].ToString(),
                                "增加镇街:" + addConditions.GetAddConditionsInfo() + "成功");
                result    = controller.Region();
                viewModel = result.Model as RegionViewModel;
                Assert.IsNotNull(viewModel);
                Assert.IsNotNull(viewModel.CityList);
                Assert.IsNotNull(viewModel.DistrictList);
                Assert.IsNotNull(viewModel.TownList);
                Assert.AreEqual(viewModel.CityName, addConditions.CityName);
                Assert.AreEqual(viewModel.DistrictName, addConditions.DistrictName);
                Assert.AreEqual(viewModel.TownName, addConditions.TownName);

                UpdateServices(viewModel);
                Assert.AreEqual(viewModel.CityList.Count, cityService.QueryCount());
                Assert.AreEqual(viewModel.DistrictList.Count, districtService.QueryCount());
                Assert.AreEqual(viewModel.TownList.Count, townService.QueryCount());
            }
            else
            {
                Assert.AreEqual(controller.TempData["error"].ToString(),
                                "输入有误!城市、区域、镇区都不能为空。");
            }
        }
Esempio n. 4
0
        public void AssertTest(string cityName = "", string districtName = "", string townName = "")
        {
            ViewResult      result    = controller.Region();
            RegionViewModel viewModel = result.Model as RegionViewModel;

            Assert.IsNotNull(viewModel);
            if (!string.IsNullOrEmpty(cityName))
            {
                viewModel.CityName = cityName;
            }
            if (!string.IsNullOrEmpty(districtName))
            {
                viewModel.DistrictName = districtName;
            }
            if (!string.IsNullOrEmpty(townName))
            {
                viewModel.TownName = townName;
            }
            controller.DeleteTown(viewModel);
            if (controller.TempData["error"] == null)
            {
                Assert.AreEqual(controller.TempData["success"].ToString(), viewModel.DeleteSuccessMessage);
                result    = controller.Region();
                viewModel = result.Model as RegionViewModel;
                Assert.IsNotNull(viewModel);
                Assert.IsNotNull(viewModel.CityList);
                Assert.IsNotNull(viewModel.DistrictList);
                Assert.IsNotNull(viewModel.TownList);
                Town town = townRepository.GetAll().First();
                Assert.AreEqual(viewModel.CityName, town.CityName);
                Assert.AreEqual(viewModel.DistrictName, town.DistrictName);
                Assert.AreEqual(viewModel.TownName, town.TownName);
                Assert.AreEqual(viewModel.CityList.Count, service.QueryCount());
                service = new QueryDistinctDistrictNamesService(townRepository.GetAll(), viewModel.CityName);
                Assert.AreEqual(viewModel.DistrictList.Count, service.QueryCount());
                service = new QueryDistinctTownNamesService(townRepository.GetAll(), viewModel.CityName,
                                                            viewModel.DistrictName);
                Assert.AreEqual(viewModel.TownList.Count, service.QueryCount());
            }
        }
Esempio n. 5
0
 public int ConstructTestRegions()
 {
     service = new QueryOptimizeRegionNamesService(repository.GetAll());
     return(service.QueryCount());
 }
Esempio n. 6
0
 public int ConstructTestCities()
 {
     service = new QueryRegionCityNamesService(repository.GetAll());
     return(service.QueryCount());
 }
Esempio n. 7
0
 public int ConstructRegions(int cityId, int districtId)
 {
     service = new ByCityDistrictQueryRegionCityNamesService(
         repository.GetAll(), "C-" + cityId, "D-" + districtId);
     return(service.QueryCount());
 }
 public int ConstructTestId()
 {
     service = new QueryDistinctCityNamesService(repository.GetAll());
     return(service.QueryCount());
 }
 public int ConstructTestId(int cityId)
 {
     service = new QueryDistinctDistrictNamesService(repository.GetAll(), "C-" + cityId);
     return(service.QueryCount());
 }