Skip to content

Commit

Permalink
Fix the check of the non-static Verify() method.
Browse files Browse the repository at this point in the history
  • Loading branch information
GillesTourreau committed Jun 24, 2024
1 parent 675c8fe commit 2ea368f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Moq.Analyzers/MoqSymbols.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ private MoqSymbols(INamedTypeSymbol mockGenericClass, Compilation compilation)
this.mockBehaviorStrictField = new Lazy<ISymbol>(() => this.mockBehaviorEnum.Value.GetMembers("Strict").First());
this.setupProtectedMethods = new Lazy<IReadOnlyList<IMethodSymbol>>(() => compilation.GetTypeByMetadataName("Moq.Protected.IProtectedMock`1")!.GetMembers("Setup").OfType<IMethodSymbol>().ToArray());
this.asMethod = new Lazy<ISymbol>(() => mockGenericClass.GetMembers("As").Single());
this.verifyMethods = new Lazy<IReadOnlyList<IMethodSymbol>>(() => mockGenericClass.GetMembers("Verify").OfType<IMethodSymbol>().ToArray());
this.verifyMethods = new Lazy<IReadOnlyList<IMethodSymbol>>(() => mockGenericClass.GetMembers("Verify").Concat(mockGenericClass.BaseType!.GetMembers("Verify")).Where(m => !m.IsStatic).OfType<IMethodSymbol>().ToArray());

this.staticVerifyMethod = new Lazy<IMethodSymbol>(() => mockGenericClass.BaseType!.GetMembers("Verify").Where(m => m.IsStatic).OfType<IMethodSymbol>().Single());
this.staticVerifyAllMethod = new Lazy<IMethodSymbol>(() => mockGenericClass.BaseType!.GetMembers("VerifyAll").Where(m => m.IsStatic).OfType<IMethodSymbol>().Single());
Expand Down
4 changes: 2 additions & 2 deletions tests/Moq.Analyzers.Tests/MoqLibrary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ public Mock(params object[] args) { }
public ISetup<TResult> Setup<TResult>(Func<T, TResult> func) { return default; }
public void Verify() { }
public void Verify(Expression<Action<T>> _) { }
public void Verify<TResult>(Expression<Func<T, TResult>> _) { }
Expand All @@ -43,6 +41,8 @@ public class Mock
{
public static void Verify(params Mock[] mocks) { }
public void Verify() { }
public void VerifyAll() { }
public static void VerifyAll(params Mock[] mocks) { }
Expand Down

0 comments on commit 2ea368f

Please sign in to comment.