Example #1
0
        public void SetUp()
        {
            _storageProviderDefinition = new UnitTestStorageProviderStubDefinition("SPID");

            _objectIDProperty  = ObjectIDStoragePropertyDefinitionObjectMother.ObjectIDProperty;
            _timestampProperty = SimpleStoragePropertyDefinitionObjectMother.TimestampProperty;
            _property1         = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("Column1");
            _property2         = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("Column2");
            _property3         = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("Column3");

            _constraints = new[]
            { new PrimaryKeyConstraintDefinition("PK_Table", true, new[] { ColumnDefinitionObjectMother.IDColumn }) };
            _indexes  = new[] { MockRepository.GenerateStub <IIndexDefinition>() };
            _synonyms = new[] { new EntityNameDefinition(null, "Test") };

            _tableDefinition = new TableDefinition(
                _storageProviderDefinition,
                new EntityNameDefinition("TableSchema", "TableTest"),
                new EntityNameDefinition("Schema", "Test"),
                _objectIDProperty,
                _timestampProperty,
                new[] { _property1, _property2, _property3 },
                _constraints,
                _indexes,
                _synonyms);
        }
Example #2
0
        public void SetUp()
        {
            _storageProviderDefinition = new UnitTestStorageProviderStubDefinition("SPID");

            _timestampProperty = SimpleStoragePropertyDefinitionObjectMother.TimestampProperty;
            _objectIDProperty  = ObjectIDStoragePropertyDefinitionObjectMother.ObjectIDProperty;
            _property1         = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("Column1");
            _property2         = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("Column2");
            _property3         = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("Column3");

            _synonyms = new[] { new EntityNameDefinition(null, "Test") };

            _baseEntityDefinition = TableDefinitionObjectMother.Create(_storageProviderDefinition);

            _indexes = new[] { MockRepository.GenerateStub <IIndexDefinition>() };
            _filterViewDefinition = new FilterViewDefinition(
                _storageProviderDefinition,
                new EntityNameDefinition("Schema", "Test"),
                _baseEntityDefinition,
                new[] { "ClassId1", "ClassId2" },
                _objectIDProperty,
                _timestampProperty,
                new[] { _property1, _property2, _property3 },
                _indexes,
                _synonyms);
        }
Example #3
0
        public override void SetUp()
        {
            base.SetUp();

            _factory = new SqlFilterViewScriptElementFactory();

            var tableDefinitionWithCustomSchema = TableDefinitionObjectMother.Create(
                SchemaGenerationFirstStorageProviderDefinition,
                new EntityNameDefinition("SchemaName", "TableName1"));
            var tableDefinitionWithDefaultSchema = TableDefinitionObjectMother.Create(
                SchemaGenerationFirstStorageProviderDefinition,
                new EntityNameDefinition(null, "TableName2"));

            var property1 = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("Column1");
            var property2 = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("Column2");

            _filterViewDefinitionWithCustomSchema = FilterViewDefinitionObjectMother.Create(
                SchemaGenerationFirstStorageProviderDefinition,
                new EntityNameDefinition("SchemaName", "FilterView1"),
                tableDefinitionWithCustomSchema,
                new[] { "ClassID1" },
                ObjectIDStoragePropertyDefinitionObjectMother.ObjectIDProperty,
                SimpleStoragePropertyDefinitionObjectMother.TimestampProperty,
                new[] { property1 });
            _filterViewDefinitionWithDefaultSchema = FilterViewDefinitionObjectMother.Create(
                SchemaGenerationFirstStorageProviderDefinition,
                new EntityNameDefinition(null, "FilterView2"),
                tableDefinitionWithDefaultSchema,
                new[] { "ClassID1", "ClassID2" },
                ObjectIDStoragePropertyDefinitionObjectMother.ObjectIDProperty,
                SimpleStoragePropertyDefinitionObjectMother.TimestampProperty,
                new[] { property1, property2 });
        }
