コード例 #1
0
        public void NoConsoleOutput_Pass()
        {
            TagTestResult.ExitCode exitCode = TagTestResult.ExitCode.CriticalError;
            try
            {
                string appInspectorPath = Helper.GetPath(Helper.AppPath.appInspectorCLI);
                string args             = string.Format(@"tagtest -s {0} -r {1} -k none -x none -f text -o {2}",
                                                        Path.Combine(Helper.GetPath(Helper.AppPath.testSource), @"unzipped\simple\main.cpp"),
                                                        Path.Combine(Helper.GetPath(Helper.AppPath.testRules), @"myrule.json"),
                                                        Path.Combine(Helper.GetPath(Helper.AppPath.testOutput), @"output.txt"));

                exitCode = (TagTestResult.ExitCode)Helper.RunProcess(appInspectorPath, args, out string testContent);

                if (exitCode == TagTestResult.ExitCode.TestPassed)
                {
                    exitCode = String.IsNullOrEmpty(testContent) ? TagTestResult.ExitCode.TestPassed : TagTestResult.ExitCode.CriticalError;
                }
            }
            catch (Exception)
            {
            }

            Assert.IsTrue(exitCode == TagTestResult.ExitCode.TestPassed);
        }
コード例 #2
0
        public void RulesNotPresentNoResults_Fail()
        {
            TagTestOptions options = new TagTestOptions()
            {
                SourcePath         = Path.Combine(Helper.GetPath(Helper.AppPath.testSource), @"unzipped\simple\main.cpp"),
                CustomRulesPath    = Path.Combine(Helper.GetPath(Helper.AppPath.testRules), @"myrule.json"),
                TestType           = "RulesNotPresent",
                FilePathExclusions = "none", //allow source under unittest path
            };

            TagTestResult.ExitCode exitCode = TagTestResult.ExitCode.CriticalError;
            try
            {
                TagTestCommand command = new TagTestCommand(options);
                TagTestResult  result  = command.GetResult();
                exitCode = result.ResultCode;
            }
            catch (Exception)
            {
                //check for specific error if desired
            }

            Assert.IsTrue(exitCode == TagTestResult.ExitCode.TestFailed);
        }
コード例 #3
0
        public void LogDebugLevel_Pass()
        {
            TagTestResult.ExitCode exitCode = TagTestResult.ExitCode.CriticalError;
            try
            {
                string args = string.Format(@"tagtest -s {0} -r {1} -k none -v debug -l {2}",
                                            Path.Combine(Helper.GetPath(Helper.AppPath.testSource), @"unzipped\simple\main.cpp"),
                                            Path.Combine(Helper.GetPath(Helper.AppPath.testRules), @"myrule.json"),
                                            Path.Combine(Helper.GetPath(Helper.AppPath.testOutput), @"log.txt"));

                exitCode = (TagTestResult.ExitCode)Microsoft.ApplicationInspector.CLI.Program.Main(args.Split(' '));

                if (exitCode == TagTestResult.ExitCode.CriticalError)
                {
                    string testContent = File.ReadAllText(Path.Combine(Helper.GetPath(Helper.AppPath.testOutput), @"log.txt"));
                    exitCode = testContent.ToLower().Contains("debug") ? TagTestResult.ExitCode.TestPassed : TagTestResult.ExitCode.CriticalError;
                }
            }
            catch (Exception)
            {
            }

            Assert.IsTrue(exitCode == TagTestResult.ExitCode.TestPassed);
        }