-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update analyzer, refactor code, and add abstract class support #20
Conversation
This commit includes several updates and improvements. The `ConstructorArgumentsShouldMatchAnalyzerTests.ShouldFailIfClassParametersDoNotMatch.approved.txt` file has been updated to reflect changes in the source code. The `FooAbstract` class and its usage have been removed from `ConstructorArgumentsShouldMatch.cs`. Defensive programming practices have been added to `DiagnosticVerifier.Helper.cs` to ensure non-null arguments. A new file `AbstractClass.cs` has been added to `Moq.Analyzers.Test.csproj`. The `Analyze` method in `ConstructorArgumentsShouldMatchAnalyzer.cs` has been refactored for better readability and maintainability, and now supports abstract classes. The `Moq.Analyzers.csproj` now uses the latest C# language version and the assembly version has been updated to `0.0.6.0`. New test class `AbstractClassTests` and related files have been added to verify the functionality of the updated analyzer. Fixes #1
@MattKotsenas the build action introduced in #9 didn't run on this PR |
Copy/paste error on my part. The default branch is Will update to master until we have the ability to change the default branch. |
Actions issue is fixed in #21. |
Updated `AbstractClassTests.ShouldFailIfBadParameters.verified.txt` and `AbstractClassTests.ShouldPassIfGoodParameters.verified.txt` to reflect changes in test conditions. Refactored `AbstractClassTests.cs` to remove `ApprovalTests` namespace, change `ShouldPassIfGoodParameters` to a Task method, and modify `VerifyCSharpDiagnostic` to take an array of file contents. Added `AbstractClass.Bad.cs` for testing incorrect parameters and updated `AbstractClass.Good.cs` with necessary changes. Updated `Moq.Analyzers.Test.csproj` to include new and updated files with `CopyToOutputDirectory` set to `Always`.
Renamed the test method `ShouldPassIfGoodParameters` to `ShouldPassIfGoodParametersAndFailOnTypeMismatch` in `AbstractClassTests`. Removed the diagnostic message for the test `ShouldFailIfBadParameters`. Cleared the content of `AbstractClassTests.ShouldPassIfGoodParameters.verified.txt`. Added a new diagnostic message to `AbstractClassTests.ShouldPassIfGoodParametersAndFailOnTypeMismatch.verified.txt` indicating a `Moq1002` warning for a line in `Test1.cs` where the parameters provided to the `Mock<AbstractClassWithCtor>` constructor do not match any existing constructors.
…arameters.approved.txt This file is no longer needed
This is failing between platforms. On Windows and through Ubuntu in WSL, the line numbers are a certain value. On a stand alone Ubuntu VM, they're about 50 chars off. Diagnostic 2
Id: Moq1300
- Location: SourceFile(Test0.cs[1594..1604))
+ Location: SourceFile(Test0.cs[1534..1544))
Highlight: OtherClass
Lines: mock.As<OtherClass>();
Severity: Error
Message: Mock.As() should take interfaces only This is because the exemplar code under test is checked in with CRLF, which is stripped in the Linux environment and causing the span positions to be different on the text run. This was corrected in #33 so we're always EOL LF |
# Conflicts: # Source/Moq.Analyzers.Test/ConstructorArgumentsShouldMatchAnalyzerTests.ShouldFailIfClassParametersDoNotMatch.verified.txt # Source/Moq.Analyzers.Test/Data/ConstructorArgumentsShouldMatch.cs # Source/Moq.Analyzers.Test/Helpers/DiagnosticVerifier.Helper.cs # Source/Moq.Analyzers.Test/Moq.Analyzers.Test.csproj # Source/Moq.Analyzers/ConstructorArgumentsShouldMatchAnalyzer.cs # Source/Moq.Analyzers/Moq.Analyzers.csproj
…into repro-issue-1
{ | ||
internal class MyBadUnitTests | ||
{ | ||
private void TestBad() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From conversation, some test cases missing:
- Pass an argument to a constructor that takes no arguments
- Pass (string, int) to a constructor that takes (int, string) or equivalent test
- Pass the incorrect number of arguments to constructor
This commit includes several updates and improvements.
ConstructorArgumentsShouldMatchAnalyzerTests.ShouldFailIfClassParametersDoNotMatch.approved.txt
file has been updated to reflect changes in the source code.FooAbstract
class and its usage have been removed fromConstructorArgumentsShouldMatch.cs
.DiagnosticVerifier.Helper.cs
to ensure non-null arguments.AbstractClass.cs
has been added toMoq.Analyzers.Test.csproj
.Analyze
method inConstructorArgumentsShouldMatchAnalyzer.cs
has been refactored for better readability and maintainability, and now supports abstract classes.AbstractClassTests
and related files have been added to verify the functionality of the updated analyzer.Fixes #1