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
.Windsor
.Tests
17 using NUnit
.Framework
;
20 /// Reported at http://forum.castleproject.org/posts/list/17.page
23 public class DependencyProblem
25 private IWindsorContainer container
;
30 container
= new WindsorContainer();
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"]);
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"]);
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"]);
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"]);
83 public void CtorSourceOrderDoesNotMatter()
85 container
.AddComponent("D", typeof(D
));
86 Assert
.IsNotNull(container
["D"]);