Created
January 15, 2018 16:22
-
-
Save collatzz/4be4e9387eddb965da6f55f39d6de27d to your computer and use it in GitHub Desktop.
Wraps the Moq Mock<T> class to prevent using Verify methods on a true stub class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using Moq; | |
| namespace Fakes | |
| { | |
| internal class Stub<T> where T : class | |
| { | |
| private Mock<T> _mock; | |
| internal Stub() | |
| : this(new Mock<T>()) { } | |
| internal Stub(Mock<T> mock) | |
| { | |
| _mock = mock; | |
| } | |
| internal T Object { get { return _mock.Object; } } | |
| // TODO: Add more Mock methods here to extend usability. | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
👍 fantastic :) very useful!