public ScenarioCampaignResultsFileProcessorTest() { _mockAuditEventRepository = new Mock <IAuditEventRepository>(); _mockSalesAreaRepository = new Mock <ISalesAreaRepository>(); _context = new RunWithScenarioReference(Guid.NewGuid(), Guid.NewGuid()); var dataSnapshot = new Mock <IOutputDataSnapshot>(); int id = 1; _dummySalesArea = _fixture .Build <SalesArea>() .Do(s => s.CustomId = id++) .CreateMany(5); _ = _mockSalesAreaRepository.Setup(m => m.GetAll()).Returns(_dummySalesArea); _ = dataSnapshot.Setup(x => x.AllSalesAreas) .Returns(new Lazy <IEnumerable <SalesArea> >(_mockSalesAreaRepository.Object.GetAll)); var importSettings = CSVImportSettings.GetImportSettings( Path.Combine(TestRootDataFolder, "lmkii_scen_camp_reqm_summ.csv"), typeof(ScenarioCampaignResultHeaderMap), typeof(ScenarioCampaignResultIndexMap) ); var scenarioCampaignResultsImportRepository = new CSVScenarioCampaignResultsImportRepository(importSettings); _expectedItems = scenarioCampaignResultsImportRepository.GetAll(); _processor = new ScenarioCampaignResultsFileProcessor(dataSnapshot.Object, _mockAuditEventRepository.Object); }
public KPICalculationContext(IOutputDataSnapshot snapshot, RunWithScenarioReference runWithScenario) { ScenarioId = runWithScenario.ScenarioId; Snapshot = snapshot; ActiveCampaigns = new Lazy <IEnumerable <Campaign> >(GetActiveCampaigns, true); CampaignMetrics = new Lazy <IDictionary <string, IEnumerable <RecommendationsByScenarioReduceResult> > >(GetCampaignMetrics, true); SmoothCampaigns = new Lazy <IEnumerable <Campaign> >(GetSmoothCampaigns, true); }
public OutputImmutableDataSnapshot(RunWithScenarioReference runWithScenarioRef, IRunRepository runRepository, IScenarioRepository scenarioRepository, IPassRepository passRepository, ICampaignRepository campaignRepository, IScheduleRepository scheduleRepository, ISalesAreaRepository salesAreaRepository, IDemographicRepository demographicRepository, IProgrammeDictionaryRepository programmeDictionaryRepository, ISpotRepository spotRepository, IMetadataRepository metadataRepository) { var runStartDate = new Lazy <DateTime>(() => Run.Value.StartDate.Add(Run.Value.StartTime)); var runEndDate = new Lazy <DateTime>(() => DateHelper.ConvertBroadcastToStandard(Run.Value.EndDate, Run.Value.EndTime)); Run = new Lazy <Run>(() => runRepository.Find(runWithScenarioRef.RunId)); Scenario = new Lazy <Scenario>(() => scenarioRepository.Get(runWithScenarioRef.ScenarioId), true); ScenarioPasses = new Lazy <IEnumerable <Pass> >(() => passRepository.FindByScenarioId(runWithScenarioRef.ScenarioId), true); AllCampaigns = new Lazy <IEnumerable <Campaign> >(campaignRepository.GetAll, true); AllSalesAreas = new Lazy <IEnumerable <SalesArea> >(salesAreaRepository.GetAll, true); AllDemographics = new Lazy <IEnumerable <Demographic> >(demographicRepository.GetAll, true); AllProgrammeDictionaries = new Lazy <IEnumerable <ProgrammeDictionary> >(programmeDictionaryRepository.GetAll, true); BreakTypes = new Lazy <IEnumerable <string> >(() => metadataRepository.GetByKey(MetaDataKeys.BreakTypes).Select(e => (string)e.Value)); SpotsForRun = new Lazy <IEnumerable <Spot> >(() => { var salesAreaPriorities = Run.Value.SalesAreaPriorities.Count == 0 ? AllSalesAreas.Value : AllSalesAreas.Value.Where(sa => Run.Value.SalesAreaPriorities.Find(rsa => rsa.SalesArea == sa.Name) != null); return(spotRepository.Search( runStartDate.Value, runEndDate.Value, salesAreaPriorities.Select(sa => sa.Name).ToList() )); }, true ); BreaksForRun = new Lazy <IEnumerable <BreakSimple> >(() => scheduleRepository.GetScheduleSimpleBreaks( AllSalesAreas.Value.Select(c => c.Name).ToList(), runStartDate.Value, runEndDate.Value ), true ); }