예제 #1
0
        /// <summary>
        /// Called to test a C# DiagnosticAnalyzer when applied on the inputted strings as a source
        /// Note: input a DiagnosticResult for each Diagnostic expected
        /// </summary>
        /// <param name="sources">An array of strings to create source documents from to run the analyzers on</param>
        /// <param name="expected">DiagnosticResults that should appear after the analyzer is run on the sources</param>
        protected void VerifyDiagnostic(string[] sources, DiagnosticResult[] expected)
        {
            var actual = _diagnosticAnalyzer.GetSortedDiagnostics(sources, LanguageNames.CSharp);
            var result = _diagnosticAnalyzer.VerifyDiagnosticResults(actual, expected);

            result.Success.ShouldBe(true, result.ErrorMessage);
        }