Czy to możliwe dzięki Unity (zamiast Castle Windsor)?

Topost na blogu pokazuje sposób implementacji auto mocking z Castle Windsor i NSubstitute.

Nie wiem ani nie używam Castle Windsor, ale używam Unity i NSubstitute.

Czy istnieje sposób na zrobienie tego, co pokazuje za pomocą Unity?

Oto istotna treść posta:

Po pierwsze, zarejestruj ILazyComponentLoader w Windsor:

var c = new WindsorContainer();    
c.Register(Component.For<LazyComponentAutoMocker>());

Następnie implementacja LazyComponentAutoMocker to po prostu:

public class LazyComponentAutoMocker : ILazyComponentLoader
{    
  public IRegistration Load(string key, Type service, IDictionary arguments)    
  {    
    return Component.For(service).Instance(Substitute.For(new[] { service }, null));    
  }    
}

I jesteś skończony! Oto prosty przykład testu jednostkowego wykorzystujący tylko kod z powyższego:

[Test]
public void IDictionary_Add_Invoked()
{
  var dict = c.Resolve<IDictionary>();
  dict.Add(1, 1);
  dict.Received().Add(1, 1);
}

questionAnswers(1)

yourAnswerToTheQuestion