Created
September 26, 2011 09:11
-
-
Save SlyNet/1241908 to your computer and use it in GitHub Desktop.
Some moq
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Machine.Specifications; | |
using Moq; | |
using It = Machine.Specifications.It; | |
namespace AssetsOptimizer.Specs.Web | |
{ | |
public class MockSpec | |
{ | |
static string test = "orig"; | |
static Mock<IDep> dependency; | |
Establish context = () => | |
{ | |
dependency = new Mock<IDep>(); | |
dependency.Setup(x => x.Foo()) | |
.Returns(test); | |
}; | |
Because of = () => test = "changed"; | |
It should_return_changed_value = () => dependency.Object.Foo().ShouldEqual("changed"); | |
} | |
public interface IDep | |
{ | |
string Foo(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Result of it
should return changed value : Failed Expected string length 7 but was 4. Strings differ at index 0.
Expected: "changed"
But was: "orig"
-----------^