static void Main(string[] args) { try { Console.WriteLine("Gilded Rose Daily Stock Update, (Version 1.0)"); if (args.Length > 0) { if (args.Length == 2) { DataAccessFactory.InputFileName = args[0]; DataAccessFactory.OutputFileName = args[1]; } else if (args.Length == 1) { DataAccessFactory.InputFileName = args[0]; } else { throw new Exception("Invalid Command Line Usage: GuildedRoseApplication <inputpath> <outpath> "); } } Console.WriteLine("\nPreparing to Process:"); Console.WriteLine("\nInput Data:"); using (var reader = new System.IO.StreamReader(DataAccessFactory.InputFileName)) { while (!reader.EndOfStream) { Console.WriteLine(reader.ReadLine()); } } Console.WriteLine("\nProcessing:"); var updater = new DailyStockUpdater(); updater.Execute(); Console.WriteLine("\nRead " + updater.ReadCount); Console.WriteLine("Processed " + updater.WriteCount); Console.WriteLine("\nOutput: "); using (var reader = new System.IO.StreamReader(DataAccessFactory.OutputFileName)) { while (!reader.EndOfStream) { Console.WriteLine(reader.ReadLine()); } } Console.WriteLine("\n\nDone!"); } catch (Exception e) { // for testing purposes this will simply write to console but in theory the error should be logged along with others and reported in the // correct way for such ErrorLogger.LogError(e.Message); } }
public void TestAssumption_WithTestAccess_AllReferenceSingleObject() { // Singlet Tests rely on this being true StockItem item = new StockItem() { Name = "Factory Test", SellIn = 1, Quality = new StockQuality(1) }; DataAccessFactory.TestItem = item; var updater = new DailyStockUpdater(); updater.Execute(); Assert.AreSame(DataAccessFactory.TestItem, item); }