Example #4
0
        public void InheritanceRoot_PersistentPropertiesWithSameStorageSpecificPropertyNameInDifferentLeavesOfInheritanceTree()
        {
            var propertyDefinition1 = CreatePersistentPropertyDefinition(
                _derivedClass,
                "FirstName1",
                SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("Property"));
            var propertyDefinition2 = CreatePersistentPropertyDefinition(
                _derivedBaseClass2,
                "FirstName2",
                SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("Property"));

            _baseOfBaseClass.SetPropertyDefinitions(new PropertyDefinitionCollection());
            _derivedBaseClass1.SetPropertyDefinitions(new PropertyDefinitionCollection());
            _derivedBaseClass2.SetPropertyDefinitions(new PropertyDefinitionCollection(new[] { propertyDefinition2 }, true));
            _derivedClass.SetPropertyDefinitions(new PropertyDefinitionCollection(new[] { propertyDefinition1 }, true));
            _derivedClass.SetReadOnly();
            _derivedBaseClass2.SetReadOnly();

            var validationResult = _validationRule.Validate(_baseOfBaseClass);

            var expectedMessage =
                "Property 'FirstName1FakeProperty' of class 'OtherDerivedValidationHierarchyClass' must not define storage specific name 'Property', "
                + "because class 'DerivedValidationDomainObjectClass' in same inheritance hierarchy already defines property 'FirstName2FakeProperty' with "
                + "the same storage specific name.\r\n\r\n"
                + "Declaring type: Remotion.Data.DomainObjects.UnitTests.Mapping.TestDomain.Validation.DerivedValidationDomainObjectClass\r\n"
                + "Property: FirstName2FakeProperty";

            AssertMappingValidationResult(validationResult, false, expectedMessage);
        }
Example #5
0
        public void SetUp()
        {
            _storageProviderID         = "DefaultStorageProvider";
            _storageProviderDefinition = new UnitTestStorageProviderStubDefinition(_storageProviderID);
            _infrastructureStoragePropertyDefinitionProviderMock = MockRepository.GenerateStrictMock <IInfrastructureStoragePropertyDefinitionProvider>();
            _storagePropertyDefinitionResolverMock = MockRepository.GenerateStrictMock <IStoragePropertyDefinitionResolver>();
            _storageNameProviderMock = MockRepository.GenerateStrictMock <IStorageNameProvider>();
            _foreignKeyConstraintDefinitionFactoryMock = MockRepository.GenerateStrictMock <IForeignKeyConstraintDefinitionFactory>();
            _factory = new RdbmsStorageEntityDefinitionFactory(
                _infrastructureStoragePropertyDefinitionProviderMock,
                _foreignKeyConstraintDefinitionFactoryMock,
                _storagePropertyDefinitionResolverMock,
                _storageNameProviderMock,
                _storageProviderDefinition);
            _testModel = new RdbmsPersistenceModelLoaderTestHelper();

            _fakeObjectIDStorageProperty  = ObjectIDStoragePropertyDefinitionObjectMother.ObjectIDProperty;
            _fakeStorageProperty1         = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("Test1");
            _fakeTimestampStorageProperty = SimpleStoragePropertyDefinitionObjectMother.TimestampProperty;

            _fakeForeignKeyConstraint = new ForeignKeyConstraintDefinition(
                "FakeForeignKeyConstraint",
                new EntityNameDefinition(null, "Test"),
                new[] { StoragePropertyDefinitionTestHelper.GetIDColumnDefinition(_fakeObjectIDStorageProperty) },
                new[] { _fakeStorageProperty1.ColumnDefinition });
        }
Example #6
0
        public void InheritanceRoot_PersistentPropertiesWithSameStorageSpecificPropertyNameInSameClass()
        {
            var classDefinition     = ClassDefinitionObjectMother.CreateClassDefinitionWithMixins(typeof(DerivedValidationDomainObjectClass));
            var propertyDefinition1 = CreatePersistentPropertyDefinition(
                classDefinition,
                "Property",
                SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("Property"));
            var propertyDefinition2 = CreatePersistentPropertyDefinition(
                classDefinition,
                "PropertyWithStorageClassPersistent",
                SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("Property"));

            classDefinition.SetDerivedClasses(new ClassDefinition[0]);
            classDefinition.SetPropertyDefinitions(new PropertyDefinitionCollection(new[] { propertyDefinition1, propertyDefinition2 }, true));
            classDefinition.SetReadOnly();

            var validationResult = _validationRule.Validate(classDefinition);

            var expectedMessage =
                "Property 'PropertyWithStorageClassPersistentFakeProperty' of class 'DerivedValidationDomainObjectClass' must not define storage specific "
                + "name 'Property', because class 'DerivedValidationDomainObjectClass' in same inheritance hierarchy already defines property "
                + "'PropertyFakeProperty' with the same storage specific name.\r\n\r\n"
                + "Declaring type: Remotion.Data.DomainObjects.UnitTests.Mapping.TestDomain.Validation.DerivedValidationDomainObjectClass\r\n"
                + "Property: PropertyFakeProperty";

            AssertMappingValidationResult(validationResult, false, expectedMessage);
        }
