Ejemplo n.º 1
0
 private void SetViewModelParameters(int cityId, int districtId, int townId)
 {
     if (ENodebId > 0)
     {
         viewModel.ENodebName = "ENodeb-" + ENodebId;
     }
     if (AddressId > 0)
     {
         viewModel.Address = "Address-" + AddressId;
     }
     if (cityId > 0)
     {
         viewModel.CityName = "City" + cityId;
         if (districtId > 0)
         {
             viewModel.DistrictName = "District" + districtId;
         }
         if (townId > 0)
         {
             viewModel.TownName = "Town" + townId;
         }
         viewResult = controller.Query(viewModel);
         viewModel  = viewResult.Model as ENodebQueryViewModel;
     }
 }
Ejemplo n.º 2
0
        public ViewResult Query()
        {
            ENodebQueryViewModel viewModel = new ENodebQueryViewModel();

            viewModel.InitializeTownList(_townRepository);
            return(View(viewModel));
        }
Ejemplo n.º 3
0
        public ViewResult Query(ENodebQueryViewModel viewModel)
        {
            ParametersContainer.QueryENodebs = viewModel.ENodebs = _eNodebRepository.GetAllWithNames(_townRepository,
                                                                                                     viewModel, viewModel.ENodebName, viewModel.Address);

            viewModel.InitializeTownList(_townRepository, viewModel);
            if (viewModel.ENodebs != null)
            {
                return(View(viewModel));
            }

            viewModel = new ENodebQueryViewModel();
            viewModel.InitializeTownList(_townRepository);
            return(View(viewModel));
        }
Ejemplo n.º 4
0
        public ActionResult RegionDef(ENodebQueryViewModel viewModel,
                                      EvaluationInfrastructure infrastructure)
        {
            eNodebList = eNodebRepository.GetAllWithNames(townRepository,
                                                          viewModel, viewModel.ENodebName, viewModel.Address);

            EvaluationViewModel model = new EvaluationViewModel
            {
                ENodebs    = eNodebList.Take(PageSize).ToList(),
                PagingInfo = new PagingInfo
                {
                    CurrentPage  = 1,
                    ItemsPerPage = PageSize,
                    TotalItems   = eNodebList.Count()
                },
                TrafficLoad     = EvaluationSettings.TrafficLoad * 100,
                CellCoverage    = (int)EvaluationSettings.DegreeSpan.GetDistanceInMeter(),
                DistanceInMeter = EvaluationSettings.DistanceInMeter
            };

            model.InitializeTownList(townRepository);
            ViewBag.RegionList = infrastructure.Region;
            return(View(model));
        }
Ejemplo n.º 5
0
 private void SetViewModelParameters(int cityId, int districtId, int townId)
 {
     if (ENodebId > 0) { viewModel.ENodebName = "ENodeb-" + ENodebId; }
     if (AddressId > 0) { viewModel.Address = "Address-" + AddressId; }
     if (cityId > 0)
     {
         viewModel.CityName = "City" + cityId;
         if (districtId > 0) { viewModel.DistrictName = "District" + districtId; }
         if (townId > 0) { viewModel.TownName = "Town" + townId; }
         viewResult = controller.Query(viewModel);
         viewModel = viewResult.Model as ENodebQueryViewModel;
     }
 }
