-
-
Save yuta-kaseda/4bf51d03b2679099a0037978f555f2d8 to your computer and use it in GitHub Desktop.
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
//参照用クラス | |
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