The following list is my most used mocking techniques to create, setup and verifies injected dependencies.

Create

This section lists all the most used ways of creating a mocked object of a dependancy

Create a mocked object of a dependency

var mockedSystemUnderTest = new Mock();

Setup

This section lists all the most used ways of setting up behaviors of a dependancy

Setup all properties in a mocked dependency

mockedSystemUnderTest.SetAllProperties();

Setup a specific property in a dependency

mockedSystemUnderTest.SetGet(prop=>prop.SomeProperty).Returns("SomeValue");

Setup a function to return a specific value

mockedSystemUnderTest.Setup(fn => fn.SomeFunction("some-value")).Returns(true);

Setup a function behavior for any value for parameters

mockedSystemUnderTest.Setup(fn => fn.SomeFunction(It.IsAny())).Returns(true);

Setup an out parameter in a mocked function

string param = "test val";
SomeType object = new SomeType(){ID = 1};
mockedSystemUnderTest.Setup(fn => fn.SomeFunction(It.IsAny(), out param, out object)).Returns(true);

Verify

This section lists all the most used ways of verifying behaviors of a dependancy after tests code is ran

Verify a function is called

mockedSystemUnderTest.Verify(fn=>fn.SomeFunction("some-value"), Times.Once);

Allow any values for parameters while verifying a function

mockedSystemUnderTest.Verify(fn=>fn.SomeFunction(It.IsAny()), Times.Once);

Get number of elements in a list, that is passed in parameter while function is invoked

mockedRespository.Verify(fn=>fn.SomeFunction(It.IsAny<List>(l=>l.Count==20), Times.Once()))