Skip to content

Instantly share code, notes, and snippets.

@SlyNet
Created September 26, 2011 09:11
Show Gist options
  • Save SlyNet/1241908 to your computer and use it in GitHub Desktop.
Save SlyNet/1241908 to your computer and use it in GitHub Desktop.
Some moq
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();
}
}
@SlyNet
Copy link
Author

SlyNet commented Sep 26, 2011

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"
-----------^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment