コード例 #1
0
        public async Task TestCaseSourceAttribute_DiagnosticWarning()
        {
            var source =
                @"using NUnit.Framework;
using System.Collections.Generic;

namespace NUnitToXUnitTests
{
    public class NUnitTests
    {
        public static IEnumerable<TestCaseData> TestData
        {
            get
            {
                yield return new TestCaseData(""v"", 3);
                yield return new TestCaseData(""a"", 2);
                yield return new TestCaseData(""l"", 4);
            }
        }

        [TestCaseSource(nameof(TestData))]
        public void TestCaseSource(string value, int value2)
        {
        }
    }
}";

            var expected = Verify.Diagnostic("NXunitConverterAnalyzer").WithLocation(18, 9).WithArguments("TestCaseSource");
            await VerifyCodeFix.VerifyAnalyzerAsync(source, expected);
        }
コード例 #2
0
        public async Task NUnitTestAttribute_DiagnosticWarning()
        {
            var source =
                @"using NUnit.Framework;

namespace NUnitToXUnitTests
{
    public class NUnitTests
    {
        [Test]
        public void Test1()
        {
            Assert.Pass();
        }
    }
}";

            var expected = Verify.Diagnostic("NXunitConverterAnalyzer").WithLocation(7, 9).WithArguments("Test1");
            await VerifyCodeFix.VerifyAnalyzerAsync(source, expected);
        }
コード例 #3
0
        public async Task TestCaseAttribute_DiagnosticWarning()
        {
            var source =
                @"using NUnit.Framework;

namespace NUnitToXUnitTests
{
    public class NUnitTests
    {
        [TestCase(""value"")]
        [TestCase(""value1"")]
        public void TestCase(string value)
        {
        }
    }
}";

            var expected = Verify.Diagnostic("NXunitConverterAnalyzer").WithLocation(7, 9).WithArguments("TestCase");
            await VerifyCodeFix.VerifyAnalyzerAsync(source, expected);
        }
コード例 #4
0
        public async Task TestClass_WithCtor()
        {
            var source =
                @"using NUnit.Framework;

namespace NUnitToXUnitTests
{
    public class UnitTests
    {
        public UnitTests()
        { }

        [Test]
        public void Test1()
        {
        }
    }
}";

            await VerifyCodeFix.VerifyAnalyzerAsync(source);
        }
コード例 #5
0
        public async Task TestClass_WithBase()
        {
            var source =
                @"using NUnit.Framework;

namespace NUnitToXUnitTests
{
    public class NUnitBase { }

    public class NUnitTests : NUnitBase
    {
        [Test]
        public void Test1()
        {
            Assert.Pass();
        }
    }
}";

            await VerifyCodeFix.VerifyAnalyzerAsync(source);
        }