public static void Main(string[] args) { View.UserInput input = null; try { input = new View.UserInput(args); } catch (Exception e) { Console.Out.WriteLine(e.Message); System.Environment.Exit(1); } try { Controller.Printer printer = new Controller.Printer(input); printer.print(); Console.Out.WriteLine("Press any key to exit"); Console.ReadKey(); } catch (Exception e) { Console.Error.WriteLine(e.Message); System.Environment.Exit(1); } }
private void checkValidOptions(NameValueCollection options) { List<string> argsList = new List<string>(); foreach (string key in options.AllKeys) { argsList.Add(key); argsList.Add(options.Get(key)); } string[] args = argsList.ToArray(); UserInput input = new UserInput(args); Assert.IsTrue(input.Options.Count == options.Count); foreach (string key in options.AllKeys) { Assert.IsNotNull(input.Options[key]); Assert.IsTrue(input.Options[key].Equals(options.Get(key))); } }
private void checkValidArgs(string[] args) { bool caughtError = false; UserInput input = null; try { input = new UserInput(args); } catch (Exception e) { caughtError = true; } Assert.IsFalse(caughtError); Assert.IsTrue(input.Options["feedIdentifier"] != null); }
private void checkInvalidArgs(string[] args) { // This method will prevent developer from casually changing usage // Usage is very user visible and must be constructed carefully and // not changed without reason. If usage is changed, this unit test // must be modified to check new usage. bool caughtError = false; try { UserInput input = new UserInput(args); } catch (Exception e) { string message = e.Message; string expectedMessage = expectedUsage + expectedHelp; Assert.IsTrue(e.Message.Equals(expectedUsage + expectedHelp)); caughtError = true; } Assert.IsTrue(caughtError); }