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
.Configuration2
19 using System
.Threading
;
20 using Castle
.Windsor
.Configuration
.Interpreters
;
21 using Castle
.Windsor
.Tests
.Components
;
22 using NUnit
.Framework
;
24 [TestFixture
, Explicit
]
25 public class SynchronizationProblemTestCase
27 private string dir
= ConfigHelper
.ResolveConfigPath("Configuration2/");
28 private WindsorContainer container
;
29 private ManualResetEvent startEvent
= new ManualResetEvent(false);
30 private ManualResetEvent stopEvent
= new ManualResetEvent(false);
35 string file
= Path
.Combine(AppDomain
.CurrentDomain
.BaseDirectory
, dir
+
36 "synchtest_config.xml");
38 container
= new WindsorContainer(new XmlInterpreter(file
));
40 container
.Resolve(typeof(ComponentWithConfigs
));
44 public void Terminate()
50 public void ResolveWithConfigTest()
52 const int threadCount
= 50;
54 Thread
[] threads
= new Thread
[threadCount
];
56 for (int i
= 0; i
< threadCount
; i
++)
58 threads
[i
] = new Thread(new ThreadStart(ExecuteMethodUntilSignal
));
64 Thread
.CurrentThread
.Join(10 * 2000);
69 private void ExecuteMethodUntilSignal()
71 startEvent
.WaitOne(int.MaxValue
, false);
73 while (!stopEvent
.WaitOne(1, false))
77 ComponentWithConfigs comp
= (ComponentWithConfigs
) container
.Resolve(typeof(ComponentWithConfigs
));
79 Assert
.AreEqual(AppDomain
.CurrentDomain
.BaseDirectory
, comp
.Name
);
80 Assert
.AreEqual(90, comp
.Port
);
81 Assert
.AreEqual(1, comp
.Dict
.Count
);
85 Console
.WriteLine(DateTime
.Now
.Ticks
+ " ---------------------------\r\n" + ex
);