コード例 #1
0
        public void DictionaryShouldContainPair_WhenPropertiesOfDifferentVariables_ShouldNotTrigger()
        {
            const string assertion = "actual.Should().ContainValue(pair.Value).And.ContainKey(otherPair.Key);";
            var          source    = GenerateCode.DictionaryAssertion(assertion);

            DiagnosticVerifier.VerifyCSharpDiagnosticUsingAllAnalyzers(source);
        }
コード例 #2
0
        private void VerifyCSharpFix <TCodeFixProvider, TDiagnosticAnalyzer>(string oldSourceAssertion, string newSourceAssertion)
            where TCodeFixProvider : Microsoft.CodeAnalysis.CodeFixes.CodeFixProvider, new()
            where TDiagnosticAnalyzer : Microsoft.CodeAnalysis.Diagnostics.DiagnosticAnalyzer, new()
        {
            var oldSource = GenerateCode.DictionaryAssertion(oldSourceAssertion);
            var newSource = GenerateCode.DictionaryAssertion(newSourceAssertion);

            DiagnosticVerifier.VerifyCSharpFix <TCodeFixProvider, TDiagnosticAnalyzer>(oldSource, newSource);
        }
コード例 #3
0
        private void VerifyCSharpDiagnostic <TDiagnosticAnalyzer>(string sourceAssersion) where TDiagnosticAnalyzer : Microsoft.CodeAnalysis.Diagnostics.DiagnosticAnalyzer, new()
        {
            var source = GenerateCode.DictionaryAssertion(sourceAssersion);

            var type         = typeof(TDiagnosticAnalyzer);
            var diagnosticId = (string)type.GetField("DiagnosticId").GetValue(null);
            var message      = (string)type.GetField("Message").GetValue(null);

            DiagnosticVerifier.VerifyCSharpDiagnosticUsingAllAnalyzers(source, new DiagnosticResult
            {
                Id        = diagnosticId,
                Message   = message,
                Locations = new DiagnosticResultLocation[]
                {
                    new DiagnosticResultLocation("Test0.cs", 12, 13)
                },
                Severity = DiagnosticSeverity.Info
            });
        }
コード例 #4
0
        public void CollectionShouldHaveElementAt_ShouldIgnoreDictionaryTypes()
        {
            string source = GenerateCode.DictionaryAssertion("actual[\"key\"].Should().Be(expectedValue);");

            DiagnosticVerifier.VerifyCSharpDiagnosticUsingAllAnalyzers(source);
        }