public void TestLatestDataOnly()
        {
            AreaDataBuilder builder = new AreaDataBuilder
            {
                Areas = new List<IArea> { new Area { Code = AreaCodes.England } },
                ComparatorAreaCodes = new List<string> { AreaCodes.England },
                GroupId = GroupIds.PracticeProfiles_PracticeSummary,
                AreaTypeId = AreaTypeIds.GpPractice,
                IncludeTimePeriods = true,
                LatestDataOnly = true
            };

            var map = builder.Build();

            foreach (var key in map.Keys)
            {
                var fullAreaDataList = map[key];
                foreach (var areaData in fullAreaDataList)
                {
                    var fullAreaData = areaData as FullAreaData;

                    Assert.AreEqual(1, fullAreaData.Data.Count);
                    Assert.AreEqual(1, fullAreaData.Periods.Count);
                }
            }
        }
        public Dictionary<int, Dictionary<string, IList<SimpleAreaData>>> GetAreaData()
        {
            var areaListBuilder = new AreaListProvider(ReaderFactory.GetAreasReader());
            areaListBuilder.CreateAreaListFromAreaCodes(_parameters.AreaCodes);
            var areas = areaListBuilder.Areas;

            Dictionary<int, Dictionary<string, IList<SimpleAreaData>>> groupIdToData =
                new Dictionary<int, Dictionary<string, IList<SimpleAreaData>>>();

            foreach (var groupId in _parameters.GroupIds)
            {
                Dictionary<string, IList<SimpleAreaData>> data = new AreaDataBuilder
                {
                    GroupId = groupId,
                    Areas = areas,
                    AreaTypeId = _parameters.AreaTypeId,
                    ComparatorAreaCodes = _parameters.ComparatorAreaCodes,
                    IncludeTimePeriods = _parameters.IncludeTimePeriods,
                    LatestDataOnly = _parameters.LatestDataOnly
                }.Build();
                groupIdToData.Add(groupId, data);
            }

            return groupIdToData;
        }
        public void TestRegressionTestForPracticeProfiles()
        {
            AreaDataBuilder builder = new AreaDataBuilder
                {
                    Areas = Area(),
                    ComparatorAreaCodes = new List<string> { AreaCodes.England },
                    GroupId = GroupIds.PracticeProfiles_SecondaryCareUse,
                    AreaTypeId = AreaTypeIds.GpPractice
                };

            var map = builder.Build();
            Assert.AreEqual(1, map.Count);
        }
        public void TestDiabetesPracticeDetails()
        {
            var areaCode = AreaCodes.Gp_PracticeInBarnetCcg;
            var parentAreaCode = AreaCodes.Ccg_Barnet;

            AreaDataBuilder builder = new AreaDataBuilder
            {
                Areas = new List<IArea>{new Area{Code = areaCode}},
                ComparatorAreaCodes = new List<string> { parentAreaCode },
                GroupId = GroupIds.Diabetes_PrevalenceAndRisk,
                AreaTypeId = AreaTypeIds.GpPractice
            };

            var dataList = builder.Build()[areaCode];
            foreach (var simpleAreaData in dataList)
            {
                Assert.IsNotNull(simpleAreaData);
                Assert.IsTrue(simpleAreaData.Significances[parentAreaCode].First()/*only one time period*/ > 0);
            }
        }
        public void TestTimePeriodsAreIncludedForMissingData()
        {
            AreaDataBuilder builder = new AreaDataBuilder
            {
                Areas = new List<IArea> { new Area { Code = AreaCodes.England } },
                ComparatorAreaCodes = new List<string> { AreaCodes.England },
                GroupId = GroupIds.PracticeProfiles_PracticeSummary,
                AreaTypeId = AreaTypeIds.GpPractice,
                IncludeTimePeriods = true
            };

            var map = builder.Build();

            foreach (var key in map.Keys)
            {
                var fullAreaDataList = map[key];
                foreach (var areaData in fullAreaDataList)
                {
                    var fullAreaData = areaData as FullAreaData;

                    Assert.AreEqual(fullAreaData.Data.Count, fullAreaData.Periods.Count,
                        "Number of data point and time periods should be equal but are not for indicator ID " + fullAreaData.IndicatorId);
                }
            }
        }