forked from ServiceStack/ServiceStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModelFactoryBase.cs
More file actions
62 lines (53 loc) · 1.03 KB
/
ModelFactoryBase.cs
File metadata and controls
62 lines (53 loc) · 1.03 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
using System.Collections.Generic;
using NUnit.Framework;
namespace ServiceStack.Common.Tests.Models
{
public abstract class ModelFactoryBase<T>
: IModelFactory<T>
{
#region Implementation of IModelFactory<T>
public void AssertListsAreEqual(List<T> actualList, IList<T> expectedList)
{
Assert.That(actualList, Has.Count.EqualTo(expectedList.Count));
var i = 0;
actualList.ForEach(x =>
AssertIsEqual(x, expectedList[i++]));
}
public abstract T CreateInstance(int i);
public abstract void AssertIsEqual(T actual, T expected);
public T ExistingValue
{
get
{
return CreateInstance(4);
}
}
public T NonExistingValue
{
get
{
return CreateInstance(5);
}
}
public List<T> CreateList()
{
return new List<T>
{
CreateInstance(1),
CreateInstance(2),
CreateInstance(3),
CreateInstance(4),
};
}
public List<T> CreateList2()
{
return new List<T>
{
CreateInstance(5),
CreateInstance(6),
CreateInstance(7),
};
}
#endregion
}
}