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