From: <fab...@us...> - 2009-10-18 16:13:41
|
Revision: 4782 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4782&view=rev Author: fabiomaulo Date: 2009-10-18 16:13:35 +0000 (Sun, 18 Oct 2009) Log Message: ----------- Merge r4781 (fix NH-1980) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Bytecode/AbstractBytecodeProvider.cs trunk/nhibernate/src/NHibernate.Test/Bytecode/Lightweight/BytecodeProviderFixture.cs Modified: trunk/nhibernate/src/NHibernate/Bytecode/AbstractBytecodeProvider.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Bytecode/AbstractBytecodeProvider.cs 2009-10-18 16:11:42 UTC (rev 4781) +++ trunk/nhibernate/src/NHibernate/Bytecode/AbstractBytecodeProvider.cs 2009-10-18 16:13:35 UTC (rev 4782) @@ -108,7 +108,7 @@ { throw new HibernateByteCodeException(type.FullName + " does not implement " + typeof(ICollectionTypeFactory).FullName); } - if (collectionTypeFactory != null) + if (collectionTypeFactory != null && !collectionTypeFactoryClass.Equals(type)) { throw new InvalidOperationException("CollectionTypeFactory in use, can't change it."); } Modified: trunk/nhibernate/src/NHibernate.Test/Bytecode/Lightweight/BytecodeProviderFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Bytecode/Lightweight/BytecodeProviderFixture.cs 2009-10-18 16:11:42 UTC (rev 4781) +++ trunk/nhibernate/src/NHibernate.Test/Bytecode/Lightweight/BytecodeProviderFixture.cs 2009-10-18 16:13:35 UTC (rev 4782) @@ -123,7 +123,7 @@ var bcp = new BytecodeProviderImpl(); ctf = bcp.CollectionTypeFactory; // initialize the instance // try to set it - Assert.Throws<InvalidOperationException>(() => bcp.SetCollectionTypeFactoryClass(typeof(Type.DefaultCollectionTypeFactory))); + Assert.Throws<InvalidOperationException>(() => bcp.SetCollectionTypeFactoryClass(typeof(CustomCollectionTypeFactory))); } private class CustomCollectionTypeFactory : Type.DefaultCollectionTypeFactory @@ -153,5 +153,15 @@ cfg.AddResource("NHibernate.Test.Bytecode.Lightweight.ProductLine.hbm.xml", GetType().Assembly); Assert.That(Environment.BytecodeProvider.CollectionTypeFactory, Is.TypeOf<CustomCollectionTypeFactory>()); } + + [Test] + [Explicit("The BytecodeProvider is static and can't be different in the same application.")] + public void ShouldNotThrownAnExceptionWithTheSameTypeOfCollectionTypeFactory() + { + ICollectionTypeFactory ctf; + var bcp = new BytecodeProviderImpl(); + ctf = bcp.CollectionTypeFactory; // initialize the instance + Assert.DoesNotThrow(() => bcp.SetCollectionTypeFactoryClass(typeof (Type.DefaultCollectionTypeFactory))); + } } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |