Skip to content

Instantly share code, notes, and snippets.

@collatzz
Created January 15, 2018 16:22
Show Gist options
  • Select an option

  • Save collatzz/4be4e9387eddb965da6f55f39d6de27d to your computer and use it in GitHub Desktop.

Select an option

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
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.
}
}
@pilotgeraldb
Copy link

👍 fantastic :) very useful!

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