Beispiel #1
0
        public void Pass()
        {
            var testSubject = new WarnAsyncVoidDiagnosticAnalyzer();

            var result = testSubject.ApplyDiagnostics(SourceText.From(@"
class C
{
     void F(){}
}
")).Result;

            result.Should().BeEmpty();
        }
Beispiel #2
0
        public void Fail()
        {
            var testSubject = new WarnAsyncVoidDiagnosticAnalyzer();

            var result = testSubject.ApplyDiagnostics(SourceText.From(@"
class C
{
    async void F(){}
}
")).Result;

            result.Should().ContainSingle()
            .Which.Descriptor.Should().Be(WarnAsyncVoidDiagnosticAnalyzer.DiagnosticDescriptor);
        }
Beispiel #3
0
        public void PassAnonymousMethod()
        {
            var testSubject = new WarnAsyncVoidDiagnosticAnalyzer();

            var result = testSubject.ApplyDiagnostics(SourceText.From(@"
class C
{
    void F(System.Func<System.Threading.Tasks.Task> _)
    {
        F(async delegate {});
    }
}
")).Result;

            result.Should().BeEmpty();
        }
Beispiel #4
0
        public void FailLambda()
        {
            var testSubject = new WarnAsyncVoidDiagnosticAnalyzer();

            var result = testSubject.ApplyDiagnostics(SourceText.From(@"
class C
{
    void F(System.Action _)
    {
        F(async () => {});
    }
}
")).Result;

            result.Should().ContainSingle()
            .Which.Descriptor.Should().Be(WarnAsyncVoidDiagnosticAnalyzer.DiagnosticDescriptor);
        }