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 System.Collections;
|
22
|
|
using System.Reflection;
|
23
|
|
using Seasar.Framework.Aop.Interceptors;
|
24
|
|
using Seasar.Framework.Container;
|
25
|
|
using Seasar.Framework.Container.Assembler;
|
26
|
|
using Seasar.Framework.Container.Impl;
|
27
|
|
using NUnit.Framework;
|
28
|
|
using log4net;
|
29
|
|
using log4net.Config;
|
30
|
|
using log4net.Util;
|
31
|
|
|
32
|
|
using Seasar.Framework.Log;
|
33
|
|
|
34
|
|
namespace Seasar.Tests.Framework.Container.Assembler
|
35
|
|
{
|
36
|
|
|
37
|
|
|
38
|
|
|
39
|
|
|
40
|
|
[TestFixture]
|
41
|
|
public class DefaultConstructorAssemblerTest
|
42
|
|
{
|
43
|
2
|
[SetUp]
|
44
|
|
public void SetUp()
|
45
|
|
{
|
46
|
2
|
FileInfo info = new FileInfo(SystemInfo.AssemblyFileName(
|
47
|
|
Assembly.GetExecutingAssembly()) + ".config");
|
48
|
2
|
XmlConfigurator.Configure(LogManager.GetRepository(), info);
|
49
|
|
}
|
50
|
|
|
51
|
1
|
[Test]
|
52
|
|
public void TestAssemble()
|
53
|
|
{
|
54
|
1
|
IS2Container container = new S2ContainerImpl();
|
55
|
1
|
ComponentDefImpl cd = new ComponentDefImpl(typeof(ArrayList));
|
56
|
1
|
container.Register(cd);
|
57
|
1
|
IConstructorAssembler assembler = new DefaultConstructorAssembler(cd);
|
58
|
1
|
Assert.IsNotNull(assembler.Assemble());
|
59
|
|
}
|
60
|
|
|
61
|
1
|
[Test]
|
62
|
|
public void TestAssembleAspect()
|
63
|
|
{
|
64
|
1
|
IS2Container container = new S2ContainerImpl();
|
65
|
1
|
ComponentDefImpl cd = new ComponentDefImpl(typeof(A));
|
66
|
1
|
cd.AddAspeceDef(new AspectDefImpl(new TraceInterceptor()));
|
67
|
1
|
container.Register(cd);
|
68
|
1
|
IConstructorAssembler assembler = new DefaultConstructorAssembler(cd);
|
69
|
1
|
A a = (A) assembler.Assemble();
|
70
|
1
|
Console.WriteLine(a.Name);
|
71
|
|
}
|
72
|
|
|
73
|
|
public class A : MarshalByRefObject
|
74
|
|
{
|
75
|
|
public string Name
|
76
|
|
{
|
77
|
1
|
get { return "A"; }
|
78
|
|
}
|
79
|
|
}
|
80
|
|
}
|
81
|
|
}
|
82
|
|
|