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;
|
22
|
|
using Seasar.Framework.Aop.Impl;
|
23
|
|
|
24
|
|
namespace Seasar.Tests.Framework.Aop.Impl
|
25
|
|
{
|
26
|
|
|
27
|
|
|
28
|
|
|
29
|
|
[TestFixture]
|
30
|
|
public class PointcutImplTest
|
31
|
|
{
|
32
|
1
|
public PointcutImplTest()
|
33
|
|
{
|
34
|
|
}
|
35
|
|
|
36
|
1
|
[Test]
|
37
|
|
public void TestGetMethodNames()
|
38
|
|
{
|
39
|
1
|
PointcutImpl pointcut = new PointcutImpl(typeof(Hello2Impl));
|
40
|
1
|
string[] methodNames = pointcut.MethodNames;
|
41
|
1
|
Assert.AreEqual(2,methodNames.Length);
|
42
|
1
|
foreach(string methodName in methodNames)
|
43
|
|
{
|
44
|
2
|
Console.WriteLine(methodName);
|
45
|
|
}
|
46
|
|
}
|
47
|
|
|
48
|
1
|
[Test]
|
49
|
|
public void TestGetMethodNames2()
|
50
|
|
{
|
51
|
1
|
PointcutImpl pointcut = new PointcutImpl(typeof(Hello2));
|
52
|
1
|
string[] methodNames = pointcut.MethodNames;
|
53
|
1
|
Assert.AreEqual(2,methodNames.Length);
|
54
|
1
|
foreach(string methodName in methodNames)
|
55
|
|
{
|
56
|
2
|
Console.WriteLine(methodName);
|
57
|
|
}
|
58
|
|
}
|
59
|
|
|
60
|
1
|
[Test]
|
61
|
|
public void TestGetMethodNames3()
|
62
|
|
{
|
63
|
1
|
PointcutImpl pointcut = new PointcutImpl(typeof(Hello2Impl2));
|
64
|
1
|
string[] methodNames = pointcut.MethodNames;
|
65
|
1
|
Assert.AreEqual(2,methodNames.Length);
|
66
|
1
|
foreach(string methodName in methodNames)
|
67
|
|
{
|
68
|
2
|
Console.WriteLine(methodName);
|
69
|
|
}
|
70
|
|
}
|
71
|
|
|
72
|
1
|
[Test]
|
73
|
|
public void TestRegex()
|
74
|
|
{
|
75
|
1
|
PointcutImpl pointcut = new PointcutImpl(new string[] { "Greeting.*" });
|
76
|
1
|
Assert.AreEqual(true, pointcut.IsApplied("Greeting"), "1");
|
77
|
1
|
Assert.AreEqual(true, pointcut.IsApplied("Greeting2"), "2");
|
78
|
1
|
Assert.AreEqual(false, pointcut.IsApplied("TestGreetingAAA"), "3");
|
79
|
1
|
Assert.AreEqual(false, pointcut.IsApplied("TestGreeting"), "4");
|
80
|
1
|
Assert.AreEqual(false, pointcut.IsApplied("TestRegex"), "5");
|
81
|
|
}
|
82
|
|
|
83
|
1
|
[Test]
|
84
|
|
public void testRegex2()
|
85
|
|
{
|
86
|
1
|
PointcutImpl pointcut = new PointcutImpl(new String[] { "Find" });
|
87
|
1
|
Assert.AreEqual(false, pointcut.IsApplied("GetFindEx"), "1");
|
88
|
1
|
Assert.AreEqual(false, pointcut.IsApplied("FindAll"), "2");
|
89
|
1
|
Assert.AreEqual(true, pointcut.IsApplied("Find"), "3");
|
90
|
|
}
|
91
|
|
|
92
|
|
public interface Hello
|
93
|
|
{
|
94
|
|
string Greeting();
|
95
|
|
}
|
96
|
|
|
97
|
|
public class HelloImpl : Hello
|
98
|
|
{
|
99
|
0
|
public string Greeting()
|
100
|
|
{
|
101
|
|
return "Hello";
|
102
|
|
}
|
103
|
|
}
|
104
|
|
|
105
|
|
public class HelloInterceptor : IMethodInterceptor
|
106
|
|
{
|
107
|
0
|
public object Invoke(IMethodInvocation invocation)
|
108
|
|
{
|
109
|
|
return "Hello";
|
110
|
|
}
|
111
|
|
}
|
112
|
|
|
113
|
|
public interface Hello2 : Hello
|
114
|
|
{
|
115
|
|
string Greeting2();
|
116
|
|
}
|
117
|
|
|
118
|
|
public class Hello2Impl : HelloImpl,Hello2
|
119
|
|
{
|
120
|
0
|
public string Greeting2()
|
121
|
|
{
|
122
|
|
return "Hello2";
|
123
|
|
}
|
124
|
|
}
|
125
|
|
|
126
|
|
public class Hello2Impl2 : Hello2
|
127
|
|
{
|
128
|
0
|
public string Greeting2()
|
129
|
|
{
|
130
|
|
return "Hello2";
|
131
|
|
}
|
132
|
|
|
133
|
0
|
public string Greeting()
|
134
|
|
{
|
135
|
|
return "Hello";
|
136
|
|
}
|
137
|
|
}
|
138
|
|
|
139
|
|
}
|
140
|
|
}
|
141
|
|
|