main
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using Rhino.Mocks;
5using Rhino.Mocks.Interfaces;
6
7namespace tests
8{
9 static public class MockingExtensions
10 {
11 static public MethodCallOccurance<T> was_told_to<T>(this T mocked_item, Action<T> action_to_perform)
12 {
13 return new MethodCallOccurance<T>(mocked_item, action_to_perform);
14 }
15
16 static public void was_not_told_to<T>(this T mocked_item, Action<T> action_to_perform)
17 {
18 mocked_item.AssertWasNotCalled(action_to_perform);
19 }
20
21 static public IMethodOptions<R> is_told_to<T, R>(this T mocked_item, Function<T, R> action_to_perform) where T : class
22 {
23 return mocked_item.Stub(action_to_perform);
24 }
25
26 static public IMethodOptions<R> is_asked_for<T, R>(this T mock, Function<T, R> func) where T : class
27 {
28 return mock.Stub(func);
29 }
30
31 static public IMethodOptions<R> it_will_return<R>(this IMethodOptions<R> options, R item)
32 {
33 return options.Return(item);
34 }
35
36 static public IMethodOptions<IEnumerable<R>> it_will_return<R>(this IMethodOptions<IEnumerable<R>> options,
37 params R[] items)
38 {
39 return options.Return(items.AsEnumerable());
40 }
41
42 static public IMethodOptions<IEnumerable<R>> it_will_return_nothing<R>(
43 this IMethodOptions<IEnumerable<R>> options)
44 {
45 return options.it_will_return();
46 }
47
48 static public void it_will_throw<R>(this IMethodOptions<R> options, Exception item)
49 {
50 options.Throw(item);
51 }
52 }
53}