public Dictionary<string, IEnumerable<string>> GetParentAreaToChildAreaDictionary()
        {
            Dictionary<string, IEnumerable<string>> parentCodeToChildCodes = new Dictionary<string, IEnumerable<string>>();

            var ignoredAreasFilter = IgnoredAreasFilterFactory.New(_parameters.GetNonSearchProfileId());

            var parentAreas = GetParentAreas();

            if (_parameters.NearestNeighbourCode != "")
            {
                var areaCode = _parameters.NearestNeighbourCode.Substring(5);
                parentCodeToChildCodes.Add(areaCode, parentAreas.Select(x => x.Code).ToList());
            }
            else
            {
                foreach (var parentArea in parentAreas)
                {
                    var parentChildAreaRelationship = new ParentChildAreaRelationshipBuilder(
                        ignoredAreasFilter, new AreaListProvider(areasReader))
                        .GetParentAreaWithChildAreas(parentArea, _parameters.AreaTypeId, _parameters.RetrieveIgnoredAreas);

                    parentCodeToChildCodes.Add(parentArea.Code, parentChildAreaRelationship.GetChildAreaCodes());
                }
            }

            return parentCodeToChildCodes;
        }
        public ChildAreasForPdfs GetResponse(int profileId, string parentAreaCode, int childAreaTypeId)
        {
            ParameterCheck.GreaterThanZero("Profile ID", profileId);
            ParameterCheck.GreaterThanZero("Child area type ID", childAreaTypeId);
            ParameterCheck.ValidAreaCode(parentAreaCode);

            var areasReader = ReaderFactory.GetAreasReader();
            var parentArea = areasReader.GetAreaFromCode(parentAreaCode);
            var ignoredAreasFilter = IgnoredAreasFilterFactory.New(profileId);

            var parentAreaWithChildren = new ParentChildAreaRelationshipBuilder(
                ignoredAreasFilter, new AreaListProvider(areasReader))
                     .GetParentAreaWithChildAreas(parentArea, childAreaTypeId, false/*retrieve ignored areas*/);

            // Benchmark hard coded for now
            var benchmarkArea = areasReader.GetAreaFromCode(AreaCodes.England);
            return new ChildAreasForPdfs(parentAreaWithChildren, benchmarkArea);
        }
        public void TestBuild_IgnoredAreasMayBeRemoved()
        {
            var areaListBuilder = new Mock<AreaListProvider>();
            areaListBuilder.SetupGet(x => x.Areas)
                .Returns(filteredAreas);

            var ignoredAreasFilter = new Mock<IgnoredAreasFilter>(MockBehavior.Strict);
            ignoredAreasFilter.Setup(x => x.RemoveAreasIgnoredEverywhere(unfilteredAreas));

            // Get areas
            ParentAreaWithChildAreas relationship =
                new ParentChildAreaRelationshipBuilder(ignoredAreasFilter.Object, areaListBuilder.Object)
                    .GetParentAreaWithChildAreas(new Area { Code = parentAreaCode }, childAreaId, false);

            // Verify
            Assert.AreEqual(2, relationship.Children.Count());
            areaListBuilder.VerifyAll();
        }
        public void TestBuild()
        {
            var areaListBuilder = new Mock<AreaListProvider>(MockBehavior.Strict);
            areaListBuilder.Setup(x => x.CreateChildAreaList(parentAreaCode, childAreaId));
            areaListBuilder.Setup(x => x.SortByOrderOrName());
            areaListBuilder.SetupGet(x => x.Areas)
                .Returns(unfilteredAreas);

            var ignoredAreasFilter = new Mock<IgnoredAreasFilter>(MockBehavior.Strict);

            // Get areas
            ParentAreaWithChildAreas relationship =
                new ParentChildAreaRelationshipBuilder(ignoredAreasFilter.Object, areaListBuilder.Object)
                    .GetParentAreaWithChildAreas(new Area { Code = parentAreaCode }, childAreaId, true);

            // Verify
            Assert.AreEqual(3, relationship.Children.Count());
            Assert.AreEqual(parentAreaCode, relationship.Parent.Code);
            areaListBuilder.VerifyAll();
        }