public void PopulateHistoricalChartsWithFinancialDataGeneratesJSONWithCorrectYearLabels() { List <ChartViewModel> historicalCharts = new List <ChartViewModel>() { new ChartViewModel() { Name = "Special Facilities", FieldName = "Special facilities", RevenueGroup = Helpers.Enums.RevenueGroupType.Expenditure, ChartGroup = Helpers.Enums.ChartGroupType.SpecialFacilities, }, new ChartViewModel() { Name = "Education Support Staff", FieldName = "Education support staff", RevenueGroup = Helpers.Enums.RevenueGroupType.Expenditure, ChartGroup = Helpers.Enums.ChartGroupType.Staff, } }; var doc = new Document(); doc.SetPropertyValue("Special facilities", "1000"); doc.SetPropertyValue("Education support staff", "2000"); doc.SetPropertyValue("No Pupils", "100"); doc.SetPropertyValue("No Teachers", "10"); var dataModels = new List <SchoolFinancialDataModel>() { new SchoolFinancialDataModel("123", "2014 / 2015", doc, SchoolFinancialType.Maintained) }; var mockLaService = new Mock <ILocalAuthoritiesService>(); mockLaService.Setup(m => m.GetLocalAuthorities()).Returns(() => "[{\"id\": \"0\",\"LANAME\": \"Hartlepool\",\"REGION\": \"1\",\"REGIONNAME\": \"North East A\"}]"); var service = new FinancialCalculationsService(mockLaService.Object); service.PopulateHistoricalChartsWithSchoolData(historicalCharts, dataModels, "2014 / 2015", Helpers.Enums.RevenueGroupType.Expenditure, Helpers.Enums.UnitType.AbsoluteMoney, SchoolFinancialType.Maintained); var historicalChartData = JsonConvert.DeserializeObject <List <HistoricalChartData> >(historicalCharts[0].DataJson); Assert.AreEqual("2014-15", historicalChartData[0].Year); }
public void PopulateHistoricalChartsWithFinancialDataCalculatesAmountsByPercentage() { List <ChartViewModel> historicalCharts = new List <ChartViewModel>() { new ChartViewModel() { Name = "Special Facilities", FieldName = "Special facilities", RevenueGroup = Helpers.Enums.RevenueGroupType.Expenditure, ChartGroup = Helpers.Enums.ChartGroupType.SpecialFacilities, }, new ChartViewModel() { Name = "Education Support Staff", FieldName = "Education support staff", RevenueGroup = Helpers.Enums.RevenueGroupType.Expenditure, ChartGroup = Helpers.Enums.ChartGroupType.Staff, } }; var doc = new Document(); doc.SetPropertyValue("Special facilities", "1000"); doc.SetPropertyValue("Education support staff", "2000"); doc.SetPropertyValue("No Pupils", "100"); doc.SetPropertyValue("No Teachers", "10"); doc.SetPropertyValue("Total Expenditure", "5000"); var dataModels = new List <SchoolFinancialDataModel>() { new SchoolFinancialDataModel("123", "2014 / 2015", doc, SchoolFinancialType.Maintained) }; var mockLaService = new Mock <ILocalAuthoritiesService>(); mockLaService.Setup(m => m.GetLocalAuthorities()).Returns(() => "[{\"id\": \"0\",\"LANAME\": \"Hartlepool\",\"REGION\": \"1\",\"REGIONNAME\": \"North East A\"}]"); var service = new FinancialCalculationsService(mockLaService.Object); service.PopulateHistoricalChartsWithSchoolData(historicalCharts, dataModels, "2014 / 2015", Helpers.Enums.RevenueGroupType.Expenditure, Helpers.Enums.UnitType.PercentageOfTotal, SchoolFinancialType.Academies); Assert.AreEqual(20, historicalCharts[0].LastYearBalance); Assert.AreEqual(40, historicalCharts[1].LastYearBalance); }