Example #7
0
        public override void SetUp()
        {
            base.SetUp();

            _dbCommandBuilderFactoryStrictMock = MockRepository.GenerateStrictMock <IDbCommandBuilderFactory>();

            _objectReaderFactoryStrictMock = MockRepository.GenerateStrictMock <IObjectReaderFactory>();
            _dataStoragePropertyDefinitionFactoryStrictMock = MockRepository.GenerateStrictMock <IDataStoragePropertyDefinitionFactory> ();

            _factory = new QueryCommandFactory(
                _objectReaderFactoryStrictMock,
                _dbCommandBuilderFactoryStrictMock,
                _dataStoragePropertyDefinitionFactoryStrictMock);

            _dataContainerReader1Stub = MockRepository.GenerateStub <IObjectReader <DataContainer> >();
            _resultRowReaderStub      = MockRepository.GenerateStub <IObjectReader <IQueryResultRow> >();

            _queryParameter1 = new QueryParameter("first", DomainObjectIDs.Order1);
            _queryParameter2 = new QueryParameter("second", DomainObjectIDs.Order3.Value);
            _queryParameter3 = new QueryParameter("third", DomainObjectIDs.Official1);
            var collection = new QueryParameterCollection {
                _queryParameter1, _queryParameter2, _queryParameter3
            };

            _queryStub = MockRepository.GenerateStub <IQuery>();
            _queryStub.Stub(stub => stub.Statement).Return("statement");
            _queryStub.Stub(stub => stub.Parameters).Return(new QueryParameterCollection(collection, true));

            _property1 = ObjectIDStoragePropertyDefinitionObjectMother.Create("Test");
            _property2 = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty();
            _property3 = SerializedObjectIDStoragePropertyDefinitionObjectMother.Create("Test");
        }
        public void SetStorageProperty()
        {
            PropertyDefinition propertyDefinition = PropertyDefinitionObjectMother.CreateForFakePropertyInfo(_classDefinition);
            var storagePropertyDefinition         = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("Test");

            propertyDefinition.SetStorageProperty(storagePropertyDefinition);

            Assert.That(propertyDefinition.StoragePropertyDefinition, Is.SameAs(storagePropertyDefinition));
        }
        public void UnifyWithEquivalentProperties_ThrowsForDifferentStoragePropertyType()
        {
            var property2 = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty();

            Assert.That(
                () => _serializedObjectIDStoragePropertyDefinition.UnifyWithEquivalentProperties(new[] { property2 }),
                Throws.ArgumentException.With.Message.EqualTo(
                    "Only equivalent properties can be combined, but this property has type 'SerializedObjectIDStoragePropertyDefinition', and the "
                    + "given property has type 'SimpleStoragePropertyDefinition'.\r\nParameter name: equivalentProperties"));
        }
Example #10
0
        public void GetMetadata_ForSingleProperty()
        {
            PropertyReflector propertyReflector = CreatePropertyReflector <ClassWithAllDataTypes> ("BooleanProperty", DomainModelConstraintProviderStub);

            PropertyDefinition actual = propertyReflector.GetMetadata();

            actual.SetStorageProperty(SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty());

            Assert.That(actual, Is.Not.Null);
            Assert.That(actual.PropertyName, Is.EqualTo("Remotion.Data.DomainObjects.UnitTests.Mapping.TestDomain.Integration.ClassWithAllDataTypes.BooleanProperty"));
            Assert.That(actual.PropertyType, Is.SameAs(typeof(bool)));
        }
Example #11
0
        public void GetMetadata_WithStorageClassPersistent()
        {
            var propertyReflector = CreatePropertyReflector <ClassWithPropertiesHavingStorageClassAttribute> (
                "Persistent", DomainModelConstraintProviderStub);

            var actual = propertyReflector.GetMetadata();

            actual.SetStorageProperty(SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("Persistent"));

            Assert.That(actual.PropertyName, Is.EqualTo("Remotion.Data.DomainObjects.UnitTests.Mapping.TestDomain.Integration.ReflectionBasedMappingSample.ClassWithPropertiesHavingStorageClassAttribute.Persistent"));
            Assert.That(actual.StorageClass, Is.EqualTo(StorageClass.Persistent));
        }
