code_junkie

Rhino Mocks: What scope do actions inside Do() execute in? [closed]

Nov 10th, 2011
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. Expect.Call(delegate { obj.Method(null); }).IgnoreArguments().Do(
  2. new Action(() => {Console.Write("executed");throw new Exception(); }));
  3.  
  4. try
  5. {
  6. int i = 0;
  7.  
  8. TestClass mock = MockRepository.GenerateMock<TestClass>();
  9. mock.Expect(x => x.Method()).Do(new Action(() => { i++; throw new Exception(); }));
  10.  
  11. mock.Method();
  12. }
  13. catch
  14. {
  15. Console.WriteLine("Bla!");
  16. }
Add Comment
Please, Sign In to add comment