Fixing an issue with output parameters that are of type IntPtr
[castle.git] / InversionOfControl / Castle.MicroKernel.Tests / TransientMultiConstructorTestCase.cs
blob886b93c20a61c5c80eb7e6b02454de4fe3dc0ecc
1 // Copyright 2004-2008 Castle Project - http://www.castleproject.org/
2 //
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
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
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
17 using System;
18 using System.Collections;
19 using Castle.Core;
20 using NUnit.Framework;
22 [TestFixture]
23 public class TransientMultiConstructorTestCase
25 [Test]
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");
43 [Test]
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");
62 // multi resolve test
64 a = container.Resolve(typeof(FooBarNonValue), arguments1);
65 b = container.Resolve(typeof(FooBarNonValue), arguments2);
67 Assert.AreNotSame(a, b, "A should not be B");
71 [Transient]
72 public class FooBar
74 public FooBar(int integer)
78 public FooBar(DateTime datetime)
83 public class Tester1
85 public string bar;
87 public Tester1(string bar)
89 this.bar = bar;
93 public class Tester2
95 public int foo;
97 public Tester2(int foo)
99 this.foo = foo;
103 [Transient]
104 public class FooBarNonValue
106 public FooBarNonValue(Tester1 test1)
110 public FooBarNonValue(Tester2 test2)