Skip to content
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

Check that the As<T>() accept only interfaces. #19

Closed
GillesTourreau opened this issue Jun 12, 2024 · 0 comments · Fixed by #24
Closed

Check that the As<T>() accept only interfaces. #19

GillesTourreau opened this issue Jun 12, 2024 · 0 comments · Fixed by #24
Assignees
Milestone

Comments

@GillesTourreau
Copy link
Contributor

  • Proposed the rule: PosInfoMoq2007
  • Description: "Can only add interfaces to the mock".

For example:

var mock = new Mock<IService>();
mock.As<Service>();   // Should raise an analyzer error.

With the following classes:

public interface IService
{
}

public class Service
{
}
@GillesTourreau GillesTourreau added this to the v1.6.0 milestone Jun 12, 2024
@GillesTourreau GillesTourreau self-assigned this Jun 12, 2024
@GillesTourreau GillesTourreau linked a pull request Jun 24, 2024 that will close this issue
@GillesTourreau GillesTourreau mentioned this issue Jun 24, 2024
@GillesTourreau GillesTourreau mentioned this issue Aug 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant