public void TestDeleteTown_WithENodebInfos_Fail() { TownOperationService service = new TownOperationService(repository.Object, "Foshan ", "Chancheng ", "Zhangcha"); Assert.IsFalse(service.DeleteOneTown(lteRepository.Object, null)); Assert.AreEqual(repository.Object.Count(), 1); }
public void TestDeleteTown_WithWhiteSpace_Success() { TownOperationService service = new TownOperationService(repository.Object, "Foshan ", "Chancheng ", "Zhangcha"); Assert.IsTrue(service.DeleteOneTown()); Assert.AreEqual(repository.Object.Count(), 0); }
public void TestMockDeleteTown_NullENodebRepository() { TownOperationService service = new TownOperationService(mockTownRepository.Object, "City1", "District1", "Town1"); Assert.IsTrue(service.DeleteOneTown(null,null)); Assert.AreEqual(mockTownRepository.Object.Count(), 0); }
public void TestDeleteTown_Fail() { TownOperationService service = new TownOperationService(repository.Object, "Foshan", "Chancheng", "Zumiao"); Assert.IsFalse(service.DeleteOneTown()); Assert.AreEqual(repository.Object.Count(), 1); }
public void TestMockDeleteTown_WrongENodebRepository() { mockENodebRepository.Setup(x => x.GetAll()).Returns(new List<ENodeb> { new ENodeb { TownId = 21, Name = "E1" } }.AsQueryable()); TownOperationService service = new TownOperationService(mockTownRepository.Object, "City1", "District1", "Town1"); Assert.IsTrue(service.DeleteOneTown(mockENodebRepository.Object,null)); Assert.AreEqual(mockTownRepository.Object.Count(), 0); }
public void TestMockDeleteTownAction(int cityId, int districtId, int townId, bool success) { TownOperationService service = new TownOperationService(townRepository.Object, "City" + cityId, "District" + districtId, "Town" + townId); if (success) { Assert.IsTrue(service.DeleteOneTown(null, null)); } else { Assert.IsFalse(service.DeleteOneTown(null, null)); } }
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 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 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 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 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 bool TestDeleteTown(int cityId, int districtId, int townId, IENodebRepository eNodebRepository, IBtsRepository btsRepository) { service = new TownOperationService(repository, "C-" + cityId, "D-" + districtId, "T-" + townId); return service.DeleteOneTown(eNodebRepository, btsRepository); }
public bool TestDeleteTown(int cityId, int districtId, int townId) { service = new TownOperationService(repository, "C-" + cityId, "D-" + districtId, "T-" + townId); return service.DeleteOneTown(); }
public void TestAddTown(int cityId, int districtId, int townId) { service = new TownOperationService(repository, "C-" + cityId, "D-" + districtId, "T-" + townId); service.SaveOneTown(); }
public ActionResult DeleteTown(RegionViewModel viewModel) { TownOperationService service = new TownOperationService(townRepository, viewModel); bool result = service.DeleteOneTown(eNodebRepository, btsRepository); if (result) { TempData["success"] = viewModel.DeleteSuccessMessage; } else { TempData["error"] = viewModel.DeleteFailMessage; } return RedirectToAction("Region"); }