public void AtsignFilenameTests(string commandLine, string testFileNames, string testFileContents, string expectedArgs, string expectedErrors) { var ee = expectedErrors.Split(new[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); var tfn = testFileNames.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries); var tfc = testFileContents.Split(new[] { '|' }); var tfs = new TestFile[tfn.Length]; for (int ix = 0; ix < tfn.Length; ++ix) { tfs[ix] = new TestFile(Path.Combine(TestContext.CurrentContext.TestDirectory, tfn[ix]), tfc[ix], true); } var options = new NUnitLiteOptions(); string actualExpectedArgs; try { actualExpectedArgs = String.Join(" ", options.PreParse(CommandLineOptions.GetArgs(commandLine)).ToArray()); } finally { foreach (var tf in tfs) { tf.Dispose(); } } Assert.AreEqual(expectedArgs, actualExpectedArgs); Assert.AreEqual(options.ErrorMessages, ee); }
public void AtsignFilenameTests(string commandLine, string testFileNames, string testFileContents, string expectedArgs, string expectedErrors) { var ee = expectedErrors.Split(new[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); var tfn = testFileNames.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries); var tfc = testFileContents.Split(new[] { '|' }); var tfs = new TestFile[tfn.Length]; for (int ix = 0; ix < tfn.Length; ++ix) tfs[ix] = new TestFile(Path.Combine(TestContext.CurrentContext.TestDirectory, tfn[ix]), tfc[ix], true); var options = new NUnitLiteOptions(); string actualExpectedArgs; try { actualExpectedArgs = String.Join(" ", options.PreParse(CommandLineOptions.GetArgs(commandLine)).ToArray()); } finally { foreach (var tf in tfs) tf.Dispose(); } Assert.AreEqual(expectedArgs, actualExpectedArgs); Assert.AreEqual(options.ErrorMessages, ee); }
public void GetArgsFromFiles_FailureTests(string args, string errorMessage) { var options = new NUnitLiteOptions(); options.PreParse(CommandLineOptions.GetArgs(args)); Assert.That(options.ErrorMessages, Is.EqualTo(new object[] { errorMessage })); }
//[Test] public void GetArgsFromFiles_NestingOverflow() { var options = new NUnitLiteOptions(); var args = new[] { "--arg1", "@file1.txt", "--arg2" }; var expectedErrors = new string[] { "@ nesting exceeds maximum depth of 3." }; using (new TestFile(Path.Combine(TestContext.CurrentContext.TestDirectory, "file1.txt"), "@file1.txt", true)) { var expandedArgs = options.PreParse(args); Assert.AreEqual(args, expandedArgs); Assert.AreEqual(expectedErrors, options.ErrorMessages); } }
public void GetArgsFromFiles(string commandLine, string files, params string[] expectedArgs) { var filespecs = files.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); var testFiles = new TestFile[filespecs.Length]; for (int ix = 0; ix < filespecs.Length; ++ix) { var filespec = filespecs[ix]; var split = filespec.IndexOf(':'); if (split < 0) { throw new Exception("Invalid test data"); } var fileName = filespec.Substring(0, split); var fileContent = filespec.Substring(split + 1); testFiles[ix] = new TestFile(Path.Combine(TestContext.CurrentContext.TestDirectory, fileName), fileContent, true); } var options = new NUnitLiteOptions(); string[] expandedArgs; try { expandedArgs = options.PreParse(CommandLineOptions.GetArgs(commandLine)).ToArray(); } finally { foreach (var tf in testFiles) { tf.Dispose(); } } Assert.AreEqual(expectedArgs, expandedArgs); Assert.Zero(options.ErrorMessages.Count); }