Fixed some formatting issues.
[castle.git] / Facilities / AutomaticTransactionManagement / Castle.Facilities.AutomaticTransactionManagement.Tests / ConfiguredComponents.cs
blob0f65f980891113f41e9bbedb8a0d08bdf7156411
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.Facilities.AutomaticTransactionManagement.Tests
17 using System.Configuration;
19 using Castle.MicroKernel.Facilities;
20 using Castle.Windsor;
22 using NUnit.Framework;
24 [TestFixture]
25 public class ConfiguredComponents
27 [Test, ExpectedException(typeof(FacilityException), "The class Castle.Facilities.AutomaticTransactionManagement.Tests.TransactionalComp1 has configured transaction in a child node but has not specified istransaction=\"true\" on the component node.")]
28 public void IsTransactionalMissing()
30 new WindsorContainer( ConfigHelper.ResolvePath("../IsTransactionalMissing.xml" ));
33 [Test]
34 public void HasIsTransactionalButNothingIsConfigured()
36 WindsorContainer container = new WindsorContainer( ConfigHelper.ResolvePath("../HasIsTransactionalButNothingIsConfigured.xml" ));
38 TransactionMetaInfoStore metaInfoStore = (TransactionMetaInfoStore)
39 container[typeof(TransactionMetaInfoStore)];
41 TransactionMetaInfo meta = metaInfoStore.GetMetaFor(typeof(TransactionalComp1));
42 Assert.IsNull(meta);
45 [Test]
46 public void HasConfiguration()
48 WindsorContainer container = new WindsorContainer( ConfigHelper.ResolvePath("../HasConfiguration.xml") );
50 TransactionMetaInfoStore metaInfoStore = (TransactionMetaInfoStore)
51 container[typeof(TransactionMetaInfoStore)];
53 TransactionMetaInfo meta = metaInfoStore.GetMetaFor(typeof(TransactionalComp1));
54 Assert.IsNotNull(meta);
55 Assert.AreEqual(3, meta.Methods.Length);
58 [Test, ExpectedException(typeof(ConfigurationErrorsException))]
59 public void HasInvalidMethod()
61 new WindsorContainer( ConfigHelper.ResolvePath("../HasInvalidMethod.xml") );
64 [Test]
65 public void ValidConfigForInheritedMethods()
67 WindsorContainer container = new WindsorContainer( ConfigHelper.ResolvePath("../ValidConfigForInheritedMethods.xml") );
69 TransactionMetaInfoStore metaInfoStore = (TransactionMetaInfoStore)
70 container[typeof(TransactionMetaInfoStore)];
72 TransactionMetaInfo meta = metaInfoStore.GetMetaFor(typeof(TransactionalComp2));
73 Assert.IsNotNull(meta);
74 Assert.AreEqual(4, meta.Methods.Length);
77 [Test]
78 public void ConfigForServiceWithInterface()
80 WindsorContainer container = new WindsorContainer( ConfigHelper.ResolvePath("../ConfigForServiceWithInterface.xml") );
82 TransactionMetaInfoStore metaInfoStore = (TransactionMetaInfoStore)
83 container[typeof(TransactionMetaInfoStore)];
85 TransactionMetaInfo meta = metaInfoStore.GetMetaFor(typeof(TransactionalComp3));
86 Assert.IsNotNull(meta);
87 Assert.AreEqual(2, meta.Methods.Length);