Example #12
0
        public void InheritanceRoot_NonPersistentPropertiesWithSameStorageSpecificPropertyName()
        {
            var propertyDefinition1 = CreateNonPersistentPropertyDefinition(
                _derivedBaseClass2, "Test1", SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("Column"));
            var propertyDefinition2 = CreatePersistentPropertyDefinition(
                _derivedBaseClass2, "Test2", SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("Column"));

            _baseOfBaseClass.SetPropertyDefinitions(new PropertyDefinitionCollection());
            _derivedBaseClass1.SetPropertyDefinitions(new PropertyDefinitionCollection());
            _derivedBaseClass2.SetPropertyDefinitions(new PropertyDefinitionCollection(new[] { propertyDefinition1, propertyDefinition2 }, true));
            _derivedBaseClass2.SetReadOnly();

            var validationResult = _validationRule.Validate(_derivedBaseClass2);

            AssertMappingValidationResult(validationResult, true, null);
        }
Example #13
0
        private PropertyDefinition CreatePropertyDefinition(ClassDefinition classDefinition, string propertyName, string columnName)
        {
            var propertyInformationStub = MockRepository.GenerateStub <IPropertyInformation>();

            propertyInformationStub.Stub(_ => _.PropertyType).Return(typeof(string));
            var propertyDefinition = new PropertyDefinition(
                classDefinition,
                propertyInformationStub,
                propertyName,
                true,
                true,
                null,
                StorageClass.Persistent);

            propertyDefinition.SetStorageProperty(SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty(columnName));
            return(propertyDefinition);
        }
Example #14
0
        public void SetUp()
        {
            _storageProviderDefinition = new UnitTestStorageProviderStubDefinition("SPID");

            _timestampProperty = SimpleStoragePropertyDefinitionObjectMother.TimestampProperty;
            _objectIDProperty  = ObjectIDStoragePropertyDefinitionObjectMother.ObjectIDProperty;
            _property1         = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("Column1");
            _property2         = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("Column2");
            _property3         = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("Column3");

            _synonyms            = new[] { new EntityNameDefinition("Schema", "Test") };
            _emptyViewDefinition = new EmptyViewDefinition(
                _storageProviderDefinition,
                new EntityNameDefinition("Schema", "Test"),
                _objectIDProperty,
                _timestampProperty,
                new[] { _property1, _property2, _property3 },
                _synonyms);
        }
Example #15
0
        public void PropertyWithStorageClassPersistent_SupportedType()
        {
            var propertyDefinition = new PropertyDefinition(
                _classDefinition,
                PropertyInfoAdapter.Create(typeof(DerivedValidationDomainObjectClass).GetProperty("PropertyWithStorageClassPersistent")),
                "PropertyWithStorageClassPersistent",
                false,
                true,
                20,
                StorageClass.Persistent);

            propertyDefinition.SetStorageProperty(SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("PropertyWithStorageClassPersistent"));
            _classDefinition.SetPropertyDefinitions(new PropertyDefinitionCollection(new[] { propertyDefinition }, true));
            _classDefinition.SetReadOnly();

            var validationResult = _validationRule.Validate(_classDefinition);

            AssertMappingValidationResult(validationResult, true, null);
        }
Example #16
0
        public void InheritanceRoot_ThreePersistentPropertiesWithSameStorageSpecificPropertyName()
        {
            var propertyDefinition1 = CreatePersistentPropertyDefinition(
                _baseOfBaseClass,
                "FirstName1",
                SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("Property"));
            var propertyDefinition2 = CreatePersistentPropertyDefinition(
                _derivedBaseClass1,
                "FirstName2",
                SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("Property"));
            var propertyDefinition3 = CreatePersistentPropertyDefinition(
                _derivedClass,
                "FirstName3",
                SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("Property"));

            _baseOfBaseClass.SetPropertyDefinitions(new PropertyDefinitionCollection(new[] { propertyDefinition1 }, true));
            _derivedBaseClass1.SetPropertyDefinitions(new PropertyDefinitionCollection(new[] { propertyDefinition2 }, true));
            _derivedBaseClass2.SetPropertyDefinitions(new PropertyDefinitionCollection());
            _derivedClass.SetPropertyDefinitions(new PropertyDefinitionCollection(new[] { propertyDefinition3 }, true));
            _derivedBaseClass1.SetReadOnly();

            var validationResults = _validationRule.Validate(_baseOfBaseClass).ToArray();

            Assert.That(validationResults.Length, Is.EqualTo(2));

            var expectedMessage1 =
                "Property 'FirstName2FakeProperty' of class 'BaseValidationDomainObjectClass' must not define storage specific name 'Property', because "
                + "class 'BaseOfBaseValidationDomainObjectClass' in same inheritance hierarchy already defines property 'FirstName1FakeProperty' with the "
                + "same storage specific name.\r\n\r\n"
                + "Declaring type: Remotion.Data.DomainObjects.UnitTests.Mapping.TestDomain.Validation.BaseOfBaseValidationDomainObjectClass\r\n"
                + "Property: FirstName1FakeProperty";
            var expectedMessage2 =
                "Property 'FirstName3FakeProperty' of class 'OtherDerivedValidationHierarchyClass' must not define storage specific name 'Property', "
                + "because class 'BaseOfBaseValidationDomainObjectClass' in same inheritance hierarchy already defines property 'FirstName1FakeProperty' "
                + "with the same storage specific name.\r\n\r\n"
                + "Declaring type: Remotion.Data.DomainObjects.UnitTests.Mapping.TestDomain.Validation.BaseOfBaseValidationDomainObjectClass\r\n"
                + "Property: FirstName1FakeProperty";

            AssertMappingValidationResult(validationResults[0], false, expectedMessage1);
            AssertMappingValidationResult(validationResults[1], false, expectedMessage2);
        }
Example #17
0
        public void InheritanceRoot_PersistentPropertiesWithDifferentStorageSpecificPropertyNameInSameClass()
        {
            var classDefinition = ClassDefinitionObjectMother.CreateClassDefinitionWithMixins(typeof(DerivedValidationDomainObjectClass));

            var propertyDefinition1 = CreatePersistentPropertyDefinition(
                classDefinition,
                "FirstName1",
                SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("Property1"));
            var propertyDefinition2 = CreatePersistentPropertyDefinition(
                classDefinition,
                "FirstName2",
                SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("Property2"));

            classDefinition.SetDerivedClasses(new ClassDefinition[0]);
            classDefinition.SetPropertyDefinitions(new PropertyDefinitionCollection(new[] { propertyDefinition1, propertyDefinition2 }, true));
            classDefinition.SetReadOnly();

            var validationResult = _validationRule.Validate(classDefinition);

            AssertMappingValidationResult(validationResult, true, null);
        }
        public override void SetUp()
        {
            base.SetUp();

            _factory = new SqlTableViewScriptElementFactory();

            _tableDefinitionWithCustomSchema = TableDefinitionObjectMother.Create(
                SchemaGenerationFirstStorageProviderDefinition,
                new EntityNameDefinition("SchemaName", "Table1"),
                new EntityNameDefinition("SchemaName", "View1"),
                ObjectIDStoragePropertyDefinitionObjectMother.ObjectIDProperty,
                SimpleStoragePropertyDefinitionObjectMother.TimestampProperty,
                SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("Column1"));
            _tableDefinitionWithDefaultSchema = TableDefinitionObjectMother.Create(
                SchemaGenerationFirstStorageProviderDefinition,
                new EntityNameDefinition(null, "Table2"),
                new EntityNameDefinition(null, "View2"),
                ObjectIDStoragePropertyDefinitionObjectMother.ObjectIDProperty,
                SimpleStoragePropertyDefinitionObjectMother.TimestampProperty,
                SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("Column1"));
        }
