UnityAutoMoq icon indicating copy to clipboard operation
UnityAutoMoq copied to clipboard

Add next code to register mock and objec with one call

Open dzmitry-lahoda opened this issue 10 years ago • 0 comments

This speeds up registering custom mock in base class of test (e.g. MyRepository) and then resolving mock in child to tune base behavior:

  public static class UnityMoqContainerExtensions
    {
        public static IUnityContainer RegisterMock<T>(this IUnityContainer self, Mock<T> mock)
            where T:class
        {
            return self.RegisterInstance(mock).RegisterInstance(mock.Object);
        }
  }

dzmitry-lahoda avatar Sep 04 '15 15:09 dzmitry-lahoda