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")); }
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"); }
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))); }
public void ShouldNotThrownAnExceptionWithTheSameTypeOfCollectionTypeFactory() { ICollectionTypeFactory ctf; var bcp = new BytecodeProviderImpl(); ctf = bcp.CollectionTypeFactory; // initialize the instance Assert.DoesNotThrow(() => bcp.SetCollectionTypeFactoryClass(typeof (Type.DefaultCollectionTypeFactory))); }
public void InvalidCollectionTypeFactoryCtor() { ICollectionTypeFactory ctf; var bcp = new BytecodeProviderImpl(); bcp.SetCollectionTypeFactoryClass(typeof (NoDefaultCtor)); Assert.Throws<HibernateByteCodeException>(() => ctf = bcp.CollectionTypeFactory); }