public void TestNoErrorOnSamples() { foreach (string pth in SamplesAasxDir.ListAasxPaths()) { using (var tmpDir = new TemporaryDirectory()) { using (var consoleCap = new ConsoleCapture()) { int code = AasxToolkit.Program.MainWithExitCode( new[] { "load", pth, "export-template", Path.Combine(tmpDir.Path, "exported.template") }); if (consoleCap.Error() != "") { throw new AssertionException( $"Expected no stderr, but got:{System.Environment.NewLine}" + consoleCap.Error()); } Assert.AreEqual(0, code); } } } }
public void TestNoErrorOnSamples() { foreach (string pth in SamplesAasxDir.ListAasxPaths()) { using (var tmpDir = new TemporaryDirectory()) { using (var consoleCap = new ConsoleCapture()) { string targetPth = Path.Combine(tmpDir.Path, "saved.xml"); int code = AasxToolkit.Program.MainWithExitCode( new[] { "load", pth, "check", "save", targetPth }); if (consoleCap.Error() != "") { throw new AssertionException( $"Expected no stderr, but got:{System.Environment.NewLine}" + consoleCap.Error() + System.Environment.NewLine + System.Environment.NewLine + $"The executed command was: " + $"AasxToolkit load {pth} check save {targetPth}"); } Assert.AreEqual(0, code); } } } }
public void TestAgainstSampleData() { var samplePaths = new List <string> { Path.Combine( TestContext.CurrentContext.TestDirectory, "TestResources\\AasxToolkit.Tests\\sample.xml") /* * TODO (mristin, 2020-10-30): add json once the validation is in place. * Michael Hoffmeister had it almost done today. * * Path.Combine( * TestContext.CurrentContext.TestDirectory, * "TestResources\\AasxToolkit.Tests\\sample.json") * * dead-csharp ignore this comment */ }; foreach (string samplePath in samplePaths) { if (!File.Exists(samplePath)) { throw new FileNotFoundException($"The sample file could not be found: {samplePath}"); } using (var tmpDir = new TemporaryDirectory()) { using (var consoleCap = new ConsoleCapture()) { string extension = Path.GetExtension(samplePath); string tmpPath = Path.Combine(tmpDir.Path, $"to-be-validated{extension}"); int code = AasxToolkit.Program.MainWithExitCode( new[] { "load", samplePath, "check+fix", "save", tmpPath, "validate", tmpPath }); if (consoleCap.Error() != "") { var nl = System.Environment.NewLine; throw new AssertionException( $"Expected no stderr for the sample file {samplePath}, but got:{nl}" + $"{consoleCap.Error()}"); } Assert.AreEqual(0, code); } } } }
public void TestDisplayedWhenHelpArgument(string helpArg) { using (var consoleCap = new ConsoleCapture()) { int code = AasxToolkit.Program.MainWithExitCode(new[] { helpArg }); if (consoleCap.Error() != "") { throw new AssertionException( $"Expected no stderr, but got:{System.Environment.NewLine}" + consoleCap.Error()); } Assert.AreEqual(0, code); Assert.IsTrue(consoleCap.Output().StartsWith("AasxToolkit:")); // Start of the help message } }
public void TestHelpTrumpsOtherArguments() { using (var consoleCap = new ConsoleCapture()) { int code = AasxToolkit.Program.MainWithExitCode( new[] { "load", "doesnt-exist.aasx", "help" }); if (consoleCap.Error() != "") { throw new AssertionException( $"Expected no stderr, but got:{System.Environment.NewLine}" + consoleCap.Error()); } Assert.AreEqual(0, code); Assert.IsTrue(consoleCap.Output().StartsWith("AasxToolkit:")); // Start of the help message } }
public void TestDisplayedWhenHelpArgument(string helpArg) { using (var consoleCap = new ConsoleCapture()) { int code = AasxToolkit.Program.MainWithExitCode(new[] { helpArg }); Assert.AreEqual(0, code); Assert.AreEqual("", consoleCap.Error()); Assert.IsTrue(consoleCap.Output().StartsWith("AasxToolkit:")); // Start of the help message } }
public void TestHelpTrumpsOtherArguments() { using (var consoleCap = new ConsoleCapture()) { int code = AasxToolkit.Program.MainWithExitCode( new[] { "load", "doesnt-exist.aasx", "help" }); Assert.AreEqual(0, code); Assert.AreEqual("", consoleCap.Error()); Assert.IsTrue(consoleCap.Output().StartsWith("AasxToolkit:")); // Start of the help message } }
public void TestNoErrorOnSamples() { foreach (string pth in SamplesAasxDir.ListAasxPaths()) { using (var tmpDir = new TemporaryDirectory()) { using (var consoleCap = new ConsoleCapture()) { int code = AasxToolkit.Program.MainWithExitCode( new[] { "load", pth, "export-template", Path.Combine(tmpDir.Path, "exported.template") }); Assert.AreEqual(0, code); Assert.AreEqual("", consoleCap.Error()); } } } }