Ejemplo n.º 6
0
        public void AssertTest(int cityId = 0, int districtId = 0, int townId = 0)
        {
            viewResult = controller.Query();
            viewModel = viewResult.Model as ENodebQueryViewModel;
            IEnumerable<ENodeb> resultENodebs = new List<ENodeb>();

            SetViewModelParameters(cityId, districtId, townId);
            Assert.IsNotNull(viewModel);
            if (viewModel == null) return;
            Assert.IsNotNull(viewModel.CityList);
            Assert.IsNotNull(viewModel.DistrictList);
            Assert.IsNotNull(viewModel.TownList);
            QueryNamesService service = new QueryDistinctCityNamesService(towns);
            Assert.AreEqual(viewModel.CityList.Count, service.QueryCount());
            if (cityId == 0)
            {
                Assert.IsNull(viewModel.CityName);
                Assert.IsNull(viewModel.DistrictName);
                Assert.IsNull(viewModel.TownName);
                Assert.AreEqual(viewModel.DistrictList.Count, 0);
                Assert.AreEqual(viewModel.TownList.Count, 0);
                Assert.IsNull(viewModel.ENodebs);
            }
            else
            {
                IEnumerable<Town> matchedCityTowns = towns.Where(x => x.CityName == viewModel.CityName);
                if (matchedCityTowns.Any())
                {
                    service = new QueryDistinctDistrictNamesService(towns, viewModel.CityName);
                    Assert.AreEqual(viewModel.DistrictList.Count, service.QueryCount(),
                        "Total towns are not matched!");
                    if (districtId == 0)
                    {
                        Assert.IsNull(viewModel.DistrictName);
                        Assert.IsNull(viewModel.TownName);
                        Assert.AreEqual(viewModel.TownList.Count, 0);
                        resultENodebs = from e in eNodebs
                            join t in matchedCityTowns on e.TownId equals t.Id
                            select e;
                    }
                    else
                    {
                        Assert.IsNotNull(viewModel.DistrictName);
                        Assert.AreEqual(viewModel.DistrictName, "District" + districtId);
                        IEnumerable<Town> matchedDistrictTowns = matchedCityTowns.Where(
                            x => x.DistrictName == viewModel.DistrictName);
                        if (matchedDistrictTowns.Any())
                        {
                            service = new QueryDistinctTownNamesService(
                                towns, viewModel.CityName, viewModel.DistrictName);
                            Assert.AreEqual(viewModel.TownList.Count, service.QueryCount(),
                                "Towns matched district are not matched!");
                            if (townId == 0)
                            {
                                Assert.IsNull(viewModel.TownName);
                                resultENodebs = from e in eNodebs
                                    join t in matchedDistrictTowns on e.TownId equals t.Id
                                    select e;
                            }
                            else
                            {
                                Assert.IsNotNull(viewModel.TownName);
                                Assert.AreEqual(viewModel.TownName, "Town" + townId);
                                Town matchedTown = matchedDistrictTowns.FirstOrDefault(x => x.TownName == viewModel.TownName);
                                if (matchedTown != null)
                                {
                                    resultENodebs = eNodebs.Where(x => x.TownId == matchedTown.Id);
                                }
                            }
                        }
                    }
                    AssertENodebs(resultENodebs);
                }
                else
                {
                    Assert.IsNull(viewModel.DistrictName);
                    Assert.IsNull(viewModel.TownName);
                    Assert.AreEqual(viewModel.DistrictList.Count, 0);
                    Assert.AreEqual(viewModel.TownList.Count, 0);
                    Assert.IsNull(viewModel.ENodebs);
                }
            }
        }
 public ENodebQueryViewModelTestHelper(IEnumerable<Town> towns, ENodebQueryViewModel viewModel)
 {
     this.towns = towns;
     this.viewModel = viewModel;
 }
Ejemplo n.º 8
0
        public ViewResult Query(ENodebQueryViewModel viewModel)
        {
            ParametersContainer.QueryENodebs = viewModel.ENodebs = _eNodebRepository.GetAllWithNames(_townRepository,
                viewModel, viewModel.ENodebName, viewModel.Address);

            viewModel.InitializeTownList(_townRepository, viewModel);
            if (viewModel.ENodebs != null)
            {
                return View(viewModel);
            }

            viewModel = new ENodebQueryViewModel();
            viewModel.InitializeTownList(_townRepository);
            return View(viewModel);
        }
Ejemplo n.º 9
0
 public ViewResult Query()
 {
     ENodebQueryViewModel viewModel = new ENodebQueryViewModel();
     viewModel.InitializeTownList(_townRepository);
     return View(viewModel);
 }
        public ActionResult RegionDef(ENodebQueryViewModel viewModel, 
            EvaluationInfrastructure infrastructure)
        {
            eNodebList = eNodebRepository.GetAllWithNames(townRepository,
                viewModel, viewModel.ENodebName, viewModel.Address);

            EvaluationViewModel model = new EvaluationViewModel
            {
                ENodebs = eNodebList.Take(PageSize).ToList(),
                PagingInfo = new PagingInfo
                {
                    CurrentPage = 1,
                    ItemsPerPage = PageSize,
                    TotalItems = eNodebList.Count()
                },
                TrafficLoad = EvaluationSettings.TrafficLoad * 100,
                CellCoverage = (int)EvaluationSettings.DegreeSpan.GetDistanceInMeter(),
                DistanceInMeter = EvaluationSettings.DistanceInMeter
            };
            model.InitializeTownList(townRepository);
            ViewBag.RegionList = infrastructure.Region;
            return View(model);
        }
