Skip to content

Instantly share code, notes, and snippets.

@MathieuAuclair
Last active March 19, 2019 16:18
Show Gist options
  • Save MathieuAuclair/05bc2ee6d92bdcac3bf9d50d44f74b09 to your computer and use it in GitHub Desktop.
Save MathieuAuclair/05bc2ee6d92bdcac3bf9d50d44f74b09 to your computer and use it in GitHub Desktop.
When an object require too much stuff, like instances

Mock all the Goodies things

If you have a variable that requires a context, simply Mock it like this!

using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;

[TestClass]
class SomeUnitTests
{
    [TestMethod]
    public void TestStuffWithMock()
    {
        var context = Mock.Of<IContext>();
    
        var complexGoodies = new ComplexGoodies(context);
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment