public async Task DetailShouldKeepUnitTypeBetweenExpenditureAndIncomeTabsAsync() { var fakeEdubaseObject = new EdubaseDataObject { URN = 123, FinanceType = "Maintained" }; var mockEdubaseDataService = new Mock <IContextDataService>(); var GetSchoolDataObjectByUrnAsyncTask = Task.Run(() => { return(fakeEdubaseObject); }); mockEdubaseDataService.Setup(m => m.GetSchoolDataObjectByUrnAsync(123)).Returns((long urn) => GetSchoolDataObjectByUrnAsyncTask); var financialCalculationsService = new Mock <IFinancialCalculationsService>(); var mockFinancialDataService = new Mock <IFinancialDataService>(); var mockDownloadCsvBuilder = new Mock <IDownloadCSVBuilder>(); var mockCookieManager = new Mock <ISchoolBenchmarkListService>(); var mockLaSearchService = new Mock <ILocalAuthoritiesService>(); var mockActiveUrnsService = new Mock <IActiveEstablishmentsService>(); var mockCscpLookupService = new Mock <ICscpLookupService>(); var mockGiasLookupService = new Mock <IGiasLookupService>(); var mockSchoolVMBuilder = new Mock <ISchoolVMBuilder>(); var fakeSVM = new SchoolViewModel(fakeEdubaseObject); fakeSVM.HistoricalFinancialDataModels = new List <FinancialDataModel> { new FinancialDataModel() }; fakeSVM.HistoricalCharts = new List <ChartViewModel> { new ChartViewModel() }; mockSchoolVMBuilder.Setup(m => m.GetResult()).Returns(fakeSVM); var controller = new SchoolController(mockFinancialDataService.Object, financialCalculationsService.Object, mockEdubaseDataService.Object, mockDownloadCsvBuilder.Object, mockCookieManager.Object, mockActiveUrnsService.Object, mockSchoolVMBuilder.Object, mockGiasLookupService.Object, mockCscpLookupService.Object); controller.ControllerContext = new ControllerContext(_rc, controller); await controller.Detail(123, UnitType.PerPupil, CentralFinancingType.Exclude, TabType.Income); mockSchoolVMBuilder.Verify(f => f.AddHistoricalChartsAsync( It.IsAny <TabType>(), It.IsAny <ChartGroupType>(), It.IsAny <CentralFinancingType>(), UnitType.PerPupil)); }
public void DetailShouldKeepUnitTypeBetweenExpenditureAndIncomeTabs() { var mockEdubaseDataService = new Mock <IContextDataService>(); dynamic testEduResult = new Document(); testEduResult.URN = "123"; mockEdubaseDataService.Setup(m => m.GetSchoolByUrn("123")).Returns((string urn) => testEduResult); var mockHistoricalChartBuilder = new Mock <IHistoricalChartBuilder>(); mockHistoricalChartBuilder .Setup(cb => cb.Build(It.IsAny <RevenueGroupType>(), It.IsAny <ChartGroupType>(), It.IsAny <SchoolFinancialType>(), It.IsAny <UnitType>())) .Returns((RevenueGroupType revenueGroup, ChartGroupType chartGroupType, SchoolFinancialType schoolFinancialType, UnitType unit) => new List <ChartViewModel>() { new ChartViewModel() { ChartGroup = ChartGroupType.Staff } }); mockHistoricalChartBuilder .Setup(cb => cb.Build(It.IsAny <RevenueGroupType>(), It.IsAny <SchoolFinancialType>())) .Returns((RevenueGroupType revenueGroup, SchoolFinancialType schoolFinancialType) => new List <ChartViewModel>() { new ChartViewModel() { ChartGroup = ChartGroupType.Staff } }); var financialCalculationsService = new Mock <IFinancialCalculationsService>(); var mockFinancialDataService = new Mock <IFinancialDataService>(); var mockDownloadCsvBuilder = new Mock <IDownloadCSVBuilder>(); var controller = new SchoolController(mockHistoricalChartBuilder.Object, mockFinancialDataService.Object, financialCalculationsService.Object, mockEdubaseDataService.Object, mockDownloadCsvBuilder.Object); controller.ControllerContext = new ControllerContext(_rc, controller); controller.Detail(123, UnitType.PerPupil, CentralFinancingType.Exclude, RevenueGroupType.Income); financialCalculationsService.Verify(f => f.PopulateHistoricalChartsWithSchoolData( It.IsAny <List <ChartViewModel> >(), It.IsAny <List <SchoolFinancialDataModel> >(), It.IsAny <string>(), It.IsAny <RevenueGroupType>(), UnitType.PerPupil, It.IsAny <SchoolFinancialType>())); }
public void DetailCallShouldResetUnitTypeBetweenExpenditureAndWorkforceTabs() { var mockEdubaseDataService = new Mock <IContextDataService>(); var GetSchoolDataObjectByUrnAsyncTask = Task.Run(() => { return(new EdubaseDataObject { URN = 123, FinanceType = "Maintained" }); }); mockEdubaseDataService.Setup(m => m.GetSchoolDataObjectByUrnAsync(123)).Returns((long urn) => GetSchoolDataObjectByUrnAsyncTask); var mockHistoricalChartBuilder = new Mock <IHistoricalChartBuilder>(); mockHistoricalChartBuilder .Setup(cb => cb.Build(It.IsAny <TabType>(), It.IsAny <ChartGroupType>(), It.IsAny <EstablishmentType>(), It.IsAny <UnitType>())) .Returns((TabType TabNames, ChartGroupType chartGroupType, EstablishmentType schoolFinancialType, UnitType unit) => new List <ChartViewModel>() { new ChartViewModel() { ChartGroup = ChartGroupType.Staff } }); mockHistoricalChartBuilder .Setup(cb => cb.Build(It.IsAny <TabType>(), It.IsAny <EstablishmentType>())) .Returns((TabType TabNames, EstablishmentType schoolFinancialType) => new List <ChartViewModel>() { new ChartViewModel() { ChartGroup = ChartGroupType.Staff } }); var financialCalculationsService = new Mock <IFinancialCalculationsService>(); var mockFinancialDataService = new Mock <IFinancialDataService>(); var mockDownloadCsvBuilder = new Mock <IDownloadCSVBuilder>(); var mockCookieManager = new Mock <ISchoolBenchmarkListService>(); var mockLaSearchService = new Mock <ILocalAuthoritiesService>(); var mockActiveUrnsService = new Mock <IActiveEstablishmentsService>(); var mockSchoolVMBuilder = new Mock <ISchoolVMBuilder>(); var mockCscpLookupService = new Mock <ICscpLookupService>(); var mockGiasLookupService = new Mock <IGiasLookupService>(); var controller = new SchoolController(mockFinancialDataService.Object, financialCalculationsService.Object, mockEdubaseDataService.Object, mockDownloadCsvBuilder.Object, mockCookieManager.Object, mockActiveUrnsService.Object, mockSchoolVMBuilder.Object, mockGiasLookupService.Object, mockCscpLookupService.Object); controller.ControllerContext = new ControllerContext(_rc, controller); _ = controller.Detail(123, UnitType.PerPupil, CentralFinancingType.Exclude, TabType.Workforce); mockSchoolVMBuilder.Verify(f => f.AddHistoricalChartsAsync( It.IsAny <TabType>(), It.IsAny <ChartGroupType>(), It.IsAny <CentralFinancingType>(), UnitType.AbsoluteCount)); }