Ejemplo n.º 1
0
        private void CheckForeignKeyObjectIDStorageProperty(
            IRdbmsStoragePropertyDefinition result,
            string expectedValueColumnName,
            StorageTypeInformation expectedValueColumnStorageTypeInfo,
            string expectedClassIDColumnName,
            StorageTypeInformation expectedClassIDStorageTypeInformation)
        {
            Assert.That(result, Is.TypeOf(typeof(ObjectIDStoragePropertyDefinition)));
            var valueProperty        = ((ObjectIDStoragePropertyDefinition)result).ValueProperty;
            var classIDValueProperty = ((ObjectIDStoragePropertyDefinition)result).ClassIDProperty;

            Assert.That(valueProperty, Is.TypeOf(typeof(SimpleStoragePropertyDefinition)));
            Assert.That(valueProperty.PropertyType, Is.SameAs(typeof(object)));

            Assert.That(classIDValueProperty, Is.TypeOf(typeof(SimpleStoragePropertyDefinition)));
            Assert.That(classIDValueProperty.PropertyType, Is.SameAs(typeof(string)));

            var valueIDColumn = ((SimpleStoragePropertyDefinition)valueProperty).ColumnDefinition;
            var classIDColumn = ((SimpleStoragePropertyDefinition)classIDValueProperty).ColumnDefinition;

            Assert.That(valueIDColumn.Name, Is.EqualTo(expectedValueColumnName));
            Assert.That(valueIDColumn.StorageTypeInfo, Is.SameAs(expectedValueColumnStorageTypeInfo));
            Assert.That(valueIDColumn.IsPartOfPrimaryKey, Is.False);

            Assert.That(classIDColumn.Name, Is.EqualTo(expectedClassIDColumnName));
            Assert.That(classIDColumn.StorageTypeInfo, Is.SameAs(expectedClassIDStorageTypeInformation));
            Assert.That(classIDColumn.IsPartOfPrimaryKey, Is.False);
        }
