public void WhenDefineWithoutPropertiesThenNothingHappen() { var orm = new ObjectRelationalMapper(); orm.TablePerClass <MyClass>(); Executing.This(() => orm.NaturalId <MyClass>()).Should().NotThrow(); }
private static HbmMapping GetMapping() { var orm = new ObjectRelationalMapper(); var mapper = new Mapper(orm, new CoolPatternsAppliersHolder(orm)); orm.TablePerClassHierarchy<Product>(); orm.TablePerClass<ActorRole>(); orm.Patterns.PoidStrategies.Add( new GuidOptimizedPoidPattern()); orm.VersionProperty<Entity>(x => x.Version); orm.NaturalId<Product>(p => p.Name); orm.Cascade<Movie, ActorRole>( Cascade.All | Cascade.DeleteOrphans); mapper.AddPropertyPattern(mi => mi.GetPropertyOrFieldType() == typeof(Decimal) && mi.Name.Contains("Price"), pm => pm.Type(NHibernateUtil.Currency)); mapper.AddPropertyPattern(mi => orm.IsRootEntity(mi.DeclaringType) && !"Description".Equals(mi.Name), pm => pm.NotNullable(true)); mapper.Subclass<Movie>(cm => cm.List(movie => movie.Actors, colm => colm.Index( lim => lim.Column("ActorIndex")), m => { })); var domainClasses = typeof(Entity).Assembly.GetTypes() .Where(t => typeof(Entity).IsAssignableFrom(t)); return mapper.CompileMappingFor(domainClasses); }
public void WhenDefineWithoutPropertiesThenNothingHappen() { var orm = new ObjectRelationalMapper(); orm.TablePerClass <MyClass>(); ActionAssert.NotThrow(() => orm.NaturalId <MyClass>()); }
private void ConfOrmMapping(ObjectRelationalMapper orm, Mapper mapper) { orm.TablePerClassHierarchy <Product>(); orm.ManyToMany <Customer, Product>(); orm.Cascade <Movie, ActorRole>(Cascade.All); orm.NaturalId <Customer>(c => c.Name); }
public void WhenDefineWithNullThenRegisterValid() { var orm = new ObjectRelationalMapper(); orm.TablePerClass<MyClass>(); orm.TablePerClass<Related>(); orm.NaturalId<MyClass>(x => x.Name, null, x => x.MyComponent, null); orm.IsMemberOfNaturalId(ForClass<MyClass>.Property(x => x.Name)).Should().Be.True(); orm.IsMemberOfNaturalId(ForClass<MyClass>.Property(x => x.Related)).Should().Be.False(); orm.IsMemberOfNaturalId(ForClass<MyClass>.Property(x => x.MyComponent)).Should().Be.True(); orm.IsMemberOfNaturalId(ForClass<MyClass>.Property(x => x.Any)).Should().Be.False(); }
public void WhenDefineRootEntityThenRegister() { var orm = new ObjectRelationalMapper(); orm.TablePerClass<MyClass>(); orm.TablePerClass<Related>(); orm.NaturalId<MyClass>(x => x.Name, x => x.Related, x => x.MyComponent, x => x.Any); orm.IsMemberOfNaturalId(ForClass<MyClass>.Property(x => x.Name)).Should().Be.True(); orm.IsMemberOfNaturalId(ForClass<MyClass>.Property(x => x.Related)).Should().Be.True(); orm.IsMemberOfNaturalId(ForClass<MyClass>.Property(x => x.MyComponent)).Should().Be.True(); orm.IsMemberOfNaturalId(ForClass<MyClass>.Property(x => x.Any)).Should().Be.True(); }
public void WhenDefineWithNullThenRegisterValid() { var orm = new ObjectRelationalMapper(); orm.TablePerClass <MyClass>(); orm.TablePerClass <Related>(); orm.NaturalId <MyClass>(x => x.Name, null, x => x.MyComponent, null); orm.IsMemberOfNaturalId(ForClass <MyClass> .Property(x => x.Name)).Should().Be.True(); orm.IsMemberOfNaturalId(ForClass <MyClass> .Property(x => x.Related)).Should().Be.False(); orm.IsMemberOfNaturalId(ForClass <MyClass> .Property(x => x.MyComponent)).Should().Be.True(); orm.IsMemberOfNaturalId(ForClass <MyClass> .Property(x => x.Any)).Should().Be.False(); }
public void WhenDefineRootEntityThenRegister() { var orm = new ObjectRelationalMapper(); orm.TablePerClass <MyClass>(); orm.TablePerClass <Related>(); orm.NaturalId <MyClass>(x => x.Name, x => x.Related, x => x.MyComponent, x => x.Any); orm.IsMemberOfNaturalId(ForClass <MyClass> .Property(x => x.Name)).Should().Be.True(); orm.IsMemberOfNaturalId(ForClass <MyClass> .Property(x => x.Related)).Should().Be.True(); orm.IsMemberOfNaturalId(ForClass <MyClass> .Property(x => x.MyComponent)).Should().Be.True(); orm.IsMemberOfNaturalId(ForClass <MyClass> .Property(x => x.Any)).Should().Be.True(); }
private static ObjectRelationalMapper GetORM() { var orm = new ObjectRelationalMapper(); orm.TablePerClassHierarchy<Product>(); orm.TablePerClass<ActorRole>(); orm.NaturalId<Product>(p => p.Name); orm.Cascade<Movie, ActorRole>( Cascade.All | Cascade.DeleteOrphans); orm.Patterns.PoidStrategies .Add(new GuidOptimizedPoidPattern()); orm.Patterns.Versions .Add(new MyVersionPattern()); return orm; }
public void WhenDefineWithoutRootEntityThenThrow() { var orm = new ObjectRelationalMapper(); ActionAssert.Throws<ArgumentOutOfRangeException>(() => orm.NaturalId<MyClass>(x=> x.Any)); }
public void WhenDefineWithoutPropertiesThenNothingHappen() { var orm = new ObjectRelationalMapper(); orm.TablePerClass<MyClass>(); ActionAssert.NotThrow(() => orm.NaturalId<MyClass>()); }
public void WhenDefineWithoutRootEntityThenThrow() { var orm = new ObjectRelationalMapper(); Executing.This(() => orm.NaturalId <MyClass>(x => x.Any)).Should().Throw <ArgumentOutOfRangeException>(); }
public void WhenDefineWithoutRootEntityThenThrow() { var orm = new ObjectRelationalMapper(); ActionAssert.Throws <ArgumentOutOfRangeException>(() => orm.NaturalId <MyClass>(x => x.Any)); }