Skip to content

Commit

Permalink
Add C# 9 test cases for S3264
Browse files Browse the repository at this point in the history
  • Loading branch information
costin-zaharia-sonarsource committed Nov 2, 2020
1 parent 7c25305 commit 043c99d
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,12 @@ public class UninvokedEventDeclarationTest
{
[TestMethod]
[TestCategory("Rule")]
public void UninvokedEventDeclaration()
{
public void UninvokedEventDeclaration() =>
Verifier.VerifyAnalyzer(@"TestCases\UninvokedEventDeclaration.cs", new UninvokedEventDeclaration());
}

[TestMethod]
[TestCategory("Rule")]
public void UninvokedEventDeclaration_CSharp9() =>
Verifier.VerifyAnalyzer(@"TestCases\UninvokedEventDeclaration.CSharp9.cs", new UninvokedEventDeclaration(), ParseOptionsHelper.FromCSharp9);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System;

public record EventInvocations
{
public event EventHandler MyEvent1;
public event EventHandler MyEvent2;
public event EventHandler MyEvent3;
public event EventHandler MyEvent4;
public event EventHandler MyEvent5;
public event EventHandler MyEvent6;

public event Action<object, EventArgs> MyAction1;
public event Action<object, EventArgs> MyAction2;
public event Action<object, EventArgs> MyAction3;
public event Action<object, EventArgs> MyAction4;
public event Action<object, EventArgs> MyAction5;
public event Action<object, EventArgs> MyAction6;

public void InvokeAll()
{
MyEvent1(this, EventArgs.Empty);
MyEvent2.Invoke(this, EventArgs.Empty);
MyEvent3.DynamicInvoke(this, EventArgs.Empty);
MyEvent4.BeginInvoke(this, EventArgs.Empty, null, null);
this.MyEvent5(this, EventArgs.Empty);
MyEvent6?.Invoke(this, EventArgs.Empty);

MyAction1(this, EventArgs.Empty);
MyAction2.Invoke(this, EventArgs.Empty);
MyAction3.DynamicInvoke(this, EventArgs.Empty);
MyAction4.BeginInvoke(this, EventArgs.Empty, null, null);
this.MyAction5(this, EventArgs.Empty);
MyAction6?.Invoke(this, EventArgs.Empty);
}
}

0 comments on commit 043c99d

Please sign in to comment.