1 // Copyright 2004-2008 Castle Project - http://www.castleproject.org/
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace Castle
.MicroKernel
.Tests
18 using System
.Collections
;
20 using NUnit
.Framework
;
23 public class TransientMultiConstructorTestCase
26 public void TransientMultiConstructorTest()
28 DefaultKernel container
= new DefaultKernel();
29 container
.AddComponent("FooBar", typeof(FooBar
));
31 Hashtable arguments1
= new Hashtable();
32 arguments1
.Add("integer", 1);
34 Hashtable arguments2
= new Hashtable();
35 arguments2
.Add("datetime", DateTime
.Now
.AddDays(1));
37 object a
= container
.Resolve(typeof(FooBar
), arguments1
);
38 object b
= container
.Resolve(typeof(FooBar
), arguments2
);
40 Assert
.AreNotSame(a
, b
, "A should not be B");
44 public void TransientMultipleConstructorNonValueTypeTest()
46 DefaultKernel container
= new DefaultKernel();
47 container
.AddComponent("FooBar", typeof(FooBarNonValue
));
48 Tester1 bla1
= new Tester1("FOOBAR");
49 Tester2 bla2
= new Tester2(666);
51 Hashtable arguments1
= new Hashtable();
52 arguments1
.Add("test1", bla1
);
54 Hashtable arguments2
= new Hashtable();
55 arguments2
.Add("test2", bla2
);
57 object a
= container
.Resolve(typeof(FooBarNonValue
), arguments1
);
58 object b
= container
.Resolve(typeof(FooBarNonValue
), arguments2
);
60 Assert
.AreNotSame(a
, b
, "A should not be B");
64 a
= container
.Resolve(typeof(FooBarNonValue
), arguments1
);
65 b
= container
.Resolve(typeof(FooBarNonValue
), arguments2
);
67 Assert
.AreNotSame(a
, b
, "A should not be B");
74 public FooBar(int integer
)
78 public FooBar(DateTime datetime
)
87 public Tester1(string bar
)
97 public Tester2(int foo
)
104 public class FooBarNonValue
106 public FooBarNonValue(Tester1 test1
)
110 public FooBarNonValue(Tester2 test2
)