public void TestEnglandReturnsValuesButNotRanks() { var areasReader = ReaderFactory.GetAreasReader(); AreaRankBuilder rankBuilder = new AreaRankBuilder { AreasReader = areasReader, GroupDataReader = ReaderFactory.GetGroupDataReader(), Area = England() }; var grouping = TestGrouping(); TimePeriod timePeriod = TimePeriod.GetDataPoint(grouping); var dataList = GetDataList(grouping, timePeriod); AreaRankGrouping rank = rankBuilder.BuildRank(grouping, indicatorMetadata, timePeriod, dataList); // Assert Assert.IsNull(rank.AreaRank.Rank, "England rank not null"); Assert.IsNotNull(rank.AreaRank.Value, "England value null"); Assert.IsNotNull(rank.AreaRank.Count, "England count null"); }
public void TestDeprivationDecileReturnsValuesButNotRanks() { var areasReader = ReaderFactory.GetAreasReader(); var categoryArea = CategoryArea.New(CategoryTypeIds.DeprivationDecileCountyAndUA2010, 7); AreaRankBuilder rankBuilder = new AreaRankBuilder { AreasReader = areasReader, GroupDataReader = ReaderFactory.GetGroupDataReader(), Area = categoryArea }; var grouping = TestGrouping(); TimePeriod timePeriod = TimePeriod.GetDataPoint(grouping); var dataList = GetDataList(grouping, timePeriod); AreaRankGrouping rank = rankBuilder.BuildRank(grouping, indicatorMetadata, timePeriod, dataList); // Assert Assert.IsNull(rank.AreaRank.Rank, "decile rank not null"); Assert.IsNotNull(rank.AreaRank.Value, "decile value null"); Assert.IsNotNull(rank.AreaRank.Count, "decile count null"); }
public LongerLivesAreaDetails GetAreaDetails(int profileId, int groupId, int childAreaTypeId, string areaCode) { area = AreaFactory.NewArea(areasReader, areaCode); indicatorComparerFactory = new IndicatorComparerFactory { PholioReader = ReaderFactory.GetPholioReader() }; var parentCodeToRanks = new Dictionary<string, List<AreaRankGrouping>>(); var parentCodeToSignificances = new Dictionary<string, List<int?>>(); var parentCodeToBenchmarks = new Dictionary<string, object>(); InitIgnoredAreaCodes(profileId); // Set up parent areas Area country = areasReader.GetAreaFromCode(AreaCodes.England); var parentAreas = new List<IArea> { country }; AddOnsClusterToParentAreas(childAreaTypeId, area, parentAreas); Decile decile = GetDecile(parentAreas, childAreaTypeId, areaCode); var isParentArea = IsParentArea(area); foreach (IArea parentArea in parentAreas) { string parentAreaCode = parentArea.Code; GroupData groupData = new GroupDataAtDataPointRepository().GetGroupDataProcessed( parentAreaCode, childAreaTypeId, profileId, groupId); var rankBuilder = new AreaRankBuilder { GroupDataReader = groupDataReader, AreasReader = areasReader, Area = area }; var ranks = new List<AreaRankGrouping>(); var significances = new List<int?>(); var benchmarks = new List<CoreDataSet>(); parentCodeToRanks.Add(parentAreaCode, ranks); foreach (GroupRoot groupRoot in groupData.GroupRoots) { Grouping grouping = GetGrouping(parentArea, groupRoot); // Get data list IndicatorMetadata metadata = groupData.GetIndicatorMetadataById(grouping.IndicatorId); TimePeriod timePeriod = TimePeriod.GetDataPoint(grouping); IList<CoreDataSet> childAreaDataList = GetChildAreaDataList(parentArea, groupRoot, grouping, timePeriod); var areaRankGrouping = rankBuilder.BuildRank(grouping, metadata, timePeriod, childAreaDataList); ranks.Add(areaRankGrouping); // Area significance if (areaRankGrouping != null && isParentArea == false) { var significance = GetSignificance(areaCode, groupRoot, grouping, childAreaDataList); significances.Add(significance); } else { significances.Add(null); } benchmarks.Add(grouping.ComparatorData); } parentCodeToSignificances.Add(parentAreaCode, significances); parentCodeToBenchmarks.Add(parentAreaCode, benchmarks); } string url = null; if (isParentArea) { // Significances not relevant for parent areas parentCodeToSignificances = null; parentCodeToBenchmarks = null; } else { // Only need area web site link for child areas url = areasReader.GetAreaUrl(area.Code); } // Bespoke response object return new LongerLivesAreaDetails { Area = area, Decile = decile, Url = url, Ranks = parentCodeToRanks, Significances = parentCodeToSignificances, Benchmarks = parentCodeToBenchmarks }; }
private AreaRankGrouping TestAreaWithLowIsGoodPolarity(string areaCode) { var areasReader = ReaderFactory.GetAreasReader(); AreaRankBuilder rankBuilder = new AreaRankBuilder { AreasReader = areasReader, GroupDataReader = ReaderFactory.GetGroupDataReader(), Area = areasReader.GetAreaFromCode(areaCode) }; var grouping = TestDiabetesGrouping(); grouping.PolarityId = PolarityIds.RagLowIsGood; TimePeriod timePeriod = TimePeriod.GetDataPoint(grouping); var dataList = GetDataList(grouping, timePeriod); AreaRankGrouping rank = rankBuilder.BuildRank(grouping, indicatorMetadata, timePeriod, dataList); // Check ranks defined Assert.IsTrue(rank.AreaRank.Rank > 0, "No rank for " + areaCode); Assert.AreEqual(1, rank.Min.Rank); return rank; }
private AreaRankGrouping TestArea(string areaCode) { var areasReader = ReaderFactory.GetAreasReader(); AreaRankBuilder rankBuilder = new AreaRankBuilder { AreasReader = areasReader, GroupDataReader = ReaderFactory.GetGroupDataReader(), Area = areasReader.GetAreaFromCode(areaCode) }; var grouping = TestGrouping(); TimePeriod timePeriod = TimePeriod.GetDataPoint(grouping); var dataList = GetDataList(grouping, timePeriod); AreaRankGrouping rank = rankBuilder.BuildRank(grouping, indicatorMetadata, timePeriod, dataList); // Check ranks defined Assert.IsTrue(rank.AreaRank.Rank > 0, "No rank for " + areaCode); Assert.IsTrue(rank.Max.Rank > 140 && rank.Max.Rank < 160, "Max rank outside range expected for " + areaCode); Assert.AreEqual(1, rank.Min.Rank); return rank; }