static void Main(string[] args) { //Show error message if all arguments are not passed. if (args.Length < 2) { Console.WriteLine(Constants.Messages.INVALID_ARGS); return; } //Try to obtain source instance based on input source type. IProductSource source = ProductSourceFactory.GetProductSource(args[0].ToLower()); if (source != null) { //Try to parse the input file, and display contents or error if parsing fails. try { source.ParseFile(args[1]); } catch (Exception ex) { Console.WriteLine(Constants.Messages.PARSE_FAILED + ex.Message); } } //Specified source not found/implemented. else { Console.WriteLine(Constants.Messages.INVALID_SOURCE); } }
public void SumByPagingTest_column_sell_price_paging_3_should_3_6_9() { IProductSource source = Substitute.For <IProductSource>(); ColumnType columnType = ColumnType.SellPrice; int paging = 3; source.GetSource().ReturnsForAnyArgs(_products); List <int> expected = new List <int> { 3, 6, 9 }; PagingHelper helper = new PagingHelper(source); List <int> actual = helper.SumByPaging(columnType, paging); CollectionAssert.AreEquivalent(expected, actual); }
public void SumByPagingTest_column_cost_paging_2_should_1_1_1_2_1() { IProductSource source = Substitute.For <IProductSource>(); ColumnType columnType = ColumnType.Cost; int paging = 2; source.GetSource().ReturnsForAnyArgs(_products); List <int> expected = new List <int> { 1, 1, 1, 2, 1 }; PagingHelper helper = new PagingHelper(source); List <int> actual = helper.SumByPaging(columnType, paging); CollectionAssert.AreEquivalent(expected, actual); }
public PagingHelper(IProductSource source) { _source = source; }