public void PopulateHistoricalChartsWithFinancialDataCalculatesAmountsByPercentage()
        {
            List <ChartViewModel> historicalCharts = new List <ChartViewModel>()
            {
                new ChartViewModel()
                {
                    Name       = "Special Facilities",
                    FieldName  = "Special facilities",
                    TabType    = Helpers.Enums.TabType.Expenditure,
                    ChartGroup = Helpers.Enums.ChartGroupType.SpecialFacilities,
                },
                new ChartViewModel()
                {
                    Name       = "Education Support Staff",
                    FieldName  = "Education support staff",
                    TabType    = Helpers.Enums.TabType.Expenditure,
                    ChartGroup = Helpers.Enums.ChartGroupType.Staff,
                }
            };

            var financialObj = new SchoolTrustFinancialDataObject();

            financialObj.Specialfacilities     = 1000;
            financialObj.EducationSupportStaff = 2000;
            financialObj.NoPupils         = 100;
            financialObj.NoTeachers       = 10;
            financialObj.TotalExpenditure = 5000;

            var dataModels = new List <FinancialDataModel>()
            {
                new FinancialDataModel("123", "2014 / 2015", financialObj, EstablishmentType.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.PopulateHistoricalChartsWithFinancialData(historicalCharts, dataModels, "2014 / 2015", Helpers.Enums.TabType.Expenditure, Helpers.Enums.UnitType.PercentageOfTotalExpenditure, EstablishmentType.Academies);

            Assert.AreEqual(20, historicalCharts[0].LastYearBalance);
            Assert.AreEqual(40, historicalCharts[1].LastYearBalance);
        }
        public void PopulateHistoricalChartsWithFinancialDataGeneratesJSONWithCorrectYearLabels()
        {
            List <ChartViewModel> historicalCharts = new List <ChartViewModel>()
            {
                new ChartViewModel()
                {
                    Name       = "Special Facilities",
                    FieldName  = "Special facilities",
                    TabType    = Helpers.Enums.TabType.Expenditure,
                    ChartGroup = Helpers.Enums.ChartGroupType.SpecialFacilities,
                },
                new ChartViewModel()
                {
                    Name       = "Education Support Staff",
                    FieldName  = "Education support staff",
                    TabType    = Helpers.Enums.TabType.Expenditure,
                    ChartGroup = Helpers.Enums.ChartGroupType.Staff,
                }
            };

            var financialObj = new SchoolTrustFinancialDataObject();

            financialObj.Specialfacilities     = 1000;
            financialObj.EducationSupportStaff = 2000;
            financialObj.NoPupils   = 100;
            financialObj.NoTeachers = 10;

            var dataModels = new List <FinancialDataModel>()
            {
                new FinancialDataModel("123", "2014 / 2015", financialObj, EstablishmentType.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.PopulateHistoricalChartsWithFinancialData(historicalCharts, dataModels, "2014 / 2015", Helpers.Enums.TabType.Expenditure, Helpers.Enums.UnitType.AbsoluteMoney, EstablishmentType.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);
        }