public void InvokeDirectMethods() { var propertyPath = new PropertyPath(null, ForClass<MyClass>.Property(x => x.MyCollection)); var customizersHolder = new CustomizersHolder(); var customizer = new CollectionElementCustomizer(propertyPath, customizersHolder); var elementMapper = new Mock<IElementMapper>(); customizer.Length(10); customizer.Precision(5); customizer.Scale(2); customizer.NotNullable(true); customizer.Unique(true); customizer.Column("pizza"); customizer.Type(NHibernateUtil.StringClob); customizer.Type<MyUserType>(); var parameters = new {something= 10}; customizer.Type<MyUserType>(parameters); customizer.Type(typeof(MyUserType), parameters); customizersHolder.InvokeCustomizers(propertyPath, elementMapper.Object); elementMapper.Verify(x => x.Length(It.Is<int>(v => v == 10)), Times.Once()); elementMapper.Verify(x => x.Precision(It.Is<short>(v => v == 5)), Times.Once()); elementMapper.Verify(x => x.Scale(It.Is<short>(v => v == 2)), Times.Once()); elementMapper.Verify(x => x.Unique(It.Is<bool>(v => v)), Times.Once()); elementMapper.Verify(x => x.NotNullable(It.Is<bool>(v => v)), Times.Once()); elementMapper.Verify(x => x.Column(It.Is<string>(v => v == "pizza")), Times.Once()); elementMapper.Verify(x => x.Type(It.Is<IType>(v => v.GetType() == NHibernateUtil.StringClob.GetType())), Times.Once()); elementMapper.Verify(x => x.Type<MyUserType>(), Times.Once()); elementMapper.Verify(x => x.Type<MyUserType>(It.Is<object>(v=> v == parameters)), Times.Once()); elementMapper.Verify(x => x.Type(It.Is<Type>(v=> v == typeof(MyUserType)), It.Is<object>(v => v == parameters)), Times.Once()); }
public void InvokeDirectMethods() { var propertyPath = new PropertyPath(null, ConfOrm.ForClass <MyClass> .Property(x => x.MyCollection)); var customizersHolder = new CustomizersHolder(); var customizer = new CollectionElementCustomizer(propertyPath, customizersHolder); var elementMapper = new Mock <IElementMapper>(); customizer.Length(10); customizer.Precision(5); customizer.Scale(2); customizer.NotNullable(true); customizer.Unique(true); customizer.Column("pizza"); customizer.Type(NHibernateUtil.StringClob); customizer.Type <MyUserType>(); var parameters = new { something = 10 }; customizer.Type <MyUserType>(parameters); customizer.Type(typeof(MyUserType), parameters); customizersHolder.InvokeCustomizers(propertyPath, elementMapper.Object); elementMapper.Verify(x => x.Length(It.Is <int>(v => v == 10)), Times.Once()); elementMapper.Verify(x => x.Precision(It.Is <short>(v => v == 5)), Times.Once()); elementMapper.Verify(x => x.Scale(It.Is <short>(v => v == 2)), Times.Once()); elementMapper.Verify(x => x.Unique(It.Is <bool>(v => v)), Times.Once()); elementMapper.Verify(x => x.NotNullable(It.Is <bool>(v => v)), Times.Once()); elementMapper.Verify(x => x.Column(It.Is <string>(v => v == "pizza")), Times.Once()); elementMapper.Verify(x => x.Type(It.Is <IType>(v => v.GetType() == NHibernateUtil.StringClob.GetType())), Times.Once()); elementMapper.Verify(x => x.Type <MyUserType>(), Times.Once()); elementMapper.Verify(x => x.Type <MyUserType>(It.Is <object>(v => v == parameters)), Times.Once()); elementMapper.Verify(x => x.Type(It.Is <Type>(v => v == typeof(MyUserType)), It.Is <object>(v => v == parameters)), Times.Once()); }
public void InvokeColumnCustomizer() { var propertyPath = new PropertyPath(null, ForClass<MyClass>.Property(x => x.MyCollection)); var customizersHolder = new CustomizersHolder(); var customizer = new CollectionElementCustomizer(propertyPath, customizersHolder); var elementMapper = new Mock<IElementMapper>(); var columnMapper = new Mock<IColumnMapper>(); elementMapper.Setup(x => x.Column(It.IsAny<Action<IColumnMapper>>())).Callback<Action<IColumnMapper>>( x => x.Invoke(columnMapper.Object)); customizer.Column(c => c.SqlType("VARCHAR(100)")); customizersHolder.InvokeCustomizers(propertyPath, elementMapper.Object); columnMapper.Verify(x => x.SqlType(It.Is<string>(v => v == "VARCHAR(100)"))); }
public void InvokeColumnCustomizer() { var propertyPath = new PropertyPath(null, ConfOrm.ForClass <MyClass> .Property(x => x.MyCollection)); var customizersHolder = new CustomizersHolder(); var customizer = new CollectionElementCustomizer(propertyPath, customizersHolder); var elementMapper = new Mock <IElementMapper>(); var columnMapper = new Mock <IColumnMapper>(); elementMapper.Setup(x => x.Column(It.IsAny <Action <IColumnMapper> >())).Callback <Action <IColumnMapper> >( x => x.Invoke(columnMapper.Object)); customizer.Column(c => c.SqlType("VARCHAR(100)")); customizersHolder.InvokeCustomizers(propertyPath, elementMapper.Object); columnMapper.Verify(x => x.SqlType(It.Is <string>(v => v == "VARCHAR(100)"))); }