Skip to content

Instantly share code, notes, and snippets.

@yuta-kaseda
Last active September 19, 2017 05:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yuta-kaseda/4bf51d03b2679099a0037978f555f2d8 to your computer and use it in GitHub Desktop.
Save yuta-kaseda/4bf51d03b2679099a0037978f555f2d8 to your computer and use it in GitHub Desktop.
//参照用クラス
public class TestClass
{
int hoge;
public void Add(int a)
{
hoge += a;
}
}
public static IMockInterface CreateMock()
{
var mock = Substitute.For<IMockInterface>();
TestClass s = new TestClass();
//TestClassのintを返すようにする
mock.hoge.Return(s.hoge);
//TestClassのintをAddする
mock
.When(m => m.HogeMethod())
.Do(() => s.AddInt(1)));
return mock;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment