public void ArgumentParsingTest(string appName, string generateFlag) { ConsoleAppBase app = (ConsoleAppBase)FactoryConsoleApplication.CreateConsoleApplicationObject(appName); OptionSet opt = app.CreateOptionSet(); opt.Parse(args); if (!generateFlag.Equals("")) { app.AddArgument("generate", generateFlag); h.Add("generate", generateFlag); } Hashtable values = app.GetArguments(); foreach (string key in values.Keys) { string value = (string)values[key]; Assert.AreEqual(h[key].ToString(), value, "Arguments parsing incorrect!!!"); } //Assert.AreEqual(h.Count, values.Count, "Number of argument parsed is incorrect!!!"); //Test to cover code coverage app.DumpParameter(); }
public void ExecuteTest() { ConsoleAppBase app = (ConsoleAppBase)FactoryConsoleApplication.CreateConsoleApplicationObject("BarcodeMigrate"); MBarcode existingData = new MBarcode(); Mock <INoSqlContext> mockCtx = new Mock <INoSqlContext>(); mockCtx.Setup(foo => foo.GetObjectByKey <MBarcode>("barcodes/8/0/5/2/1/5/8059699639/2154237147")).Returns(existingData); INoSqlContext ctx = mockCtx.Object; app.SetNoSqlContext(ctx); ILogger logger = new Mock <ILogger>().Object; app.SetLogger(logger); OptionSet opt = app.CreateOptionSet(); opt.Parse(args); createInputFile((String)h["infile"]); int result = app.Run(); Assert.AreEqual(0, result); }