Ejemplo n.º 2
0
        public override void SetUp()
        {
            base.SetUp();

            _storageTypeInformationProviderStub = MockRepository.GenerateStub <IStorageTypeInformationProvider> ();

            _idStorageTypeInformation = StorageTypeInformationObjectMother.CreateStorageTypeInformation();
            _storageTypeInformationProviderStub
            .Stub(stub => stub.GetStorageTypeForID(false))
            .Return(_idStorageTypeInformation);

            _classIDStorageTypeInformation = StorageTypeInformationObjectMother.CreateStorageTypeInformation();
            _storageTypeInformationProviderStub
            .Stub(stub => stub.GetStorageTypeForClassID(false))
            .Return(_classIDStorageTypeInformation);

            _timestampStorageTypeInformation = StorageTypeInformationObjectMother.CreateStorageTypeInformation();
            _storageTypeInformationProviderStub
            .Stub(stub => stub.GetStorageTypeForTimestamp(false))
            .Return(_timestampStorageTypeInformation);

            _storageNameProviderStub = MockRepository.GenerateStub <IStorageNameProvider>();
            _storageNameProviderStub.Stub(stub => stub.GetIDColumnName()).Return("ID");
            _storageNameProviderStub.Stub(stub => stub.GetClassIDColumnName()).Return("ClassID");
            _storageNameProviderStub.Stub(stub => stub.GetTimestampColumnName()).Return("Timestamp");

            _infrastructureStoragePropertyDefinitionProvider =
                new InfrastructureStoragePropertyDefinitionProvider(_storageTypeInformationProviderStub, _storageNameProviderStub);
        }
        public void UnifyForEquivalentProperties_ThrowsForDifferentConverterType()
        {
            var typeInfo1 = new StorageTypeInformation(typeof(int), "X", DbType.Int32, true, typeof(string), new DefaultConverter(typeof(string)));
            var typeInfo2 = new StorageTypeInformation(typeof(int), "X", DbType.Int32, true, typeof(string), new AdvancedEnumConverter(typeof(DbType)));

            Assert.That(
                () => typeInfo1.UnifyForEquivalentProperties(new[] { typeInfo2 }),
                Throws.ArgumentException.With.Message.EqualTo(
                    "Only equivalent properties can be combined, but this property has .NET type converter type 'Remotion.Utilities.DefaultConverter', and "
                    + "the given property has .NET type converter type 'Remotion.Utilities.AdvancedEnumConverter'.\r\nParameter name: equivalentStorageTypes"));
        }
        public void UnifyForEquivalentProperties_ThrowsForDifferentStorageDbType()
        {
            var typeInfo1 = new StorageTypeInformation(typeof(int), "X", DbType.String, true, typeof(string), new DefaultConverter(typeof(string)));
            var typeInfo2 = new StorageTypeInformation(typeof(int), "X", DbType.Int32, true, typeof(string), new DefaultConverter(typeof(string)));

            Assert.That(
                () => typeInfo1.UnifyForEquivalentProperties(new[] { typeInfo2 }),
                Throws.ArgumentException.With.Message.EqualTo(
                    "Only equivalent properties can be combined, but this property has storage DbType 'String', and the given property has "
                    + "storage DbType 'Int32'.\r\nParameter name: equivalentStorageTypes"));
        }
        public void UnifyForEquivalentProperties_CombinesStorageTypes_FirstNullable_CombinedIsNullable()
        {
            var typeInfo1 = new StorageTypeInformation(typeof(string), "X", DbType.Int32, true, typeof(int), new DefaultConverter(typeof(string)));
            var typeInfo2 = new StorageTypeInformation(typeof(string), "X", DbType.Int32, false, typeof(int), new DefaultConverter(typeof(string)));
            var typeInfo3 = new StorageTypeInformation(typeof(string), "X", DbType.Int32, false, typeof(int), new DefaultConverter(typeof(string)));

            var result = typeInfo1.UnifyForEquivalentProperties(new[] { typeInfo2, typeInfo3 });

            Assert.That(result, Is.TypeOf <StorageTypeInformation> ());
            Assert.That(((StorageTypeInformation)result).IsStorageTypeNullable, Is.True);
        }
