Example #1
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));
            }
        }
Example #2
0
 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 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_NoENodebRepository()
        {
            TownOperationService service = new TownOperationService(mockTownRepository.Object,
                                                                    "City1", "District1", "Town1");

            Assert.IsTrue(service.DeleteOneTown());
            Assert.AreEqual(mockTownRepository.Object.Count(), 0);
        }
        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_RightENodebRepository()
        {
            mockENodebRepository.Setup(x => x.GetAll()).Returns(new List <ENodeb> {
                new ENodeb {
                    TownId = 22, Name = "E1"
                }
            }.AsQueryable());
            TownOperationService service = new TownOperationService(mockTownRepository.Object,
                                                                    "City1", "District1", "Town1");

            Assert.IsFalse(service.DeleteOneTown(mockENodebRepository.Object, null));
            Assert.AreEqual(mockTownRepository.Object.Count(), 1);
        }
        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 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"));
        }
Example #11
0
 public bool TestDeleteTown(int cityId, int districtId, int townId)
 {
     service = new TownOperationService(repository,
                                        "C-" + cityId, "D-" + districtId, "T-" + townId);
     return(service.DeleteOneTown());
 }