Example #19
0
        public override void SetUp()
        {
            base.SetUp();

            _storageProviderDefinitionFinder = new StorageGroupBasedStorageProviderDefinitionFinder(DomainObjectsConfiguration.Current.Storage);
            _storageProviderDefinition       = (RdbmsProviderDefinition)_storageProviderDefinitionFinder.GetStorageProviderDefinition(
                storageGroupTypeOrNull: null, errorMessageContext: "SetUp");

            var factory = _storageProviderDefinition.Factory;

            _rdbmsPersistenceModelLoader =
                (RdbmsPersistenceModelLoader)factory.CreatePersistenceModelLoader(_storageProviderDefinition, _storageProviderDefinitionFinder);

            _testModel = new RdbmsPersistenceModelLoaderTestHelper();

            var infrastructureStoragePropertyDefinitionProvider =
                ((RdbmsStorageEntityDefinitionFactory)_rdbmsPersistenceModelLoader.EntityDefinitionFactory).InfrastructureStoragePropertyDefinitionProvider;

            _infrastructureObjectIDStoragePropertyDefinition  = infrastructureStoragePropertyDefinitionProvider.GetObjectIDStoragePropertyDefinition();
            _infrastructureIDStoragePropertyDefinition        = (SimpleStoragePropertyDefinition)_infrastructureObjectIDStoragePropertyDefinition.ValueProperty;
            _infrastructureClassIDStoragePropertyDefinition   = (SimpleStoragePropertyDefinition)_infrastructureObjectIDStoragePropertyDefinition.ClassIDProperty;
            _infrastructureTimestampStoragePropertyDefinition =
                (SimpleStoragePropertyDefinition)infrastructureStoragePropertyDefinitionProvider.GetTimestampStoragePropertyDefinition();

            _fakeBaseBaseStoragePropertyDefinition       = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("BaseBaseProperty");
            _fakeBaseStoragePropertyDefinition           = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("BaseProperty");
            _fakeTableStoragePropertyDefinition1         = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("TableProperty1");
            _fakeTableStoragePropertyDefinition2         = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("TableProperty2");
            _fakeDerivedStoragePropertyDefinition1       = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("DerivedProperty1");
            _fakeDerivedStoragePropertyDefinition2       = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("DerivedProperty2");
            _fakeDerivedDerivedStoragePropertyDefinition = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("DerivedDerivedProperty");

            _testModel.BaseBasePropertyDefinition.SetStorageProperty(_fakeBaseBaseStoragePropertyDefinition);
            _testModel.BasePropertyDefinition.SetStorageProperty(_fakeBaseStoragePropertyDefinition);
            _testModel.TablePropertyDefinition1.SetStorageProperty(_fakeTableStoragePropertyDefinition1);
            _testModel.TablePropertyDefinition2.SetStorageProperty(_fakeTableStoragePropertyDefinition2);
            _testModel.DerivedPropertyDefinition1.SetStorageProperty(_fakeDerivedStoragePropertyDefinition1);
            _testModel.DerivedPropertyDefinition2.SetStorageProperty(_fakeDerivedStoragePropertyDefinition2);
            _testModel.DerivedDerivedPropertyDefinition.SetStorageProperty(_fakeDerivedDerivedStoragePropertyDefinition);
        }
Example #20
0
        public void SetUp()
        {
            _persistenceModelProviderStub = MockRepository.GenerateStub <IRdbmsPersistenceModelProvider>();
            _resolver  = new StoragePropertyDefinitionResolver(_persistenceModelProviderStub);
            _testModel = new RdbmsPersistenceModelLoaderTestHelper();

            _fakeStorageProperyDefinition1 = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("Test1");
            _fakeStorageProperyDefinition2 = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("Test2");
            _fakeStorageProperyDefinition3 = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("Test3");
            _fakeStorageProperyDefinition4 = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("Test4");
            _fakeStorageProperyDefinition5 = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("Test5");
            _fakeStorageProperyDefinition6 = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("Test6");
            _fakeStorageProperyDefinition7 = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("Test7");

            _persistenceModelProviderStub
            .Stub(stub => stub.GetStoragePropertyDefinition(_testModel.BaseBasePropertyDefinition))
            .Return(_fakeStorageProperyDefinition1);
            _persistenceModelProviderStub
            .Stub(stub => stub.GetStoragePropertyDefinition(_testModel.BaseBasePropertyDefinition))
            .Return(_fakeStorageProperyDefinition1);
            _persistenceModelProviderStub
            .Stub(stub => stub.GetStoragePropertyDefinition(_testModel.BasePropertyDefinition))
            .Return(_fakeStorageProperyDefinition2);
            _persistenceModelProviderStub
            .Stub(stub => stub.GetStoragePropertyDefinition(_testModel.TablePropertyDefinition1))
            .Return(_fakeStorageProperyDefinition3);
            _persistenceModelProviderStub
            .Stub(stub => stub.GetStoragePropertyDefinition(_testModel.TablePropertyDefinition2))
            .Return(_fakeStorageProperyDefinition4);
            _persistenceModelProviderStub
            .Stub(stub => stub.GetStoragePropertyDefinition(_testModel.DerivedPropertyDefinition1))
            .Return(_fakeStorageProperyDefinition5);
            _persistenceModelProviderStub
            .Stub(stub => stub.GetStoragePropertyDefinition(_testModel.DerivedPropertyDefinition2))
            .Return(_fakeStorageProperyDefinition6);
            _persistenceModelProviderStub
            .Stub(stub => stub.GetStoragePropertyDefinition(_testModel.DerivedDerivedPropertyDefinition))
            .Return(_fakeStorageProperyDefinition7);
        }
