public void TestSaveTown_Fail() { Assert.AreEqual(repository.Object.Count(), 1); TownOperationService service = new TownOperationService(repository.Object, "Foshan", "Chancheng", "Zhangcha"); service.SaveOneTown(); Assert.AreEqual(repository.Object.Count(), 1); }
public void TestSaveTown_Success() { Assert.AreEqual(repository.Object.Count(), 1); TownOperationService service = new TownOperationService(repository.Object, "Foshan", "Nanhai", "Guicheng"); service.SaveOneTown(); Assert.AreEqual(repository.Object.Count(), 2); }
public void TestSaveAndDeleteTown_AddFail_DeleteSuccess() { Assert.AreEqual(repository.Object.Count(), 1); TownOperationService service = new TownOperationService(repository.Object, "Foshan", "Chancheng ", "Zhangcha "); service.SaveOneTown(); Assert.AreEqual(repository.Object.Count(), 1, "Add town success! But it's expected to be failed!"); repository.MockRemoveOneTownOperation(); service = new TownOperationService(repository.Object, "Foshan", "Chancheng ", "Zhangcha "); Assert.IsTrue(service.DeleteOneTown()); Assert.AreEqual(repository.Object.Count(), 0); }
public void TestSaveAndDeleteTown_AddSuccess_DeleteFail() { Assert.AreEqual(repository.Object.Count(), 1); TownOperationService service = new TownOperationService(repository.Object, "Foshan", "Nanhai ", "Guicheng "); service.SaveOneTown(); Assert.AreEqual(repository.Object.Count(), 2); repository.MockRemoveOneTownOperation(); service = new TownOperationService(repository.Object, "Foshan", "Nanhai", "Dali"); Assert.IsFalse(service.DeleteOneTown()); Assert.AreEqual(repository.Object.Count(), 2); }
public ActionResult AddTown(RegionViewModel viewModel) { Town addConditions = viewModel.AddTownConditions; if (!addConditions.IsAddConditionsValid()) { TempData["error"] = "输入有误!城市、区域、镇区都不能为空。"; return(RedirectToAction("Region")); } TownOperationService service = new TownOperationService(townRepository, addConditions); service.SaveOneTown(); TempData["success"] = "增加镇街:" + addConditions.GetAddConditionsInfo() + "成功"; TempData["RegionViewModel"] = new RegionViewModel("addTown") { CityName = addConditions.CityName, DistrictName = addConditions.DistrictName, TownName = addConditions.TownName, RegionName = viewModel.RegionName }; return(RedirectToAction("Region")); }
public void TestAddTown(int cityId, int districtId, int townId) { service = new TownOperationService(repository, "C-" + cityId, "D-" + districtId, "T-" + townId); service.SaveOneTown(); }