public override bool CompareTargetDataToDb(string key, string fileName = null, Table tableData = null, TestDataResultOperationType operationType = default) { var featureTestData = GenerateDataFromTable(tableData); var fileTestData = GenerateDataFromFile(fileName, key); var allBreaks = _breakRepository.GetAll().ToList(); switch (operationType) { case TestDataResultOperationType.Add: { featureTestData.AddRange(fileTestData); if (allBreaks.Count != featureTestData.Count) { return(false); } foreach (var entity in featureTestData) { if (allBreaks.Count(c => c.ExternalBreakRef == entity.ExternalBreakRef) != 1) { return(false); } var storedBreak = allBreaks.FirstOrDefault(c => c.ExternalBreakRef == entity.ExternalBreakRef); if (!CompareBreak(entity, storedBreak)) { return(false); } } var resultSchedules = TestDataImporter.GetDataFromFile <Schedule>(fileName, "Schedules").ToList(); var allSchedules = _scheduleRepository.GetAll().ToList(); if (allSchedules.Count != resultSchedules.Count) { return(false); } foreach (var schedule in resultSchedules) { var storedSchedule = allSchedules.FirstOrDefault(c => c.SalesArea == schedule.SalesArea && c.Date == schedule.Date); var storedRefs = storedSchedule.Breaks.Select(b => b.ExternalBreakRef).OrderBy(b => b); var targetRefs = schedule.Breaks.Select(b => b.ExternalBreakRef).OrderBy(b => b); if (!storedRefs.SequenceEqual(targetRefs)) { return(false); } } var resultSpots = TestDataImporter.GetDataFromFile <Schedule>(fileName, "Spots").ToList(); var allSpots = _spotRepository.GetAll(); return(allSpots.Count() == resultSpots.Count); } default: return(false); } }
public Dictionary <string, int> Get() { var breakcount = _breakrepo.GetAll().Count(); var spotCountcount = _spotrepo.GetAll().Count(); var progcount = _programmerepo.GetAll().Count(); var campaigncount = _campaignrepo.GetAll().Count(); var productcount = _productRepository.GetAll().Count(); var clashcount = _clashRepository.GetAll().Count(); var items = new Dictionary <string, int> { { "Breaks", breakcount }, { "Spots", spotCountcount }, { "Programmes", progcount }, { "Campaigns", campaigncount }, { "Product", productcount }, { "Clash", clashcount } }; return(items); }
/// <summary> /// Creates recommendations data /// </summary> /// <param name="numberOfSpots">Number of spots to generate data for</param> /// <returns></returns> public List <Recommendation> Create(int numberOfSpots) { var recommendations = new List <Recommendation>(); _random = new Random(); DateTime processorDateTime = DateTime.UtcNow; // Load data var spots = _spotRepository.GetAll(); // Doesn't actually return all var salesAreas = _salesAreaRepository.GetAll(); var programmes = _programmeRepository.GetAll(); // Doesn't actually return all numberOfSpots = (numberOfSpots > spots.ToList().Count ? spots.ToList().Count : numberOfSpots); // If insufficient spots then return max number if (!spots.Any()) { throw new ArgumentException("Cannot generate fake recommendations data because there are no spots in the database"); } if (!programmes.Any()) { throw new ArgumentException("Cannot generate fake recommendations data because there are no programmes in the database"); } // Add data for each spot int programmeIndex = -1; for (int spotIndex = 0; spotIndex < numberOfSpots; spotIndex++) { programmeIndex++; programmeIndex = (programmeIndex >= programmes.ToList().Count - 1 ? 0 : programmeIndex); var spot = spots.ToList()[spotIndex]; var salesArea = salesAreas.Where(x => x.Name.Equals(spot.SalesArea)).First(); var programme = programmes.ToList()[++programmeIndex]; recommendations.Add(CreateRecommendation(spots.ToList()[spotIndex], salesArea, programme, processorDateTime)); } return(recommendations); }
public List <Spot> GetAll() { return(_spotRepository.GetAll()); }
public IEnumerable <Spot> Get() { var spots = _repository.GetAll(); return(spots); }
public IEnumerable <Spot> GetAll() => _repository.GetAll();