Example #21
0
        public void InheritanceRoot_PersistentPropertiesWithDifferentStorageSpecificPropertyNameInDifferentLeavesOfInheritanceTree()
        {
            var propertyDefinition1 = CreatePersistentPropertyDefinition(
                _derivedClass,
                "FirstName1",
                SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("Property1"));
            var propertyDefinition2 = CreatePersistentPropertyDefinition(
                _derivedBaseClass2,
                "FirstName2",
                SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("Property2"));

            _baseOfBaseClass.SetPropertyDefinitions(new PropertyDefinitionCollection());
            _derivedBaseClass1.SetPropertyDefinitions(new PropertyDefinitionCollection());
            _derivedClass.SetPropertyDefinitions(new PropertyDefinitionCollection(new[] { propertyDefinition1 }, true));
            _derivedBaseClass2.SetPropertyDefinitions(new PropertyDefinitionCollection(new[] { propertyDefinition2 }, true));
            _derivedClass.SetReadOnly();
            _derivedBaseClass2.SetReadOnly();

            var validationResult = _validationRule.Validate(_baseOfBaseClass);

            AssertMappingValidationResult(validationResult, true, null);
        }
Example #22
0
        public override void SetUp()
        {
            base.SetUp();

            _factory = new SqlEmptyViewScriptElementFactory();

            var property1 = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("Column1", StorageTypeInformationObjectMother.CreateVarchar100StorageTypeInformation());
            var property2 = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("Column2", StorageTypeInformationObjectMother.CreateVarchar100StorageTypeInformation());

            _emptyViewDefinitionWithCustomSchema = EmptyViewDefinitionObjectMother.Create(
                SchemaGenerationFirstStorageProviderDefinition,
                new EntityNameDefinition("SchemaName", "EmptyView1"),
                ObjectIDStoragePropertyDefinitionObjectMother.ObjectIDProperty,
                SimpleStoragePropertyDefinitionObjectMother.TimestampProperty,
                new[] { property1 });
            _emptyViewDefinitionWithDefaultSchema = EmptyViewDefinitionObjectMother.Create(
                SchemaGenerationFirstStorageProviderDefinition,
                new EntityNameDefinition(null, "EmptyView2"),
                ObjectIDStoragePropertyDefinitionObjectMother.ObjectIDProperty,
                SimpleStoragePropertyDefinitionObjectMother.TimestampProperty,
                new[] { property1, property2 });
        }
Example #23
0
        public void InheritanceRoot_PersistentPropertiesFromSamePropertyInformation_InDifferentLeavesOfInheritanceTree()
        {
            var propertyInformation = new NullPropertyInformation();
            var propertyDefinition1 = CreatePersistentPropertyDefinition(
                _derivedClass,
                SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("Length"),
                propertyInformation);
            var propertyDefinition2 = CreatePersistentPropertyDefinition(
                _derivedBaseClass2,
                SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("Length"),
                propertyInformation);

            _baseOfBaseClass.SetPropertyDefinitions(new PropertyDefinitionCollection());
            _derivedBaseClass1.SetPropertyDefinitions(new PropertyDefinitionCollection());
            _derivedClass.SetPropertyDefinitions(new PropertyDefinitionCollection(new[] { propertyDefinition1 }, true));
            _derivedBaseClass2.SetPropertyDefinitions(new PropertyDefinitionCollection(new[] { propertyDefinition2 }, true));
            _derivedClass.SetReadOnly();
            _derivedBaseClass2.SetReadOnly();

            var validationResult = _validationRule.Validate(_baseOfBaseClass);

            AssertMappingValidationResult(validationResult, true, null);
        }
