public void CanSetMetaTypeThroughGenericMethod() { var hbmMapping = new HbmMapping(); var hbmAny = new HbmAny(); var mapper = new AnyMapper(null, typeof(int), hbmAny, hbmMapping); mapper.MetaType<char>(); Assert.That(hbmAny.MetaType, Is.EqualTo("Char")); }
public void CanSetMetaTypeThroughIType() { var hbmMapping = new HbmMapping(); var hbmAny = new HbmAny(); var mapper = new AnyMapper(null, typeof(int), hbmAny, hbmMapping); mapper.MetaType(NHibernateUtil.Character); Assert.That(hbmAny.MetaType, Is.EqualTo("Char")); }
public void CanSetCascade() { var hbmMapping = new HbmMapping(); var hbmAny = new HbmAny(); var mapper = new AnyMapper(null, typeof(int), hbmAny, hbmMapping); mapper.Cascade(Cascade.All); hbmAny.cascade.Should().Be("all"); }
public void WhenSetMetaValueWithClassThenThrow() { var hbmMapping = new HbmMapping(); var hbmAny = new HbmAny(); var mapper = new AnyMapper(null, typeof(int), hbmAny, hbmMapping); Executing.This(() => mapper.MetaValue(typeof(MyReferenceClass), typeof(MyReferenceClass))).Should().Throw <ArgumentOutOfRangeException>(); }
public void CanSetIdTypeThroughType() { var hbmMapping = new HbmMapping(); var hbmAny = new HbmAny(); var mapper = new AnyMapper(null, typeof(int), hbmAny, hbmMapping); mapper.IdType(typeof(long)); hbmAny.idtype.Should().Be("Int64"); }
public void CanSetMetaTypeThroughIType() { var hbmMapping = new HbmMapping(); var hbmAny = new HbmAny(); var mapper = new AnyMapper(null, typeof(int), hbmAny, hbmMapping); mapper.MetaType(NHibernateUtil.Character); hbmAny.MetaType.Should().Be("Char"); }
public void WhenSetMetaValueWithClassThenThrow() { var hbmMapping = new HbmMapping(); var hbmAny = new HbmAny(); var mapper = new AnyMapper(null, typeof(int), hbmAny, hbmMapping); Assert.That(() => mapper.MetaValue(typeof(MyReferenceClass), typeof(MyReferenceClass)), Throws.TypeOf <ArgumentOutOfRangeException>()); }
public void CanSetIdTypeThroughType() { var hbmMapping = new HbmMapping(); var hbmAny = new HbmAny(); var mapper = new AnyMapper(null, typeof(int), hbmAny, hbmMapping); mapper.IdType(typeof(long)); Assert.That(hbmAny.idtype, Is.EqualTo("Int64")); }
public void AutoCleanInvalidCascade() { var hbmMapping = new HbmMapping(); var hbmAny = new HbmAny(); var mapper = new AnyMapper(null, typeof(int), hbmAny, hbmMapping); mapper.Cascade(Cascade.All | Cascade.DeleteOrphans); hbmAny.cascade.Should().Be("all"); }
public void CanSetMetaTypeThroughGenericMethod() { var hbmMapping = new HbmMapping(); var hbmAny = new HbmAny(); var mapper = new AnyMapper(null, typeof(int), hbmAny, hbmMapping); mapper.MetaType <char>(); Assert.That(hbmAny.MetaType, Is.EqualTo("Char")); }
public void CanSetUpdate() { var hbmMapping = new HbmMapping(); var hbmAny = new HbmAny(); var mapper = new AnyMapper(null, typeof(int), hbmAny, hbmMapping); mapper.Update(false); Assert.That(hbmAny.update, Is.False); }
public void CanSetInsert() { var hbmMapping = new HbmMapping(); var hbmAny = new HbmAny(); var mapper = new AnyMapper(null, typeof(int), hbmAny, hbmMapping); mapper.Insert(false); Assert.That(hbmAny.insert, Is.False); }
public void WhenSetSecondMetaValueThenCheckCompatibility() { var hbmMapping = new HbmMapping(); var hbmAny = new HbmAny(); var mapper = new AnyMapper(null, typeof(int), hbmAny, hbmMapping); mapper.MetaValue('A', typeof(MyReferenceClass)); Assert.That(() => mapper.MetaValue(5, typeof(MyClass)), Throws.TypeOf <ArgumentException>()); }
public void WhenSetFirstMetaValueThenSetMetaTypeIfNotClass() { var hbmMapping = new HbmMapping(); var hbmAny = new HbmAny(); var mapper = new AnyMapper(null, typeof(int), hbmAny, hbmMapping); mapper.MetaValue('A', typeof(MyReferenceClass)); Assert.That(hbmAny.MetaType, Is.EqualTo("Char")); }
public void CanSetMetaTypeThroughGenericMethod() { var hbmMapping = new HbmMapping(); var hbmAny = new HbmAny(); var mapper = new AnyMapper(null, typeof(int), hbmAny, hbmMapping); mapper.MetaType <char>(); hbmAny.MetaType.Should().Be("Char"); }
public void WhenDuplicatedMetaValueWithDifferentTypeThenThrow() { var hbmMapping = new HbmMapping(); var hbmAny = new HbmAny(); var mapper = new AnyMapper(null, typeof(int), hbmAny, hbmMapping); mapper.MetaValue('A', typeof(MyReferenceClass)); Assert.That(() => mapper.MetaValue('A', typeof(MyClass)), Throws.TypeOf <ArgumentException>()); }
public void CanSetCascade() { var hbmMapping = new HbmMapping(); var hbmAny = new HbmAny(); var mapper = new AnyMapper(null, typeof(int), hbmAny, hbmMapping); mapper.Cascade(Mapping.ByCode.Cascade.All); Assert.That(hbmAny.cascade, Is.EqualTo("all")); }
public void WhenSetFirstMetaValueThenSetMetaTypeIfNotClass() { var hbmMapping = new HbmMapping(); var hbmAny = new HbmAny(); var mapper = new AnyMapper(null, typeof(int), hbmAny, hbmMapping); mapper.MetaValue('A', typeof(MyReferenceClass)); hbmAny.MetaType.Should().Be("Char"); }
public void CanSetIndex() { var hbmMapping = new HbmMapping(); var hbmAny = new HbmAny(); var mapper = new AnyMapper(null, typeof(int), hbmAny, hbmMapping); mapper.Index("pizza"); Assert.That(hbmAny.index, Is.EqualTo("pizza")); }
public void CanSetIndex() { var hbmMapping = new HbmMapping(); var hbmAny = new HbmAny(); var mapper = new AnyMapper(null, typeof(int), hbmAny, hbmMapping); mapper.Index("pizza"); hbmAny.index.Should().Be("pizza"); }
public void CanSetLazy() { var hbmMapping = new HbmMapping(); var hbmAny = new HbmAny(); var mapper = new AnyMapper(null, typeof(int), hbmAny, hbmMapping); mapper.Lazy(true); hbmAny.lazy.Should().Be(true); }
public void WhenDuplicatedMetaValueWithDifferentTypeThenThrow() { var hbmMapping = new HbmMapping(); var hbmAny = new HbmAny(); var mapper = new AnyMapper(null, typeof(int), hbmAny, hbmMapping); mapper.MetaValue('A', typeof(MyReferenceClass)); Executing.This(() => mapper.MetaValue('A', typeof(MyClass))).Should().Throw <ArgumentException>(); }
public void WhenNullParameterThenThrow() { var hbmMapping = new HbmMapping(); var hbmAny = new HbmAny(); var mapper = new AnyMapper(null, typeof(int), hbmAny, hbmMapping); Assert.That(() => mapper.MetaValue(null, typeof(MyReferenceClass)), Throws.TypeOf <ArgumentNullException>()); Assert.That(() => mapper.MetaValue('A', null), Throws.TypeOf <ArgumentNullException>()); }
public void CanSetUpdate() { var hbmMapping = new HbmMapping(); var hbmAny = new HbmAny(); var mapper = new AnyMapper(null, typeof(int), hbmAny, hbmMapping); mapper.Update(false); hbmAny.update.Should().Be.False(); }
public void CanSetLazy() { var hbmMapping = new HbmMapping(); var hbmAny = new HbmAny(); var mapper = new AnyMapper(null, typeof(int), hbmAny, hbmMapping); mapper.Lazy(true); Assert.That(hbmAny.lazy, Is.EqualTo(true)); }
public void CanSetInsert() { var hbmMapping = new HbmMapping(); var hbmAny = new HbmAny(); var mapper = new AnyMapper(null, typeof(int), hbmAny, hbmMapping); mapper.Insert(false); hbmAny.insert.Should().Be.False(); }
public void AutoCleanInvalidCascade() { var hbmMapping = new HbmMapping(); var hbmAny = new HbmAny(); var mapper = new AnyMapper(null, typeof(int), hbmAny, hbmMapping); mapper.Cascade(Mapping.ByCode.Cascade.All | Mapping.ByCode.Cascade.DeleteOrphans); Assert.That(hbmAny.cascade, Is.EqualTo("all")); }
public void WhenSetSecondMetaValueThenCheckCompatibility() { var hbmMapping = new HbmMapping(); var hbmAny = new HbmAny(); var mapper = new AnyMapper(null, typeof(int), hbmAny, hbmMapping); mapper.MetaValue('A', typeof(MyReferenceClass)); Executing.This(() => mapper.MetaValue(5, typeof(MyClass))).Should().Throw <ArgumentException>(); }
public void WhenNullParameterThenThrow() { var hbmMapping = new HbmMapping(); var hbmAny = new HbmAny(); var mapper = new AnyMapper(null, typeof(int), hbmAny, hbmMapping); Executing.This(() => mapper.MetaValue(null, typeof(MyReferenceClass))).Should().Throw <ArgumentNullException>(); Executing.This(() => mapper.MetaValue('A', null)).Should().Throw <ArgumentNullException>(); }
public void WhenDuplicatedMetaValueThenRegisterOne() { var hbmMapping = new HbmMapping(); var hbmAny = new HbmAny(); var mapper = new AnyMapper(null, typeof(int), hbmAny, hbmMapping); mapper.MetaValue('A', typeof(MyReferenceClass)); mapper.MetaValue('A', typeof(MyReferenceClass)); Assert.That(hbmAny.metavalue, Has.Length.EqualTo(1)); }
public void MetaTypeShouldBeImmutable() { var hbmMapping = new HbmMapping(); var hbmAny = new HbmAny(); var mapper = new AnyMapper(null, typeof(int), hbmAny, hbmMapping); mapper.MetaValue('A', typeof(MyReferenceClass)); Assert.That(() => mapper.MetaType(NHibernateUtil.Int32), Throws.TypeOf <ArgumentException>()); Assert.That(() => mapper.MetaType <int>(), Throws.TypeOf <ArgumentException>()); }
public void WhenSetMetaValueWithClassThenThrow() { var hbmMapping = new HbmMapping(); var hbmAny = new HbmAny(); var mapper = new AnyMapper(null, typeof(int), hbmAny, hbmMapping); Assert.That(() => mapper.MetaValue(typeof(MyReferenceClass), typeof(MyReferenceClass)), Throws.TypeOf<ArgumentOutOfRangeException>()); }
public void WhenSetIdColumnPropertiesThenWorkOnSameHbmColumnCreatedAtCtor() { const int idColumnIndex = 1; var hbmMapping = new HbmMapping(); var hbmAny = new HbmAny(); var mapper = new AnyMapper(null, typeof(int), hbmAny, hbmMapping); var columnsBefore = hbmAny.Columns.ToArray(); mapper.Columns(idcm => idcm.Length(10), metacm => { }); var columnsAfter = hbmAny.Columns.ToArray(); columnsBefore[idColumnIndex].Should().Be.SameInstanceAs(columnsAfter[idColumnIndex]); columnsBefore[idColumnIndex].length.Should().Be("10"); }
public void WhenDuplicatedMetaValueWithDifferentTypeThenThrow() { var hbmMapping = new HbmMapping(); var hbmAny = new HbmAny(); var mapper = new AnyMapper(null, typeof(int), hbmAny, hbmMapping); mapper.MetaValue('A', typeof(MyReferenceClass)); Assert.That(() => mapper.MetaValue('A', typeof(MyClass)), Throws.TypeOf<ArgumentException>()); }
public void WhenSetTwoMetaValueThenHasTwoMetaValues() { var hbmMapping = new HbmMapping(); var hbmAny = new HbmAny(); var mapper = new AnyMapper(null, typeof(int), hbmAny, hbmMapping); mapper.MetaValue('A', typeof(MyReferenceClass)); mapper.MetaValue('B', typeof(MyClass)); hbmAny.metavalue.Should().Have.Count.EqualTo(2); hbmAny.metavalue.Select(mv => mv.value).Should().Have.SameValuesAs("A", "B"); hbmAny.metavalue.Select(mv => mv.@class).Satisfy(c => c.Any(clazz => clazz.Contains("MyReferenceClass"))); hbmAny.metavalue.Select(mv => mv.@class).Satisfy(c => c.Any(clazz => clazz.Contains("MyClass"))); }
public void WhenNullParameterThenThrow() { var hbmMapping = new HbmMapping(); var hbmAny = new HbmAny(); var mapper = new AnyMapper(null, typeof(int), hbmAny, hbmMapping); Executing.This(() => mapper.MetaValue(null, typeof(MyReferenceClass))).Should().Throw<ArgumentNullException>(); Executing.This(() => mapper.MetaValue('A', null)).Should().Throw<ArgumentNullException>(); }
public void CanSetMetaTypeThroughType() { var hbmMapping = new HbmMapping(); var hbmAny = new HbmAny(); var mapper = new AnyMapper(null, typeof(int), hbmAny, hbmMapping); mapper.MetaType(typeof(char)); hbmAny.MetaType.Should().Be("Char"); }
public void WhenSetSecondMetaValueThenCheckCompatibility() { var hbmMapping = new HbmMapping(); var hbmAny = new HbmAny(); var mapper = new AnyMapper(null, typeof(int), hbmAny, hbmMapping); mapper.MetaValue('A', typeof(MyReferenceClass)); Assert.That(() => mapper.MetaValue(5, typeof(MyClass)), Throws.TypeOf<ArgumentException>()); }
public void IdMetaTypeShouldBeImmutableAfterAddMetaValues() { var hbmMapping = new HbmMapping(); var hbmAny = new HbmAny(); var mapper = new AnyMapper(null, typeof(int), hbmAny, hbmMapping); mapper.MetaValue('A', typeof(MyReferenceClass)); Executing.This(() => mapper.IdType(NHibernateUtil.Int32)).Should().NotThrow(); Executing.This(mapper.IdType<int>).Should().NotThrow(); Executing.This(mapper.IdType<string>).Should().Throw<ArgumentException>(); Executing.This(() => mapper.IdType(NHibernateUtil.String)).Should().Throw<ArgumentException>(); }
public void WhenSetTwoMetaValueThenHasTwoMetaValues() { var hbmMapping = new HbmMapping(); var hbmAny = new HbmAny(); var mapper = new AnyMapper(null, typeof(int), hbmAny, hbmMapping); mapper.MetaValue('A', typeof(MyReferenceClass)); mapper.MetaValue('B', typeof(MyClass)); Assert.That(hbmAny.metavalue, Has.Length.EqualTo(2)); Assert.That(hbmAny.metavalue.Select(mv => mv.value), Is.EquivalentTo(new [] {"A", "B"})); Assert.That(hbmAny.metavalue.Any(mv => [email protected]("MyReferenceClass")), Is.True); Assert.That(hbmAny.metavalue.Any(mv => [email protected]("MyClass")), Is.True); }
public void WhenDuplicatedMetaValueWithDifferentTypeThenThrow() { var hbmMapping = new HbmMapping(); var hbmAny = new HbmAny(); var mapper = new AnyMapper(null, typeof(int), hbmAny, hbmMapping); mapper.MetaValue('A', typeof(MyReferenceClass)); Executing.This(() => mapper.MetaValue('A', typeof(MyClass))).Should().Throw<ArgumentException>(); }
public void WhenSetMetaValueWithClassThenThrow() { var hbmMapping = new HbmMapping(); var hbmAny = new HbmAny(); var mapper = new AnyMapper(null, typeof(int), hbmAny, hbmMapping); Executing.This(() => mapper.MetaValue(typeof(MyReferenceClass), typeof(MyReferenceClass))).Should().Throw<ArgumentOutOfRangeException>(); }
public void IdMetaTypeShouldBeImmutableAfterAddMetaValues() { var hbmMapping = new HbmMapping(); var hbmAny = new HbmAny(); var mapper = new AnyMapper(null, typeof(int), hbmAny, hbmMapping); mapper.MetaValue('A', typeof(MyReferenceClass)); Assert.That(() => mapper.IdType(NHibernateUtil.Int32), Throws.Nothing); Assert.That(() => mapper.IdType<int>(), Throws.Nothing); Assert.That(() => mapper.IdType<string>(), Throws.TypeOf<ArgumentException>()); Assert.That(() => mapper.IdType(NHibernateUtil.String), Throws.TypeOf<ArgumentException>()); }
public void WhenSetSecondMetaValueThenCheckCompatibility() { var hbmMapping = new HbmMapping(); var hbmAny = new HbmAny(); var mapper = new AnyMapper(null, typeof(int), hbmAny, hbmMapping); mapper.MetaValue('A', typeof(MyReferenceClass)); Executing.This(() => mapper.MetaValue(5, typeof(MyClass))).Should().Throw<ArgumentException>(); }
public void WhenDuplicatedMetaValueThenRegisterOne() { var hbmMapping = new HbmMapping(); var hbmAny = new HbmAny(); var mapper = new AnyMapper(null, typeof(int), hbmAny, hbmMapping); mapper.MetaValue('A', typeof(MyReferenceClass)); mapper.MetaValue('A', typeof(MyReferenceClass)); hbmAny.metavalue.Should().Have.Count.EqualTo(1); }
public void WhenSetMetaColumnPropertiesThenWorkOnSameHbmColumnCreatedAtCtor() { // The first column in the mapping is the MetaValue const int metaValueColumnIndex = 0; var hbmMapping = new HbmMapping(); var hbmAny = new HbmAny(); var mapper = new AnyMapper(null, typeof(int), hbmAny, hbmMapping); var columnsBefore = hbmAny.Columns.ToArray(); mapper.Columns(idcm => { }, metacm => metacm.Length(500)); var columnsAfter = hbmAny.Columns.ToArray(); columnsBefore[metaValueColumnIndex].Should().Be.SameInstanceAs(columnsAfter[metaValueColumnIndex]); columnsBefore[metaValueColumnIndex].length.Should().Be("500"); }