Exemplo n.º 1
0
        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
        }
Exemplo n.º 2
0
 public void DoSomethingWithDependencyWillThrow()
 {
     var mc = new SomeClass();
     Assert.Throws<NullReferenceException>(() =>
         mc.DoSomething("Ploeh"));
 }