-
Notifications
You must be signed in to change notification settings - Fork 163
Expand file tree
/
Copy pathTestBase.cs
More file actions
46 lines (42 loc) · 1.48 KB
/
TestBase.cs
File metadata and controls
46 lines (42 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using Moq;
namespace SharpRepository.Tests
{
public abstract class TestBase
{
protected static T N<T>() where T : class
{
return default(T);
}
/// <summary>
/// Create a mock
/// </summary>
/// <typeparam name="T">Type to be mocked</typeparam>
/// <param name="argumentsForConstructor">Constructor arguments</param>
/// <returns>T</returns>
protected static T M<T>(params object[] argumentsForConstructor) where T : class
{
var mock = new MockRepository(MockBehavior.Default).Create<T>(argumentsForConstructor);
return mock.Object;
}
/// <summary>
/// Create a partial mock
/// </summary>
/// <typeparam name="T">Type to be partially mocked</typeparam>
/// <param name="argumentsForConstructor">Constructor arguments</param>
/// <returns>T</returns>
protected static T Pm<T>(params object[] argumentsForConstructor) where T : class
{
return M<T>(argumentsForConstructor);
}
/// <summary>
/// Create a stub
/// </summary>
/// <typeparam name="T">Type to be stubbed</typeparam>
/// <param name="argumentsForConstructor">Constructor arguments</param>
/// <returns>T</returns>
protected static T S<T>(params object[] argumentsForConstructor) where T : class
{
return M<T>(argumentsForConstructor);
}
}
}