1
|
|
#region Copyright
|
2
|
|
|
3
|
|
|
4
|
|
|
5
|
|
|
6
|
|
|
7
|
|
|
8
|
|
|
9
|
|
|
10
|
|
|
11
|
|
|
12
|
|
|
13
|
|
|
14
|
|
|
15
|
|
|
16
|
|
|
17
|
|
#endregion
|
18
|
|
|
19
|
|
using System;
|
20
|
|
using System.IO;
|
21
|
|
using Seasar.Framework.Container;
|
22
|
|
using Seasar.Framework.Container.Factory;
|
23
|
|
using Seasar.Framework.Util;
|
24
|
|
|
25
|
|
namespace Seasar.Framework.Unit
|
26
|
|
{
|
27
|
|
public class S2FrameworkTestCaseBase
|
28
|
|
{
|
29
|
|
private IS2Container container;
|
30
|
|
|
31
|
22
|
public S2FrameworkTestCaseBase()
|
32
|
|
{
|
33
|
|
}
|
34
|
|
|
35
|
|
public IS2Container Container
|
36
|
|
{
|
37
|
45
|
get { return container; }
|
38
|
45
|
set { container = value; }
|
39
|
|
}
|
40
|
|
|
41
|
0
|
public object GetComponent(string componentName)
|
42
|
|
{
|
43
|
|
return container.GetComponent(componentName);
|
44
|
|
}
|
45
|
|
|
46
|
4
|
public object GetComponent(Type componentClass)
|
47
|
|
{
|
48
|
4
|
return container.GetComponent(componentClass);
|
49
|
|
}
|
50
|
|
|
51
|
0
|
public IComponentDef GetComponentDef(string componentName)
|
52
|
|
{
|
53
|
|
return container.GetComponentDef(componentName);
|
54
|
|
}
|
55
|
|
|
56
|
0
|
public IComponentDef GetComponentDef(Type componentClass)
|
57
|
|
{
|
58
|
|
return container.GetComponentDef(componentClass);
|
59
|
|
}
|
60
|
|
|
61
|
1
|
public void Register(Type componentClass)
|
62
|
|
{
|
63
|
1
|
container.Register(componentClass);
|
64
|
|
}
|
65
|
|
|
66
|
0
|
public void Register(Type componentClass, string componentName)
|
67
|
|
{
|
68
|
|
container.Register(componentClass, componentName);
|
69
|
|
}
|
70
|
|
|
71
|
0
|
public void Register(object component)
|
72
|
|
{
|
73
|
|
container.Register(component);
|
74
|
|
}
|
75
|
|
|
76
|
0
|
public void Register(object component, string componentName)
|
77
|
|
{
|
78
|
|
container.Register(component, componentName);
|
79
|
|
}
|
80
|
|
|
81
|
0
|
public void Register(IComponentDef componentDef)
|
82
|
|
{
|
83
|
|
container.Register(componentDef);
|
84
|
|
}
|
85
|
|
|
86
|
40
|
public void Include(string path)
|
87
|
|
{
|
88
|
40
|
S2ContainerFactory.Include(Container, ConvertPath(path));
|
89
|
|
}
|
90
|
|
|
91
|
49
|
protected string ConvertPath(string path)
|
92
|
|
{
|
93
|
49
|
if (ResourceUtil.GetResourceNoException(path, this.GetType().Assembly) != null)
|
94
|
|
{
|
95
|
32
|
return path;
|
96
|
|
}
|
97
|
17
|
if (path.IndexOf('/') > 0)
|
98
|
|
{
|
99
|
1
|
return path;
|
100
|
|
}
|
101
|
16
|
if (path.IndexOf(Path.DirectorySeparatorChar) > 0)
|
102
|
|
{
|
103
|
0
|
return path;
|
104
|
|
}
|
105
|
16
|
string prefix = this.GetType().FullName.Replace('.', '/');
|
106
|
16
|
int pos = (prefix.LastIndexOf("/") + 1);
|
107
|
16
|
prefix = prefix.Substring(0, pos);
|
108
|
16
|
return prefix + path;
|
109
|
|
}
|
110
|
|
}
|
111
|
|
}
|
112
|
|
|