Removing "using Test;"
[castle.git] / InversionOfControl / Castle.Windsor.Tests / DependencyProblem.cs
blob2cfc5b1774741a20f358ae52bce0c5c5eb80ca60
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.Windsor.Tests
17 using NUnit.Framework;
19 /// <summary>
20 /// Reported at http://forum.castleproject.org/posts/list/17.page
21 /// </summary>
22 [TestFixture]
23 public class DependencyProblem
25 private IWindsorContainer container;
27 [SetUp]
28 public void Init()
30 container = new WindsorContainer();
33 [Test]
34 public void LoadingInSequence()
36 container.AddComponent("C", typeof(C));
37 container.AddComponent("B", typeof(B));
38 container.AddComponent("A", typeof(A));
40 Assert.IsNotNull(container["A"]);
41 Assert.IsNotNull(container["B"]);
42 Assert.IsNotNull(container["C"]);
45 [Test]
46 public void LoadingPartiallyInSequence()
48 container.AddComponent("B", typeof(B));
49 container.AddComponent("C", typeof(C));
50 container.AddComponent("A", typeof(A));
52 Assert.IsNotNull(container["A"]);
53 Assert.IsNotNull(container["B"]);
54 Assert.IsNotNull(container["C"]);
57 [Test]
58 public void LoadingOutOfSequence()
60 container.AddComponent("A", typeof(A));
61 container.AddComponent("B", typeof(B));
62 container.AddComponent("C", typeof(C));
64 Assert.IsNotNull(container["A"]);
65 Assert.IsNotNull(container["B"]);
66 Assert.IsNotNull(container["C"]);
69 [Test]
70 public void LoadingOutOfSequenceWithExtraLoad()
72 container.AddComponent("A", typeof(A));
73 container.AddComponent("B", typeof(B));
74 container.AddComponent("C", typeof(C));
75 container.AddComponent("NotUsed", typeof(int));
77 Assert.IsNotNull(container["A"]);
78 Assert.IsNotNull(container["B"]);
79 Assert.IsNotNull(container["C"]);
82 [Test]
83 public void CtorSourceOrderDoesNotMatter()
85 container.AddComponent("D", typeof(D));
86 Assert.IsNotNull(container["D"]);
89 public class A
91 public A(B b)
96 public class B
98 public B(C b)
103 public class C
105 public C()
110 public class D
112 public D(B b)
116 public D()