/08_04.cs Secret
Created
November 14, 2014 22:25
08. 移行サンプル:Typemock Isolator による… で解説する移行結果(Example Test 2 - Complex Test)。
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
[Test] | |
public void UserOfSomeClassDoSomething_should_show_MessageBox_if_an_exception_is_thrown() | |
{ | |
using (new IndirectionsContext()) | |
{ | |
// Arrange | |
PSomeClass.MyMethod().Body = () => { throw new Exception("foo"); }; | |
var mockMessageBox = new Mock<IndirectionFunc<string, DialogResult>>(); | |
mockMessageBox.Setup(_ => _(string.Empty)).Returns(DialogResult.OK); | |
PMessageBox.ShowString().Body = mockMessageBox.Object; | |
// Act | |
var user = new UserOfSomeClass(); | |
user.DoSomething(); | |
// Assert | |
mockMessageBox.Verify(_ => _("Exception caught: foo")); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment