public void GivenDataSourceReader_WhenReadingValidDataSourceWithHeader_ThenReturnsList()
        {
            var dataSourceMock = Mock.Of <SalesCSVDataSource>(x => x.Name == "sales.csv" &&
                                                              x.HasHeaderRecord == true
                                                              );

            var list = _datasourceReader.Read(dataSourceMock);

            Assert.That(list, Is.Not.Null);
            Assert.That(list, Is.Not.Empty);
        }
        public IEnumerable <Sales> ReadSalesData(IDataSource dataSource, bool enforceBusinessRules)
        {
            //Parse
            var sales = _datasourceReader.Read(dataSource);

            if (enforceBusinessRules) //Validate Data
            {
                _validationService.Validate(sales);

                _errors = new List <Log>();
                foreach (var sale in sales.Where(x => !x.IsValid))
                {
                    _errors.Add(new Log {
                        LineNumber = sale.LineNumber,
                        Message    = $"Sales : Validation Error found on record on Line {sale.LineNumber}/ Row {sale.RowID} with Order {sale.OrderId} from Customer {sale.CustomerID} : {sale.CustomerName}."
                    });
                }
            }

            return(sales);
        }