File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed
nunit.analyzers.tests/DelegateRequired
nunit.analyzers/DelegateRequired Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -46,6 +46,32 @@ public void AnalyzeWhenDelegateProvided()
4646 RoslynAssert . Valid ( analyzer , testCode ) ;
4747 }
4848
49+ [ Test ]
50+ public void AnalyzeWhenDelegateLocalProvided ( )
51+ {
52+ var testCode = TestUtility . WrapInTestMethod ( @"
53+ TestDelegate action = MyOperation;
54+ Assert.That(action, Throws.InvalidOperationException);
55+
56+ static void MyOperation() => throw new InvalidOperationException();
57+ " ) ;
58+
59+ RoslynAssert . Valid ( analyzer , testCode ) ;
60+ }
61+
62+ [ Test ]
63+ public void AnalyzeWhenDelegateParameterProvided ( )
64+ {
65+ var testCode = TestUtility . WrapInTestMethod ( @"
66+ AssertSupported(MyOperation);
67+
68+ static void AssertSupported(Action test) => Assert.That(test, Throws.InvalidOperationException);
69+ static void MyOperation() => throw new InvalidOperationException();
70+ " ) ;
71+
72+ RoslynAssert . Valid ( analyzer , testCode ) ;
73+ }
74+
4975 [ Test ]
5076 public void AnalyzeWhenAsyncDelegateProvided ( )
5177 {
Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ protected override void AnalyzeAssertInvocation(OperationAnalysisContext context
3131 return ;
3232 }
3333
34- if ( actualOperation is IDelegateCreationOperation )
34+ if ( actualOperation . Type . TypeKind == TypeKind . Delegate )
3535 {
3636 return ;
3737 }
You can’t perform that action at this time.
0 commit comments