public void DoSomethingWillInvokeDependency() { // Fixture setup string message = "ploeh"; string expectedResult = "fnaah"; var sut = new SomeClass(); var stub = new Mock<ISomeInterface>(); stub.Setup(s => s.DoStuff(message)).Returns(expectedResult); sut.Dependency = stub.Object; // Exercise system var result = sut.DoSomething(message); // Verify outcome Assert.Equal<string>(expectedResult, result); // Teardown }
public void DoSomethingWithDependencyWillThrow() { var mc = new SomeClass(); Assert.Throws<NullReferenceException>(() => mc.DoSomething("Ploeh")); }