Ejemplo n.º 6
0
        public override void SetUp()
        {
            base.SetUp();

            _storageNameProviderMock                  = MockRepository.GenerateStrictMock <IStorageNameProvider>();
            _storageProviderDefinitionFinderStub      = MockRepository.GenerateStub <IStorageProviderDefinitionFinder>();
            _storageTypeInformationProviderStrictMock = MockRepository.GenerateStrictMock <IStorageTypeInformationProvider> ();

            _factory = new RelationStoragePropertyDefinitionFactory(TestDomainStorageProviderDefinition,
                                                                    false, _storageNameProviderMock, _storageTypeInformationProviderStrictMock, _storageProviderDefinitionFinderStub);

            _fakeStorageTypeInformation1 = StorageTypeInformationObjectMother.CreateStorageTypeInformation();
            _fakeStorageTypeInformation2 = StorageTypeInformationObjectMother.CreateStorageTypeInformation();
        }
        private void CheckSimplePropertyDefinition(
            IRdbmsStoragePropertyDefinition result,
            Type expectedPropertyType,
            string expectedColumnName,
            StorageTypeInformation expectedStorageTypeInformation)
        {
            Assert.That(result, Is.TypeOf(typeof(SimpleStoragePropertyDefinition)));
            Assert.That(result.PropertyType, Is.SameAs(expectedPropertyType));
            var column = StoragePropertyDefinitionTestHelper.GetSingleColumn(result);

            Assert.That(column.Name, Is.EqualTo(expectedColumnName));
            Assert.That(column.IsPartOfPrimaryKey, Is.False);
            Assert.That(column.StorageTypeInfo, Is.SameAs(expectedStorageTypeInformation));
        }
        public void UnifyForEquivalentProperties_CombinesStorageTypes_AllNonNullable_CombinedIsAlsoNonNullable()
        {
            var typeInfo1 = new StorageTypeInformation(typeof(string), "X", DbType.Int32, false, typeof(int), new DefaultConverter(typeof(string)));
            var typeInfo2 = new StorageTypeInformation(typeof(string), "X", DbType.Int32, false, typeof(int), new DefaultConverter(typeof(string)));
            var typeInfo3 = new StorageTypeInformation(typeof(string), "X", DbType.Int32, false, typeof(int), new DefaultConverter(typeof(string)));

            var result = typeInfo1.UnifyForEquivalentProperties(new[] { typeInfo2, typeInfo3 });

            Assert.That(result, Is.TypeOf <StorageTypeInformation> ());
            Assert.That(((StorageTypeInformation)result).StorageType, Is.SameAs(typeof(string)));
            Assert.That(((StorageTypeInformation)result).StorageTypeName, Is.EqualTo("X"));
            Assert.That(((StorageTypeInformation)result).StorageDbType, Is.EqualTo(DbType.Int32));
            Assert.That(((StorageTypeInformation)result).IsStorageTypeNullable, Is.False);
            Assert.That(((StorageTypeInformation)result).DotNetType, Is.SameAs(typeof(int)));
            Assert.That(((StorageTypeInformation)result).DotNetTypeConverter, Is.SameAs(typeInfo1.DotNetTypeConverter));
        }
 private void CheckStorageTypeInformation(
     StorageTypeInformation storageTypeInformation,
     Type expectedStorageType,
     string expectedStorageTypeName,
     DbType expectedStorageDbType,
     bool expectedIsNullable,
     Type expectedDotNetType,
     IResolveConstraint dotNetTypeConverterConstraint)
 {
     Assert.That(storageTypeInformation.StorageType, Is.SameAs(expectedStorageType));
     Assert.That(storageTypeInformation.StorageTypeName, Is.EqualTo(expectedStorageTypeName));
     Assert.That(storageTypeInformation.StorageDbType, Is.EqualTo(expectedStorageDbType));
     Assert.That(storageTypeInformation.IsStorageTypeNullable, Is.EqualTo(expectedIsNullable));
     Assert.That(storageTypeInformation.DotNetType, Is.SameAs(expectedDotNetType));
     Assert.That(storageTypeInformation.DotNetTypeConverter, dotNetTypeConverterConstraint);
 }
        public void SetUp()
        {
            _storageTypeInformationProviderMock = MockRepository.GenerateStrictMock <IStorageTypeInformationProvider> ();
            _storageNameProviderStub            = MockRepository.GenerateStub <IStorageNameProvider>();

            _factory = new ValueStoragePropertyDefinitionFactory(_storageTypeInformationProviderMock, _storageNameProviderStub);

            _someClassDefinition = ClassDefinitionObjectMother.CreateClassDefinition();

            _someClassDefinitionWithoutBaseClass  = ClassDefinitionObjectMother.CreateClassDefinition();
            _someClassDefinitionWithBaseClass     = ClassDefinitionObjectMother.CreateClassDefinition(id: "some", baseClass: _someClassDefinitionWithoutBaseClass);
            _someClassDefinitionWithBaseBaseClass = ClassDefinitionObjectMother.CreateClassDefinition(id: "some", baseClass: _someClassDefinitionWithBaseClass);

            _fakeStorageTypeInformation1 = StorageTypeInformationObjectMother.CreateStorageTypeInformation();
            _fakeStorageTypeInformation2 = StorageTypeInformationObjectMother.CreateStorageTypeInformation();
        }
 public void SetUp()
 {
     _typeConverterStub      = MockRepository.GenerateStub <TypeConverter>();
     _storageTypeInformation = new StorageTypeInformation(typeof(bool), "test", DbType.Boolean, false, typeof(int), _typeConverterStub);
 }
        public void SetUp()
        {
            _storageTypeInformation = StorageTypeInformationObjectMother.CreateStorageTypeInformation();

            _columnDefinition = new ColumnDefinition("Name", _storageTypeInformation, true);
        }