private IList<IArea> GetParentAreas() { var listBuilder = new AreaListProvider(areasReader); if (Area.IsNearestNeighbour(_parameters.NearestNeighbourCode)) { listBuilder.CreateAreaListFromNearestNeighbourAreaCode(_parameters.ProfileId, _parameters.NearestNeighbourCode); } else { listBuilder.CreateAreaListFromAreaTypeId(_parameters.ProfileId, _parameters.ParentAreaTypeId); } return listBuilder.Areas; }
public void CreateAreaListFromAreaTypeIdReturnsParentAreas() { IList<string> codes = new List<string> { "a", "b" }; var areas = AreaList(); var mockAreasReader = new Mock<AreasReader>(); ParentAreaCodesAreFound(codes, mockAreasReader); AreasGotFromCodes(codes, areas, mockAreasReader); var builder = new AreaListProvider(mockAreasReader.Object); builder.CreateAreaListFromAreaTypeId(profileId, areaTypeId); var areaList = builder.Areas; Assert.AreEqual(3, areaList.Count); }
public void CreateAreaListFromAreaTypeIdWhereCategoryAreaType() { var categoryAreaType = CategoryAreaType.New(new CategoryType { Id = CategoryTypeIds.DeprivationDecileCountyAndUA2010 }); var builder = new AreaListProvider(ReaderFactory.GetAreasReader()); builder.CreateAreaListFromAreaTypeId(profileId, categoryAreaType.Id); var areaList = builder.Areas; Assert.IsTrue(areaList.Any()); // Check names are defined Assert.IsFalse(string.IsNullOrEmpty(areaList.First().Name)); Assert.IsFalse(string.IsNullOrEmpty(areaList.First().ShortName)); }
public IList<IArea> GetResponse(int areaTypeId, int profileId, int templateProfileId, bool retrieveIgnoredAreas) { _areaListProvider = new AreaListProvider(areasReader); _areaListProvider.CreateAreaListFromAreaTypeId(profileId, areaTypeId); // Remove ignored areas if (retrieveIgnoredAreas == false) { var nonSearchProfileId = ActionHelper.GetNonSearchProfileId(profileId, templateProfileId); var ignoredAreasFilter = IgnoredAreasFilterFactory.New(nonSearchProfileId); _areaListProvider.RemoveAreasIgnoredEverywhere(ignoredAreasFilter); } _areaListProvider.SortByOrderOrName(); return _areaListProvider.Areas; }
private AreaListProvider CreateAreaListFromAreaTypeId(List<Area> areas) { var mockAreasReader = new Mock<AreasReader>(); GetAreasByAreaTypeIdReturnsAreas(areas, mockAreasReader); NoParentAreaCodes(mockAreasReader); var builder = new AreaListProvider(mockAreasReader.Object); builder.CreateAreaListFromAreaTypeId(profileId, areaTypeId); return builder; }