Ejemplo n.º 11
0
        public void AssertTest(int cityId = 0, int districtId = 0, int townId = 0)
        {
            viewResult = controller.Query();
            viewModel  = viewResult.Model as ENodebQueryViewModel;
            IEnumerable <ENodeb> resultENodebs = new List <ENodeb>();

            SetViewModelParameters(cityId, districtId, townId);
            Assert.IsNotNull(viewModel);
            if (viewModel == null)
            {
                return;
            }
            Assert.IsNotNull(viewModel.CityList);
            Assert.IsNotNull(viewModel.DistrictList);
            Assert.IsNotNull(viewModel.TownList);
            QueryNamesService service = new QueryDistinctCityNamesService(towns);

            Assert.AreEqual(viewModel.CityList.Count, service.QueryCount());
            if (cityId == 0)
            {
                Assert.IsNull(viewModel.CityName);
                Assert.IsNull(viewModel.DistrictName);
                Assert.IsNull(viewModel.TownName);
                Assert.AreEqual(viewModel.DistrictList.Count, 0);
                Assert.AreEqual(viewModel.TownList.Count, 0);
                Assert.IsNull(viewModel.ENodebs);
            }
            else
            {
                IEnumerable <Town> matchedCityTowns = towns.Where(x => x.CityName == viewModel.CityName);
                if (matchedCityTowns.Any())
                {
                    service = new QueryDistinctDistrictNamesService(towns, viewModel.CityName);
                    Assert.AreEqual(viewModel.DistrictList.Count, service.QueryCount(),
                                    "Total towns are not matched!");
                    if (districtId == 0)
                    {
                        Assert.IsNull(viewModel.DistrictName);
                        Assert.IsNull(viewModel.TownName);
                        Assert.AreEqual(viewModel.TownList.Count, 0);
                        resultENodebs = from e in eNodebs
                                        join t in matchedCityTowns on e.TownId equals t.Id
                                        select e;
                    }
                    else
                    {
                        Assert.IsNotNull(viewModel.DistrictName);
                        Assert.AreEqual(viewModel.DistrictName, "District" + districtId);
                        IEnumerable <Town> matchedDistrictTowns = matchedCityTowns.Where(
                            x => x.DistrictName == viewModel.DistrictName);
                        if (matchedDistrictTowns.Any())
                        {
                            service = new QueryDistinctTownNamesService(
                                towns, viewModel.CityName, viewModel.DistrictName);
                            Assert.AreEqual(viewModel.TownList.Count, service.QueryCount(),
                                            "Towns matched district are not matched!");
                            if (townId == 0)
                            {
                                Assert.IsNull(viewModel.TownName);
                                resultENodebs = from e in eNodebs
                                                join t in matchedDistrictTowns on e.TownId equals t.Id
                                                select e;
                            }
                            else
                            {
                                Assert.IsNotNull(viewModel.TownName);
                                Assert.AreEqual(viewModel.TownName, "Town" + townId);
                                Town matchedTown = matchedDistrictTowns.FirstOrDefault(x => x.TownName == viewModel.TownName);
                                if (matchedTown != null)
                                {
                                    resultENodebs = eNodebs.Where(x => x.TownId == matchedTown.Id);
                                }
                            }
                        }
                    }
                    AssertENodebs(resultENodebs);
                }
                else
                {
                    Assert.IsNull(viewModel.DistrictName);
                    Assert.IsNull(viewModel.TownName);
                    Assert.AreEqual(viewModel.DistrictList.Count, 0);
                    Assert.AreEqual(viewModel.TownList.Count, 0);
                    Assert.IsNull(viewModel.ENodebs);
                }
            }
        }
Ejemplo n.º 12
0
 public ViewResult Query(ENodebQueryViewModel viewModel)
 {
     viewModel.InitializeTownList(_townRepository, viewModel);
     viewModel.SetItems(1, pageSize);
     return View(viewModel);
 }
Ejemplo n.º 13
0
 public ViewResult Query(int page = 1)
 {
     ENodebQueryViewModel viewModel = new ENodebQueryViewModel();
     viewModel.InitializeTownList(_townRepository);
     viewModel.SetItems(page, pageSize);
     return View(viewModel);
 }
 public ENodebQueryViewModelTestHelper(IEnumerable <Town> towns, ENodebQueryViewModel viewModel)
 {
     this.towns     = towns;
     this.viewModel = viewModel;
 }