Example #24
0
        public void SetUp()
        {
            _storageProviderID         = "DefaultStorageProvider";
            _storageProviderDefinition = new UnitTestStorageProviderStubDefinition(_storageProviderID);
            _testModel = new RdbmsPersistenceModelLoaderTestHelper();

            _entityDefinitionFactoryMock = MockRepository.GenerateStrictMock <IRdbmsStorageEntityDefinitionFactory>();
            _dataStoragePropertyDefinitionFactoryMock = MockRepository.GenerateStrictMock <IDataStoragePropertyDefinitionFactory>();
            _storageNameProviderStub = MockRepository.GenerateStub <IStorageNameProvider>();
            _storageNameProviderStub.Stub(stub => stub.GetTableName(_testModel.TableClassDefinition1)).Return(
                new EntityNameDefinition(null, _testModel.TableClassDefinition1.ID));
            _storageNameProviderStub.Stub(stub => stub.GetTableName(_testModel.TableClassDefinition2)).Return(
                new EntityNameDefinition(null, _testModel.TableClassDefinition2.ID));

            _rdbmsPersistenceModelLoader = new RdbmsPersistenceModelLoader(
                _entityDefinitionFactoryMock,
                _dataStoragePropertyDefinitionFactoryMock,
                _storageNameProviderStub,
                new RdbmsPersistenceModelProvider());

            _fakeEntityDefinitionBaseBase              = MockRepository.GenerateStub <IRdbmsStorageEntityDefinition>();
            _fakeEntityDefinitionBase                  = MockRepository.GenerateStub <IRdbmsStorageEntityDefinition>();
            _fakeEntityDefinitionTable1                = MockRepository.GenerateStub <IRdbmsStorageEntityDefinition>();
            _fakeEntityDefinitionTable2                = MockRepository.GenerateStub <IRdbmsStorageEntityDefinition>();
            _fakeEntityDefinitionDerived1              = MockRepository.GenerateStub <IRdbmsStorageEntityDefinition>();
            _fakeEntityDefinitionDerived2              = MockRepository.GenerateStub <IRdbmsStorageEntityDefinition>();
            _fakeEntityDefinitionDerivedDerived        = MockRepository.GenerateStub <IRdbmsStorageEntityDefinition>();
            _fakeEntityDefinitionDerivedDerivedDerived = MockRepository.GenerateStub <IRdbmsStorageEntityDefinition>();

            _fakeColumnDefinition1 = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("Test1");
            _fakeColumnDefinition2 = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("Test2");
            _fakeColumnDefinition3 = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("Test3");
            _fakeColumnDefinition4 = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("Test4");
            _fakeColumnDefinition5 = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("Test5");
            _fakeColumnDefinition6 = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("Test6");
            _fakeColumnDefinition7 = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("Test7");
        }
Example #25
0
        public void CreateTableDefinition_WithoutPrimaryKey()
        {
            _storagePropertyDefinitionResolverMock
            .Expect(mock => mock.GetStoragePropertiesForHierarchy(_testModel.TableClassDefinition1))
            .Return(new IRdbmsStoragePropertyDefinition[0]);
            _storagePropertyDefinitionResolverMock.Replay();

            _foreignKeyConstraintDefinitionFactoryMock
            .Expect(mock => mock.CreateForeignKeyConstraints(_testModel.TableClassDefinition1))
            .Return(new ForeignKeyConstraintDefinition[0]);
            _foreignKeyConstraintDefinitionFactoryMock.Replay();

            _storageNameProviderMock
            .Expect(mock => mock.GetTableName(_testModel.TableClassDefinition1))
            .Return(new EntityNameDefinition(null, "FakeTableName"));
            _storageNameProviderMock
            .Expect(mock => mock.GetViewName(_testModel.TableClassDefinition1))
            .Return(new EntityNameDefinition(null, "FakeViewName"));
            _storageNameProviderMock.Replay();

            // no primary key columns!
            _infrastructureStoragePropertyDefinitionProviderMock
            .Expect(mock => mock.GetObjectIDStoragePropertyDefinition())
            .Return(new ObjectIDStoragePropertyDefinition(
                        SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty(),
                        SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty()));
            _infrastructureStoragePropertyDefinitionProviderMock
            .Expect(mock => mock.GetTimestampStoragePropertyDefinition())
            .Return(_fakeTimestampStorageProperty);

            _infrastructureStoragePropertyDefinitionProviderMock.Replay();

            var result = _factory.CreateTableDefinition(_testModel.TableClassDefinition1);

            Assert.That(result, Is.TypeOf <TableDefinition>().With.Property("Constraints").Empty);
        }
Example #26
0
 private static SimpleStoragePropertyDefinition CreateStorageProperyDefinitionWithNameAndNullability(string columnName, bool isStorageTypeNullable)
 {
     return(SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty(
                columnName,
                storageTypeInformation: StorageTypeInformationObjectMother.CreateStorageTypeInformation(isStorageTypeNullable: isStorageTypeNullable)));
 }