You only need to configure the Mock object if you really need to control the behavior of what it does, for example, return material:
_mockRepo.SetUp(m => m.DoStuff()).Returns(someObject);
or do an exception:
_mockRepo.SetUp(m => m.DoStuff()).Throws(new SomeExceptionType());
I assume that in your example, you are passing the layout of the logger object to some other object that is under testing, in which case deleting the installation call will have no effect, since the equivalent setup will only be done by creating the Mock object.
Edit
public class Dude : IDude { private IAirSupport _support; public Dude(IAirSupport support) { _support = support; } public void Advance(Place place) { if(place.IsUnderAttack) { _support.CoveringFire(place); MoveAndFire(place); } } }
To make fun of it:
var support = new Mock<IAirSupport>(); var dude = new Dude(support.Object); var place = new HotSpot { IsUnderFire = true }; dude.Advance(place); support.Verify(m => m.CoveringFire(place), Times.Once());
That's all you need - check if all the hard work is there, there is no reason to call the settings.
source share