Example #1
0
        public void SetCollectionTypeFactoryClassByType()
        {
            System.Type nullType = null;
            var         bcp      = new BytecodeProviderImpl();

            Assert.Throws <ArgumentNullException>(() => bcp.SetCollectionTypeFactoryClass(nullType));
            Assert.Throws <HibernateByteCodeException>(() => bcp.SetCollectionTypeFactoryClass(GetType()), "should allow only ICollectionTypeFactory type");
        }
Example #2
0
        public void SetCollectionTypeFactoryClassByName()
        {
            string nullName = null;
            var    bcp      = new BytecodeProviderImpl();

            Assert.Throws <ArgumentNullException>(() => bcp.SetCollectionTypeFactoryClass(nullName));
            Assert.Throws <ArgumentNullException>(() => bcp.SetCollectionTypeFactoryClass(string.Empty));
            Assert.Throws <TypeLoadException>(() => bcp.SetCollectionTypeFactoryClass("whatever"));
        }
Example #3
0
        public void ShouldNotThrownAnExceptionWithTheSameTypeOfCollectionTypeFactory()
        {
            ICollectionTypeFactory ctf;
            var bcp = new BytecodeProviderImpl();

            ctf = bcp.CollectionTypeFactory;             // initialize the instance
            Assert.DoesNotThrow(() => bcp.SetCollectionTypeFactoryClass(typeof(Type.DefaultCollectionTypeFactory)));
        }
Example #4
0
        public void InvalidCollectionTypeFactoryCtor()
        {
            ICollectionTypeFactory ctf;
            var bcp = new BytecodeProviderImpl();

            bcp.SetCollectionTypeFactoryClass(typeof(NoDefaultCtor));
            Assert.Throws <HibernateByteCodeException>(() => ctf = bcp.CollectionTypeFactory);
        }
Example #5
0
        public void CollectionTypeFactoryCantChangeAfterUsage()
        {
            ICollectionTypeFactory ctf;
            var bcp = new BytecodeProviderImpl();

            ctf = bcp.CollectionTypeFactory;             // initialize the instance
            // try to set it
            Assert.Throws <InvalidOperationException>(() => bcp.SetCollectionTypeFactoryClass(typeof(CustomCollectionTypeFactory)));
        }