public void XmlExternalEntityShouldNotBeParsed_XPathDocument_CSharp9() =>
 Verifier.VerifyAnalyzerFromCSharp9Console(@"TestCases\XmlExternalEntityShouldNotBeParsed_XPathDocument_CSharp9.cs",
                                           new XmlExternalEntityShouldNotBeParsed(GetVersionProviderMock(NetFrameworkVersion.After452)),
                                           MetadataReferenceFacade.GetSystemXml()
                                           .Concat(MetadataReferenceFacade.GetSystemData())
                                           .Concat(MetadataReferenceFacade.GetSystemXmlLinq())
                                           .ToArray());
 public void TestMethodShouldContainAssertion_Xunit_Legacy() =>
 Verifier.VerifyAnalyzer(@"TestCases\TestMethodShouldContainAssertion.Xunit.Legacy.cs",
                         new TestMethodShouldContainAssertion(),
                         additionalReferences: NuGetMetadataReference.XunitFrameworkV1
                         .Concat(NuGetMetadataReference.FluentAssertions(Constants.NuGetLatestVersion))
                         .Concat(MetadataReferenceFacade.GetSystemXml())
                         .Concat(MetadataReferenceFacade.GetSystemXmlLinq())
                         .ToArray());
 public void XmlExternalEntityShouldNotBeParsed_XmlDocument(NetFrameworkVersion version, string testFilePath) =>
 Verifier.VerifyAnalyzer(testFilePath,
                         new XmlExternalEntityShouldNotBeParsed(GetVersionProviderMock(version)),
                         additionalReferences: MetadataReferenceFacade.GetSystemXml()
                         .Concat(MetadataReferenceFacade.GetSystemData())
                         .Concat(MetadataReferenceFacade.GetSystemXmlLinq())
                         .Concat(NuGetMetadataReference.MicrosoftWebXdt())
                         .ToArray());
 public void TestMethodShouldContainAssertion_NUnit(string testFwkVersion, string fluentVersion, string nSubstituteVersion) =>
 Verifier.VerifyAnalyzer(@"TestCases\TestMethodShouldContainAssertion.NUnit.cs",
                         new TestMethodShouldContainAssertion(),
                         additionalReferences: NuGetMetadataReference.NUnit(testFwkVersion)
                         .Concat(NuGetMetadataReference.FluentAssertions(fluentVersion))
                         .Concat(NuGetMetadataReference.NSubstitute(nSubstituteVersion))
                         .Concat(MetadataReferenceFacade.GetSystemXml())
                         .Concat(MetadataReferenceFacade.GetSystemXmlLinq())
                         .ToArray());
 private static void VerifyRule(NetFrameworkVersion version, string testFilePath, OutputKind outputKind = OutputKind.DynamicallyLinkedLibrary, IEnumerable <ParseOptions> options = null) =>
 Verifier.VerifyAnalyzer(testFilePath,
                         new XmlExternalEntityShouldNotBeParsed(GetVersionProviderMock(version)),
                         additionalReferences: MetadataReferenceFacade.GetSystemXml()
                         .Concat(MetadataReferenceFacade.GetSystemData())
                         .Concat(MetadataReferenceFacade.GetSystemXmlLinq())
                         .ToArray(),
                         outputKind: outputKind,
                         options: options);
        private static void VerifyRule(NetFrameworkVersion version, string testFilePath)
        {
            var rule = new XmlExternalEntityShouldNotBeParsed(GetVersionProviderMock(version));

            Verifier.VerifyAnalyzer(testFilePath, rule,
                                    additionalReferences: MetadataReferenceFacade.GetSystemXml()
                                    .Concat(MetadataReferenceFacade.GetSystemData())
                                    .Concat(MetadataReferenceFacade.GetSystemXmlLinq())
                                    .ToArray());
        }
        public void XmlExternalEntityShouldNotBeParsed_XmlDocument(NetFrameworkVersion version, string testFilePath)
        {
            // setup
            var rule = new XmlExternalEntityShouldNotBeParsed(GetVersionProviderMock(version));

            // act & verify
            Verifier.VerifyAnalyzer(testFilePath, rule,
                                    additionalReferences: MetadataReferenceFacade.GetSystemXml()
                                    .Concat(MetadataReferenceFacade.GetSystemData())
                                    .Concat(MetadataReferenceFacade.GetSystemXmlLinq())
                                    .Concat(NuGetMetadataReference.MicrosoftWebXdt())
                                    .ToArray(),
                                    options: ParseOptionsHelper.FromCSharp8);
        }
        public void TestMethodShouldContainAssertion_NUnit_V2Specific(string testFwkVersion) =>
        Verifier.VerifyCSharpAnalyzer(@"
using System;
using NUnit.Framework;

[TestFixture]
public class Foo
{
    [TestCase]
    [ExpectedException(typeof(Exception))]
    public void TestCase4()
    {
        var x = System.IO.File.Open("""", System.IO.FileMode.Open);
    }

    [Theory]
    [ExpectedException(typeof(Exception))]
    public void Theory4()
    {
        var x = System.IO.File.Open("""", System.IO.FileMode.Open);
    }

    [TestCaseSource(""Foo"")]
    [ExpectedException(typeof(Exception))]
    public void TestCaseSource4()
    {
        var x = System.IO.File.Open("""", System.IO.FileMode.Open);
    }

    [Test]
    [ExpectedException(typeof(Exception))]
    public void Test4()
    {
        var x = System.IO.File.Open("""", System.IO.FileMode.Open);
    }
}",
                                      new TestMethodShouldContainAssertion(),
                                      additionalReferences: NuGetMetadataReference.NUnit(testFwkVersion)
                                      .Concat(MetadataReferenceFacade.GetSystemXml())
                                      .Concat(MetadataReferenceFacade.GetSystemXmlLinq())
                                      .ToArray());