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 NUnit.Framework;
|
21
|
|
using Seasar.Framework.Aop.Interceptors;
|
22
|
|
using Seasar.Framework.Container;
|
23
|
|
using Seasar.Framework.Container.Impl;
|
24
|
|
|
25
|
|
namespace Seasar.Tests.Framework.Container.Impl
|
26
|
|
{
|
27
|
|
|
28
|
|
|
29
|
|
|
30
|
|
[TestFixture]
|
31
|
|
public class AspectDefImplTest
|
32
|
|
{
|
33
|
|
|
34
|
1
|
[Test]
|
35
|
|
public void TestSetExpression()
|
36
|
|
{
|
37
|
1
|
IS2Container container = new S2ContainerImpl();
|
38
|
1
|
IAspectDef ad = new AspectDefImpl();
|
39
|
1
|
ad.Expression = "traceAdvice";
|
40
|
1
|
ad.Container = container;
|
41
|
1
|
ComponentDefImpl cd = new ComponentDefImpl(typeof(TraceInterceptor), "traceAdvice");
|
42
|
1
|
container.Register(cd);
|
43
|
1
|
Assert.AreEqual(typeof(TraceInterceptor), ad.Aspect.MethodInterceptor.GetType());
|
44
|
|
}
|
45
|
|
|
46
|
|
public class A
|
47
|
|
{
|
48
|
|
private IHoge hoge_;
|
49
|
|
|
50
|
0
|
public A(IHoge hoge)
|
51
|
|
{
|
52
|
|
hoge_ = hoge;
|
53
|
|
}
|
54
|
|
|
55
|
0
|
public string HogeName
|
56
|
|
{
|
57
|
|
get { return hoge_.Name; }
|
58
|
|
}
|
59
|
|
}
|
60
|
|
|
61
|
|
public class A2
|
62
|
|
{
|
63
|
|
private IHoge hoge_;
|
64
|
|
|
65
|
0
|
public IHoge Hoge
|
66
|
|
{
|
67
|
|
set { hoge_ = value; }
|
68
|
|
}
|
69
|
|
|
70
|
0
|
public string HogeName
|
71
|
|
{
|
72
|
|
get { return hoge_.Name; }
|
73
|
|
}
|
74
|
|
}
|
75
|
|
|
76
|
|
public interface IHoge
|
77
|
|
{
|
78
|
|
string Name { get; }
|
79
|
|
}
|
80
|
|
|
81
|
|
public class B : IHoge
|
82
|
|
{
|
83
|
0
|
public string Name
|
84
|
|
{
|
85
|
|
get { return "B"; }
|
86
|
|
}
|
87
|
|
}
|
88
|
|
|
89
|
|
public class C : IHoge
|
90
|
|
{
|
91
|
|
private A2 a2_;
|
92
|
|
|
93
|
0
|
public A2 A2
|
94
|
|
{
|
95
|
|
set { a2_ = value; }
|
96
|
|
}
|
97
|
|
|
98
|
0
|
public string Name
|
99
|
|
{
|
100
|
|
get { return "C"; }
|
101
|
|
}
|
102
|
|
|
103
|
0
|
public string HogeName
|
104
|
|
{
|
105
|
|
get { return a2_.HogeName; }
|
106
|
|
}
|
107
|
|
}
|
108
|
|
}
|
109
|
|
|
110
|
|
}
|
111
|
|
|