Skip to content

Consider Using Static Extension Methods for Expectation Creation #411

Description

@JasonBock

Describe alternatives you've considered
This idea came from a comment in my C# video from VSLive Las Vegas - https://www.youtube.com/watch?v=pEfHF9l98Ho. Basically, create an extension method on the type that we want to mock, and effectively "hide" the name of the expectation type:

var expectations = IPersonRepository.CreateExpectations();

I like this. It's no longer necessary to remember the name of the expectation type. Granted, this is really close to the currently generated name, but I think it reads better. And it lets me change the type of the expectations.

It's unfortunate that file scope can only be applied to a type, because I could make it where the expectations type can be seen by callers but can't be created. Maybe there's another way to do that.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions