Overview

substitutes

var substitute = Substitute.For<ISomeInterface>();
// or
var someClass = Substitute.For<SomeClassWithCtorArgs>(5, "hello world");

substituting for multiple types

Substituting for multiple interfaces:

var command = Substitute.For<ICommand, IDisposable>();
var runner = new CommandRunner(command);

runner.RunCommand();

command.Received().Execute();
((IDisposable)command).Received().Dispose();

Substituting for multiple interfaces and a class:

var substitute = Substitute.For(
		new[] { typeof(ICommand), typeof(ISomeInterface), typeof(SomeClassWithCtorArgs) },
		new object[] { 5, "hello world" }
	);
Assert.IsInstanceOf<ICommand>(substitute);
Assert.IsInstanceOf<ISomeInterface>(substitute);
Assert.IsInstanceOf<SomeClassWithCtorArgs>(substitute);

substituting for delegates

var func = Substitute.For<Func<string>>();

func().Returns("hello");
Assert.AreEqual("hello", func());