From: <fab...@us...> - 2009-10-18 16:11:50
|
Revision: 4781 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4781&view=rev Author: fabiomaulo Date: 2009-10-18 16:11:42 +0000 (Sun, 18 Oct 2009) Log Message: ----------- Fix NH-1980 Modified Paths: -------------- branches/2.1.x/nhibernate/src/NHibernate/Bytecode/AbstractBytecodeProvider.cs branches/2.1.x/nhibernate/src/NHibernate.Test/Bytecode/Lightweight/BytecodeProviderFixture.cs Modified: branches/2.1.x/nhibernate/src/NHibernate/Bytecode/AbstractBytecodeProvider.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate/Bytecode/AbstractBytecodeProvider.cs 2009-10-18 15:59:11 UTC (rev 4780) +++ branches/2.1.x/nhibernate/src/NHibernate/Bytecode/AbstractBytecodeProvider.cs 2009-10-18 16:11:42 UTC (rev 4781) @@ -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: branches/2.1.x/nhibernate/src/NHibernate.Test/Bytecode/Lightweight/BytecodeProviderFixture.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/Bytecode/Lightweight/BytecodeProviderFixture.cs 2009-10-18 15:59:11 UTC (rev 4780) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/Bytecode/Lightweight/BytecodeProviderFixture.cs 2009-10-18 16:11:42 UTC (rev 4781) @@ -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. |