public async Task RunAsync(string[] args) { Logger.LogInformation("ABP CLI (https://abp.io)"); #if !DEBUG if (!commandLineArgs.Options.ContainsKey("skip-cli-version-check")) { await CheckCliVersionAsync(); } #endif var commandLineArgs = CommandLineArgumentParser.Parse(args); try { if (commandLineArgs.IsCommand("batch")) { await RunBatchAsync(commandLineArgs); } else { await RunInternalAsync(commandLineArgs); } } catch (CliUsageException usageException) { Logger.LogWarning(usageException.Message); } catch (Exception ex) { Logger.LogException(ex); } }
public int getMail(string[] args, bool isHash) { //命令解析器 int EmlCount = 0; arguments = CommandLineArgumentParser.Parse(args); if (isHash) { string url = arguments.Get("-url").Next; string username = arguments.Get("-username").Next; string hash = arguments.Get("-hash").Next; this.Mail = new Mail(url, username, hash, ExchangeVersion.Exchange2013); } else { string url = arguments.Get("-url").Next; string username = arguments.Get("-username").Next; string password = arguments.Get("-password").Next; this.Mail = new Mail(url, username, password); } string path = ""; if (arguments.Get("-GetMail").Next.ToString().Equals("ALL")) { path = mail.Path + "\\folderEmails" + Util.convertFromDate(DateTime.Now); } else { path = mail.Path + "\\folderEmails" + arguments.Get("-GetMail").Next.ToString(); } EmlCount = GetMailBY(args, path); return(EmlCount); }
private async Task RunBatchAsync(CommandLineArgs commandLineArgs) { var targetFile = commandLineArgs.Target; if (targetFile.IsNullOrWhiteSpace()) { throw new CliUsageException( "Must provide a file name/path that contains a list of commands" + Environment.NewLine + Environment.NewLine + "Example: " + " abp batch commands.txt" ); } var filePath = Path.Combine(Directory.GetCurrentDirectory(), targetFile); var fileLines = File.ReadAllLines(filePath); foreach (var line in fileLines) { var lineText = line; if (lineText.IsNullOrWhiteSpace() || lineText.StartsWith("#")) { continue; } if (lineText.Contains('#')) { lineText = lineText.Substring(0, lineText.IndexOf('#')); } var args = CommandLineArgumentParser.Parse(lineText); await RunInternalAsync(args); } }
public static void workWithListFile(string[] args) { var argument = CommandLineArgumentParser.Parse(args); string[] urls = null; Entities.Processor psr = null; if (argument.Has("-l")) { var listfile = argument.Get("-l").Next; urls = System.IO.File.ReadAllLines(listfile); } if (argument.Has("-p")) { var psrfile = argument.Get("-p").Next; psr = Tools.Serializer.DeSerializePSR(psrfile); } StringBuilder sb = new StringBuilder(); foreach (var url in urls) { var htmlt = Tools.DownLoader.GetDocument(url); var f1 = Tools.Scraper.Scrape(htmlt, psr); Console.WriteLine(DateTime.Now.ToString() + " GET:" + f1.Count); foreach (var item in f1) { sb.AppendLine(url + "\t" + item); } } System.IO.File.WriteAllText("taskFromListfile.txt", sb.ToString()); System.Windows.Forms.MessageBox.Show("OK!"); }
static int Main(string[] args) { var parser = new CommandLineArgumentParser(typeof(CommandArgs), new ErrorReporter(Console.Error.WriteLine)); var cmdArgs = new CommandArgs(); if (!parser.Parse(args, cmdArgs)) { Console.Write(CommandLineUtility.CommandLineArgumentsUsage(typeof(CommandArgs))); return(-1); } string appManifestPath = cmdArgs.ApplicationManifestPath; List <string> serviceManifestPaths = new List <string>(cmdArgs.ServiceManifestPathList.Split(';')); AppManifestCleanupUtil util = new AppManifestCleanupUtil(); List <string> appParamFilePaths = null; if (cmdArgs.ApplicationParametersFilePathList != null) { appParamFilePaths = new List <string>(cmdArgs.ApplicationParametersFilePathList.Split(';')); } util.CleanUp(appManifestPath, serviceManifestPaths, appParamFilePaths); return(0); }
public async Task RunAsync(string[] args) { Logger.LogInformation("ABP CLI (https://abp.io)"); await CheckCliVersionAsync(); var commandLineArgs = CommandLineArgumentParser.Parse(args); var commandType = CommandSelector.Select(commandLineArgs); using (var scope = ServiceScopeFactory.CreateScope()) { var command = (IConsoleCommand)scope.ServiceProvider.GetRequiredService(commandType); try { await command.ExecuteAsync(commandLineArgs); } catch (CliUsageException usageException) { Logger.LogWarning(usageException.Message); } catch (Exception ex) { Logger.LogException(ex); } } }
public static void Main(string[] args) { var parser = CommandLineArgumentParser.Parse(args); var p = parser.Get("--urls"); var urls = p == null ? "" : p.Next; //CreateWebHostBuilder(args).Build().Run(); IConfiguration cfg = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddEnvironmentVariables(evs => { }) //.AddCommandLine() .AddJsonFile("appsettings.json", true, true) .Build(); var builder = new WebHostBuilder() .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) //.UseIISIntegration() //.UseUrls(bindUrl) .UseStartup <Startup>() .UseConfiguration(cfg); if (urls.IsNotNullOrEmpty()) { builder.UseUrls(urls); } //CreateWebHostBuilder(args).Build var host = builder.Build(); host.Run(); }
public int searchMail(string[] args, bool isHash) { //命令解析器 arguments = CommandLineArgumentParser.Parse(args); int EmlCount = 0; if (isHash) { string url = arguments.Get("-url").Next; string username = arguments.Get("-username").Next; string hash = arguments.Get("-hash").Next; this.Mail = new Mail(url, username, hash, ExchangeVersion.Exchange2013); } else { string url = arguments.Get("-url").Next; string username = arguments.Get("-username").Next; string password = arguments.Get("-password").Next; this.Mail = new Mail(url, username, password); } //根据参数得到过滤条件 List <SearchFilter> filterList = getSearchFilterList(args); Dictionary <string, string> map = getFilterMap("-Search"); string path = mail.Path + "\\" + getPartPath(map); if (map["ToRecipien"] == null || !map["ToRecipien"].Equals("") || map["ToRecipien"].Equals(" ")) { EmlCount = mail.searchMail(filterList, path); } else { EmlCount = mail.searchMailByToRecipient(filterList, map["ToRecipien"], path); } return(EmlCount); }
public void Integer() { var args = new string[] { }; var result = CommandLineArgumentParser.Parse <DefaultValuesOptions>(args); result.ParsedOptions.Number.Should().Be(12345); result.Result.Should().Be(OptionsResult.Success); }
public void BooleanFalse() { var args = new string[] { }; var result = CommandLineArgumentParser.Parse <DefaultValuesOptions>(args); result.ParsedOptions.BooleanFalse.Should().BeFalse(); result.Result.Should().Be(OptionsResult.Success); }
public void StringNull() { var args = new string[] {}; var result = CommandLineArgumentParser.Parse <DefaultValuesOptions>(args); result.ParsedOptions.TextNull.Should().BeNull(); result.Result.Should().Be(OptionsResult.Success); }
public void CommandParsedTest() { CommandLineArguments Expected = new CommandLineArguments { Command = "push" }; CommandLineArguments Actual = CommandLineArgumentParser.Parse(ParseCommandLine("push")); Assert.AreEqual(Expected.Command, Actual.Command); }
public void ThenSetsLanguageToEnglishByDefault() { var args = new[] { "" }; var configuration = new Configuration(); var commandLineArgumentParser = new CommandLineArgumentParser(FileSystem); bool shouldContinue = commandLineArgumentParser.Parse(args, configuration, TextWriter.Null); Check.That(configuration.Language).IsEqualTo("en"); }
public void ParseDuplicatedArgument(string arg1, string arg2) { string errorMsg = string.Empty; MainArguments arguments = new MainArguments(); CommandLineArgumentParser parser = new CommandLineArgumentParser(arguments.GetType()); Assert.AreEqual(false, parser.Parse(new string[] { arg1, arg2 }, arguments, delegate(string message) { errorMsg = message; })); Assert.AreEqual("Duplicate 'help' argument.", errorMsg); }
public void ParseInvalidValueForBooleanArgument() { string errorMsg = string.Empty; MainArguments arguments = new MainArguments(); CommandLineArgumentParser parser = new CommandLineArgumentParser(arguments.GetType()); Assert.AreEqual(false, parser.Parse(new string[] { "/help:bad" }, arguments, delegate(string message) { errorMsg = message; })); Assert.AreEqual("Invalid 'help' argument value 'bad'.", errorMsg); }
public void ParseInvalidArgument(string arg) { string errorMsg = string.Empty; MainArguments arguments = new MainArguments(); CommandLineArgumentParser parser = new CommandLineArgumentParser(arguments.GetType()); Assert.AreEqual(false, parser.Parse(new string[] { arg }, arguments, delegate(string message) { errorMsg = message; })); Assert.AreEqual(string.Format("Unrecognized argument '{0}'.", arg), errorMsg); }
public void ThenCanParseResultsFormatSpecrunWithLongFormSuccessfully() { var args = new[] { @"-test-results-format=specrun" }; var configuration = new Configuration(); var commandLineArgumentParser = new CommandLineArgumentParser(FileSystem); bool shouldContinue = commandLineArgumentParser.Parse(args, configuration, TextWriter.Null); shouldContinue.ShouldBeTrue(); Assert.AreEqual(TestResultsFormat.SpecRun, configuration.TestResultsFormat); }
public void ThenCanParseResultsFormatCucumberJsonWithShortFormSuccessfully() { var args = new[] { @"-trfmt=cucumberjson" }; var configuration = new Configuration(); var commandLineArgumentParser = new CommandLineArgumentParser(FileSystem); bool shouldContinue = commandLineArgumentParser.Parse(args, configuration, TextWriter.Null); shouldContinue.ShouldBeTrue(); Assert.AreEqual(TestResultsFormat.CucumberJson, configuration.TestResultsFormat); }
public void Then_can_parse_results_format_nunit_with_short_form_successfully() { var args = new string[] { @"-trfmt=nunit" }; var configuration = new Configuration(); var commandLineArgumentParser = new CommandLineArgumentParser(); bool shouldContinue = commandLineArgumentParser.Parse(args, configuration, TextWriter.Null); Assert.AreEqual(true, shouldContinue); Assert.AreEqual(TestResultsFormat.NUnit, configuration.TestResultsFormat); }
public void ThenCanParseExcludeTagsSuccessfully() { var args = new[] { @"-excludeTags=exclude-tag" }; var configuration = new Configuration(); var commandLineArgumentParser = new CommandLineArgumentParser(FileSystem); bool shouldContinue = commandLineArgumentParser.Parse(args, configuration, TextWriter.Null); Check.That(shouldContinue).IsTrue(); Check.That(configuration.ExcludeTags).IsEqualTo("exclude-tag"); }
public void ThenCanParseResultsFormatMstestWithLongFormSuccessfully() { var args = new[] { @"-test-results-format=mstest" }; var configuration = new Configuration(); var commandLineArgumentParser = new CommandLineArgumentParser(); bool shouldContinue = commandLineArgumentParser.Parse(args, configuration, TextWriter.Null); Assert.AreEqual(true, shouldContinue); Assert.AreEqual(TestResultsFormat.MsTest, configuration.TestResultsFormat); }
public void ThenCanParseExcelDocumentationFormatWithShortFormSuccessfully() { var args = new[] { @"-df=excel" }; var configuration = new Configuration(); var commandLineArgumentParser = new CommandLineArgumentParser(); bool shouldContinue = commandLineArgumentParser.Parse(args, configuration, TextWriter.Null); shouldContinue.ShouldBeTrue(); configuration.DocumentationFormat.ShouldEqual(DocumentationFormat.Excel); }
public void ThenCanParseResultsFormatXunitWithShortFormSuccessfully() { var args = new[] { @"-trfmt=xunit" }; var configuration = new Configuration(); var commandLineArgumentParser = new CommandLineArgumentParser(); bool shouldContinue = commandLineArgumentParser.Parse(args, configuration, TextWriter.Null); Assert.AreEqual(true, shouldContinue); Assert.AreEqual(TestResultsFormat.xUnit, configuration.TestResultsFormat); }
public static void Main(string[] args) { var arguments = CommandLineArgumentParser.Parse(args); int workers = 0; if (arguments.Has("-w")) { Console.WriteLine("Workers:{0}", arguments.Get("-w").Next); int.TryParse(arguments.Get("-w").Next.ToString(), out workers); } // 获取第一个参数为编译使用Hyoka的项目生成的dll,从中获取Hyoka实例。 // 反射加载这个类,获取其中的方法信息。 // 例如 Hyoka.exe Sample -w 4 if (arguments.Get(0) != null && !arguments.Get(0).ToString().Contains("-")) { // 仅需要输入编译生成的dll名称,例如Sample var hyoka_str = arguments.Get(0).ToString(); Console.WriteLine($"===>>{ hyoka_str}"); // 需将Hyoka.exe和Hyoka.dll放置在项目生成运行目录下 if (File.Exists($".\\{ hyoka_str }.dll")) { string path = System.Environment.CurrentDirectory; Assembly hyoka_assem = Assembly.LoadFile($"{ path }\\{ hyoka_str }.dll"); Type[] hyoka_types = hyoka_assem.GetTypes(); Hyoka hyoka_instance = null; foreach (var type in hyoka_types) { if (type.BaseType.Name.Equals(nameof(Config))) { //var instance = Activator.CreateInstance(type); var property = type.GetField("Hyoka").GetValue(null); if (property != null) { hyoka_instance = property as Hyoka; } } } if (hyoka_instance == null) { throw new Exception("Hyoka instance is not initialize"); } // 测试一下 hyoka_instance.Loop(); } else { throw new Exception("The task class dll file or hyoka instance file is not exist."); } } else { throw new Exception("Please set a correct command parameter with position zero."); } }
public void ThenCanParseExcelDocumentationFormatWithShortFormSuccessfully() { var args = new[] { @"-df=excel" }; var configuration = new Configuration(); var commandLineArgumentParser = new CommandLineArgumentParser(FileSystem); bool shouldContinue = commandLineArgumentParser.Parse(args, configuration, TextWriter.Null); Check.That(shouldContinue).IsTrue(); Check.That(configuration.DocumentationFormat).IsEqualTo(DocumentationFormat.Excel); }
private void ThenCanParseResultsFormatSuccessfully(string argumentName, string argument, TestResultsFormat expectedResultsFormat) { var args = new[] { argumentName + argument }; var configuration = new Configuration(); var commandLineArgumentParser = new CommandLineArgumentParser(FileSystem); bool shouldContinue = commandLineArgumentParser.Parse(args, configuration, TextWriter.Null); Check.That(shouldContinue).IsTrue(); Check.That(configuration.TestResultsFormat).IsEqualTo(expectedResultsFormat); }
public void RequiredMandatoryMissing_ResultNo() { var args = new string[] { }; var parse = CommandLineArgumentParser.Parse <RequiredFieldsOptions>(args); parse.Result.Should().Be(OptionsResult.MissingRequiredArgument); parse.MissingRequiredOptions.Count.Should().Be(2); parse.MissingRequiredOptions.First().Should().Be("requiredtext"); parse.MissingRequiredOptions.Last().Should().Be("namba"); }
public void ThenCanParseResultsFormatSpecrunWithShortFormSuccessfully() { var args = new[] { @"-trfmt=specrun" }; var configuration = new Configuration(); var commandLineArgumentParser = new CommandLineArgumentParser(FileSystem); bool shouldContinue = commandLineArgumentParser.Parse(args, configuration, TextWriter.Null); Check.That(shouldContinue).IsTrue(); Check.That(configuration.TestResultsFormat).IsEqualTo(TestResultsFormat.SpecRun); }
public void ThenCanParseResultsFormatCucumberJsonWithLongFormSuccessfully() { var args = new[] { @"-test-results-format=cucumberjson" }; var configuration = new Configuration(); var commandLineArgumentParser = new CommandLineArgumentParser(FileSystem); bool shouldContinue = commandLineArgumentParser.Parse(args, configuration, TextWriter.Null); Check.That(shouldContinue).IsTrue(); Check.That(configuration.TestResultsFormat).IsEqualTo(TestResultsFormat.CucumberJson); }
public void ThenCanParseExcelDocumentationFormatWithShortFormSuccessfully() { var args = new[] { @"-df=excel" }; var configuration = new Configuration(); var commandLineArgumentParser = new CommandLineArgumentParser(FileSystem); bool shouldContinue = commandLineArgumentParser.Parse(args, configuration, TextWriter.Null); Check.That(shouldContinue).IsTrue(); Check.That(configuration.DocumentationFormat).IsEqualTo(DocumentationFormat.Excel); }
public void IntegerArray() { var args = new string[] { }; var result = CommandLineArgumentParser.Parse <DefaultValuesOptions>(args); result.ParsedOptions.NumberArray.Length.Should().Be(2); result.ParsedOptions.NumberArray[0].Should().Be(1); result.ParsedOptions.NumberArray[1].Should().Be(25); result.Result.Should().Be(OptionsResult.Success); }
public void StringArray() { var args = new string[] { }; var result = CommandLineArgumentParser.Parse <DefaultValuesOptions>(args); result.ParsedOptions.TextArray.Length.Should().Be(2); result.ParsedOptions.TextArray[0].Should().Be("Default1"); result.ParsedOptions.TextArray[1].Should().Be("Default2"); result.Result.Should().Be(OptionsResult.Success); }
public void ThenCanParseExcelDocumentationFormatWithLongFormSuccessfully() { var args = new[] {@"-documentation-format=excel"}; var configuration = new Configuration(); var commandLineArgumentParser = new CommandLineArgumentParser(FileSystem); bool shouldContinue = commandLineArgumentParser.Parse(args, configuration, TextWriter.Null); shouldContinue.ShouldBeTrue(); configuration.DocumentationFormat.ShouldEqual(DocumentationFormat.Excel); }
public void ThenCanFilterOutNonExistingTestResultFiles() { var args = new[] { @"-link-results-file=c:\DoesNotExist.xml;" }; var configuration = new Configuration(); var commandLineArgumentParser = new CommandLineArgumentParser(FileSystem); bool shouldContinue = commandLineArgumentParser.Parse(args, configuration, TextWriter.Null); shouldContinue.ShouldBeTrue(); configuration.HasTestResults.ShouldBeFalse(); Assert.AreEqual(0, configuration.TestResultsFiles.Count()); }
static void Main(string[] args) { //Basic parsing of arguments for now var parser = new CommandLineArgumentParser(); parser.Parse(args); //Create a cloak manager var manager = new CloakManager(); //Create a cloaking context var cloakContext = new CloakContext(parser.Settings); //Run the manager manager.Run(cloakContext); }
public void ThenCanParseHelpRequestWithLongFormSuccessfully() { var args = new[] { @"--help" }; var configuration = new Configuration(); var writer = new StringWriter(); var commandLineArgumentParser = new CommandLineArgumentParser(FileSystem); bool shouldContinue = commandLineArgumentParser.Parse(args, configuration, writer); StringAssert.Contains(expectedHelpString.ComparisonNormalize(), writer.GetStringBuilder().ToString().ComparisonNormalize()); shouldContinue.ShouldBeFalse(); }
public void Then_can_parse_long_form_arguments_successfully() { var args = new string[] { @"--feature-directory=c:\features", @"--output-directory=c:\features-output" }; var configuration = new Configuration(); var commandLineArgumentParser = new CommandLineArgumentParser(); bool shouldContinue = commandLineArgumentParser.Parse(args, configuration, TextWriter.Null); Assert.AreEqual(true, shouldContinue); Assert.AreEqual(@"c:\features", configuration.FeatureFolder.FullName); Assert.AreEqual(@"c:\features-output", configuration.OutputFolder.FullName); Assert.AreEqual(false, configuration.HasTestResults); Assert.AreEqual(null, configuration.TestResultsFile); }
public void ThenCanParseHelpRequestWithLongFormSuccessfully() { var args = new[] { @"--help" }; var configuration = new Configuration(); var writer = new StringWriter(); var commandLineArgumentParser = new CommandLineArgumentParser(FileSystem); bool shouldContinue = commandLineArgumentParser.Parse(args, configuration, writer); var actual = RetrieveString(writer); Check.That(actual).Contains(ExpectedHelpString.ComparisonNormalize()); Check.That(shouldContinue).IsFalse(); }
public void Then_can_parse_help_request_with_short_form_successfully() { var args = new string[] { @"-h" }; var configuration = new Configuration(); var writer = new StringWriter(); var commandLineArgumentParser = new CommandLineArgumentParser(); bool shouldContinue = commandLineArgumentParser.Parse(args, configuration, writer); StringAssert.Contains(expectedHelpString, writer.GetStringBuilder().ToString().Trim()); Assert.AreEqual(false, shouldContinue); Assert.AreEqual(Path.GetFullPath(Directory.GetCurrentDirectory()), configuration.FeatureFolder.FullName); Assert.AreEqual(Path.GetFullPath(Environment.GetEnvironmentVariable("TEMP")), configuration.OutputFolder.FullName); Assert.AreEqual(false, configuration.HasTestFrameworkResults); Assert.AreEqual(null, configuration.LinkedTestFrameworkResultsFile); }
public void ThenCanParseHelpRequestWithLongFormSuccessfully() { var args = new[] {@"--help"}; var configuration = new Configuration(); var writer = new StringWriter(); var commandLineArgumentParser = new CommandLineArgumentParser(FileSystem); bool shouldContinue = commandLineArgumentParser.Parse(args, configuration, writer); StringAssert.Contains(expectedHelpString.ComparisonNormalize(), writer.GetStringBuilder().ToString().ComparisonNormalize()); Assert.AreEqual(false, shouldContinue); Assert.AreEqual(Path.GetFullPath(Directory.GetCurrentDirectory()), configuration.FeatureFolder.FullName); Assert.AreEqual(Path.GetFullPath(Directory.GetCurrentDirectory()), configuration.OutputFolder.FullName); Assert.AreEqual(false, configuration.HasTestResults); Assert.AreEqual(null, configuration.TestResultsFile); }
public void ThenCanParseResultsFileWithShortFormSuccessfully() { FileSystem.AddFile(@"c:\results.xml", "<xml />"); var args = new[] { @"-lr=c:\results.xml" }; var configuration = new Configuration(); var commandLineArgumentParser = new CommandLineArgumentParser(FileSystem); bool shouldContinue = commandLineArgumentParser.Parse(args, configuration, TextWriter.Null); Check.That(shouldContinue).IsTrue(); Check.That(configuration.HasTestResults).IsTrue(); Check.That(configuration.TestResultsFile.FullName).IsEqualTo(@"c:\results.xml"); }
public void ThenCanParseResultsFormatCucumberJsonWithShortFormSuccessfully() { var args = new[] { @"-trfmt=cucumberjson" }; var configuration = new Configuration(); var commandLineArgumentParser = new CommandLineArgumentParser(FileSystem); bool shouldContinue = commandLineArgumentParser.Parse(args, configuration, TextWriter.Null); shouldContinue.ShouldBeTrue(); Assert.AreEqual(TestResultsFormat.CucumberJson, configuration.TestResultsFormat); }
public void ThenCanParseResultsFormatSpecrunWithLongFormSuccessfully() { var args = new[] { @"-test-results-format=specrun" }; var configuration = new Configuration(); var commandLineArgumentParser = new CommandLineArgumentParser(FileSystem); bool shouldContinue = commandLineArgumentParser.Parse(args, configuration, TextWriter.Null); shouldContinue.ShouldBeTrue(); Assert.AreEqual(TestResultsFormat.SpecRun, configuration.TestResultsFormat); }
public void ThenSetsLanguageToEnglishByDefault() { var args = new[] { "" }; var configuration = new Configuration(); var commandLineArgumentParser = new CommandLineArgumentParser(FileSystem); bool shouldContinue = commandLineArgumentParser.Parse(args, configuration, TextWriter.Null); Check.That(configuration.Language).IsEqualTo("en"); }
public void ThenCanParseResultsFileWithShortFormSuccessfully() { var args = new[] { @"-lr=c:\results.xml" }; var configuration = new Configuration(); var commandLineArgumentParser = new CommandLineArgumentParser(FileSystem); bool shouldContinue = commandLineArgumentParser.Parse(args, configuration, TextWriter.Null); shouldContinue.ShouldBeTrue(); configuration.HasTestResults.ShouldBeTrue(); Assert.AreEqual(@"c:\results.xml", configuration.TestResultsFile.FullName); }
public void ThenCanParseResultsFormatSpecrunWithShortFormSuccessfully() { var args = new[] { @"-trfmt=specrun" }; var configuration = new Configuration(); var commandLineArgumentParser = new CommandLineArgumentParser(FileSystem); bool shouldContinue = commandLineArgumentParser.Parse(args, configuration, TextWriter.Null); Check.That(shouldContinue).IsTrue(); Check.That(configuration.TestResultsFormat).IsEqualTo(TestResultsFormat.SpecRun); }
public void ThenCanFilterOutNonExistingTestResultFiles() { var args = new[] { @"-link-results-file=c:\DoesNotExist.xml;" }; var configuration = new Configuration(); var commandLineArgumentParser = new CommandLineArgumentParser(FileSystem); bool shouldContinue = commandLineArgumentParser.Parse(args, configuration, TextWriter.Null); Check.That(shouldContinue).IsTrue(); Check.That(configuration.HasTestResults).IsFalse(); Check.That(configuration.TestResultsFiles).IsEmpty(); }
public void ThenCanParseShortFormArgumentsSuccessfully() { var args = new[] {@"-f=c:\features", @"-o=c:\features-output"}; var configuration = new Configuration(); var commandLineArgumentParser = new CommandLineArgumentParser(FileSystem); bool shouldContinue = commandLineArgumentParser.Parse(args, configuration, TextWriter.Null); Assert.AreEqual(true, shouldContinue); Assert.AreEqual(@"c:\features", configuration.FeatureFolder.FullName); Assert.AreEqual(@"c:\features-output", configuration.OutputFolder.FullName); Assert.AreEqual(false, configuration.HasTestResults); Assert.AreEqual(null, configuration.TestResultsFile); }
public void ThenCanParseResultsFormatCucumberJsonWithLongFormSuccessfully() { var args = new[] { @"-test-results-format=cucumberjson" }; var configuration = new Configuration(); var commandLineArgumentParser = new CommandLineArgumentParser(FileSystem); bool shouldContinue = commandLineArgumentParser.Parse(args, configuration, TextWriter.Null); Check.That(shouldContinue).IsTrue(); Check.That(configuration.TestResultsFormat).IsEqualTo(TestResultsFormat.CucumberJson); }
public void ThenCanParseVersionRequestShortFormSuccessfully() { var args = new[] { @"-v" }; var configuration = new Configuration(); var writer = new StringWriter(); var commandLineArgumentParser = new CommandLineArgumentParser(FileSystem); bool shouldContinue = commandLineArgumentParser.Parse(args, configuration, writer); StringAssert.IsMatch(expectedVersionString.ComparisonNormalize(), writer.GetStringBuilder().ToString().ComparisonNormalize()); shouldContinue.ShouldBeFalse(); }
public void ThenCanParseVersionRequestShortFormSuccessfully() { var args = new[] {@"-v"}; var configuration = new Configuration(); var writer = new StringWriter(); var commandLineArgumentParser = new CommandLineArgumentParser(FileSystem); bool shouldContinue = commandLineArgumentParser.Parse(args, configuration, writer); StringAssert.IsMatch(expectedVersionString.ComparisonNormalize(), writer.GetStringBuilder().ToString().ComparisonNormalize()); Assert.AreEqual(false, shouldContinue); Assert.AreEqual(Path.GetFullPath(Directory.GetCurrentDirectory()), configuration.FeatureFolder.FullName); Assert.AreEqual(Path.GetFullPath(Environment.GetEnvironmentVariable("TEMP")), configuration.OutputFolder.FullName); Assert.AreEqual(false, configuration.HasTestResults); Assert.AreEqual(null, configuration.TestResultsFile); }
public void ThenCanParseResultsFileAsSemicolonSeparatedListThatEndsWithASemicolon() { FileSystem.AddFile(@"c:\results1.xml", "<xml />"); var args = new[] { @"-link-results-file=c:\results1.xml;" }; var configuration = new Configuration(); var commandLineArgumentParser = new CommandLineArgumentParser(FileSystem); bool shouldContinue = commandLineArgumentParser.Parse(args, configuration, TextWriter.Null); Check.That(shouldContinue).IsTrue(); Check.That(configuration.HasTestResults).IsTrue(); Check.That(configuration.TestResultsFiles.Count()).IsEqualTo(1); Check.That(configuration.TestResultsFiles.First().FullName).IsEqualTo(@"c:\results1.xml"); }
public void Then_can_parse_results_file_with_short_form_successfully() { var args = new string[] { @"-lr=c:\results.xml" }; var configuration = new Configuration(); var commandLineArgumentParser = new CommandLineArgumentParser(); bool shouldContinue = commandLineArgumentParser.Parse(args, configuration, TextWriter.Null); Assert.AreEqual(true, shouldContinue); Assert.AreEqual(Path.GetFullPath(Directory.GetCurrentDirectory()), configuration.FeatureFolder.FullName); Assert.AreEqual(Path.GetFullPath(Environment.GetEnvironmentVariable("TEMP")), configuration.OutputFolder.FullName); Assert.AreEqual(true, configuration.HasTestFrameworkResults); Assert.AreEqual(@"c:\results.xml", configuration.LinkedTestFrameworkResultsFile.FullName); }
public void ThenCanParseResultsFormatMstestWithLongFormSuccessfully() { var args = new[] {@"-test-results-format=mstest"}; var configuration = new Configuration(); var commandLineArgumentParser = new CommandLineArgumentParser(FileSystem); bool shouldContinue = commandLineArgumentParser.Parse(args, configuration, TextWriter.Null); Assert.AreEqual(true, shouldContinue); Assert.AreEqual(TestResultsFormat.MsTest, configuration.TestResultsFormat); }
public void ThenCanParseResultsFileWithShortFormSuccessfully() { var args = new[] {@"-lr=c:\results.xml"}; var configuration = new Configuration(); var commandLineArgumentParser = new CommandLineArgumentParser(FileSystem); bool shouldContinue = commandLineArgumentParser.Parse(args, configuration, TextWriter.Null); Assert.AreEqual(true, shouldContinue); Assert.AreEqual(Path.GetFullPath(Directory.GetCurrentDirectory()), configuration.FeatureFolder.FullName); Assert.AreEqual(Path.GetFullPath(Environment.GetEnvironmentVariable("TEMP")), configuration.OutputFolder.FullName); Assert.AreEqual(true, configuration.HasTestResults); Assert.AreEqual(@"c:\results.xml", configuration.TestResultsFile.FullName); }
public void ThenCanParseResultsFileAsSemicolonSeparatedListThatStartsWithASemicolon() { var args = new[] { @"-link-results-file=;c:\results1.xml" }; var configuration = new Configuration(); var commandLineArgumentParser = new CommandLineArgumentParser(FileSystem); bool shouldContinue = commandLineArgumentParser.Parse(args, configuration, TextWriter.Null); shouldContinue.ShouldBeTrue(); configuration.HasTestResults.ShouldBeTrue(); Assert.AreEqual(1, configuration.TestResultsFiles.Length); Assert.AreEqual(@"c:\results1.xml", configuration.TestResultsFiles[0].FullName); }
public void ThenCanParseShortFormArgumentsSuccessfully() { var args = new[] { @"-f=c:\features", @"-o=c:\features-output" }; var configuration = new Configuration(); var commandLineArgumentParser = new CommandLineArgumentParser(FileSystem); bool shouldContinue = commandLineArgumentParser.Parse(args, configuration, TextWriter.Null); Check.That(shouldContinue).IsTrue(); Check.That(configuration.FeatureFolder.FullName).IsEqualTo(@"c:\features"); Check.That(configuration.OutputFolder.FullName).IsEqualTo(@"c:\features-output"); }
public void ThenInputAndOutputDirectoryAreSetToTheCurrentDirectory() { var args = new[] { @"-v" }; var configuration = new Configuration(); var writer = new StringWriter(); var commandLineArgumentParser = new CommandLineArgumentParser(FileSystem); commandLineArgumentParser.Parse(args, configuration, writer); string currentDirectory = Assembly.GetExecutingAssembly().Location; Check.That(configuration.FeatureFolder.FullName).IsEqualTo(currentDirectory); Check.That(configuration.OutputFolder.FullName).IsEqualTo(currentDirectory); }
public void ThenInputAndOutputDirectoryAreSetToTheCurrentDirectory() { var args = new[] { @"-v" }; var configuration = new Configuration(); var writer = new StringWriter(); var commandLineArgumentParser = new CommandLineArgumentParser(FileSystem); commandLineArgumentParser.Parse(args, configuration, writer); Assert.AreEqual(CurrentDirectory, configuration.FeatureFolder.FullName); Assert.AreEqual(CurrentDirectory, configuration.OutputFolder.FullName); }
public void ThenCanParseResultsFormatXunitWithShortFormSuccessfully() { var args = new[] {@"-trfmt=xunit"}; var configuration = new Configuration(); var commandLineArgumentParser = new CommandLineArgumentParser(FileSystem); bool shouldContinue = commandLineArgumentParser.Parse(args, configuration, TextWriter.Null); Assert.AreEqual(true, shouldContinue); Assert.AreEqual(TestResultsFormat.xUnit, configuration.TestResultsFormat); }