コード例 #1
0
        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);
                    }
                }
            }
        }
コード例 #2
0
        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);
                    }
                }
            }
        }
コード例 #3
0
            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);
                        }
                    }
                }
            }
コード例 #4
0
            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
                }
            }
コード例 #5
0
            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
                }
            }
コード例 #6
0
            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
                }
            }
コード例 #7
0
            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
                }
            }
コード例 #8
0
        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());
                    }
                }
            }
        }