Beispiel #1
0
        public void GetTableDefinition_TableDefinition()
        {
            var objectID = CreateObjectID(_tableDefinition);

            _rdbmsPersistenceModelProviderStub.Stub(stub => stub.GetEntityDefinition(objectID.ClassDefinition)).Return(_tableDefinition);

            var result = _finder.GetTableDefinition(objectID);

            Assert.That(result, Is.SameAs(_tableDefinition));
        }
Beispiel #2
0
        private PropertyDefinition CreatePropertyWithStubbedStorageProperty(
            ClassDefinition classDefinition, IRdbmsStoragePropertyDefinition storagePropertyDefinition, string propertyName, IPropertyInformation propertyInfo)
        {
            PropertyDefinition propertyDefinition = PropertyDefinitionObjectMother.CreateForPropertyInformation(classDefinition, propertyName, propertyInfo);

            _persistenceModelProviderStub
            .Stub(stub => stub.GetStoragePropertyDefinition(propertyDefinition))
            .Return(storagePropertyDefinition);
            return(propertyDefinition);
        }
Beispiel #3
0
        public void Read_DataReaderReadTrue_ThrowsException()
        {
            _dataReaderStrictMock.Expect(mock => mock.Read()).Return(true);

            _idPropertyStrictMock
            .Stub(stub => stub.CombineValue(Arg <IColumnValueProvider> .Is.Anything))
            .Return(DomainObjectIDs.OrderTicket1);
            _timestampPropertyStrictMock
            .Stub(stub => stub.CombineValue(Arg <IColumnValueProvider> .Is.Anything))
            .Return(_fakeTimestamp);
            ReplayAll();

            var propertyDefinition = GetPropertyDefinition(typeof(OrderTicket), "FileName");

            _persistenceModelProviderStub
            .Stub(stub => stub.GetStoragePropertyDefinition(propertyDefinition))
            .Throw(new InvalidOperationException("TestException"));

            _dataContainerReader.Read(_dataReaderStrictMock);
        }
Beispiel #4
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);
        }
Beispiel #5
0
        public void ResolveEntity()
        {
            var objectIDProperty  = ObjectIDStoragePropertyDefinitionObjectMother.ObjectIDProperty;
            var timestampProperty = SimpleStoragePropertyDefinitionObjectMother.TimestampProperty;

            var foreignKeyProperty = SimpleStoragePropertyDefinitionObjectMother.CreateGuidStorageProperty("ForeignKey");
            var simpleProperty     = SimpleStoragePropertyDefinitionObjectMother.CreateStringStorageProperty("Column1");

            var tableDefinition = TableDefinitionObjectMother.Create(
                TestDomainStorageProviderDefinition,
                new EntityNameDefinition(null, "Test"),
                null,
                objectIDProperty,
                timestampProperty,
                foreignKeyProperty,
                simpleProperty);

            _rdbmsPersistenceModelProviderStub
            .Stub(stub => stub.GetEntityDefinition(_classDefinition))
            .Return(tableDefinition);

            var result = _storageSpecificExpressionResolver.ResolveEntity(_classDefinition, "o");

            var expectedIdColumn         = new SqlColumnDefinitionExpression(typeof(Guid), "o", "ID", true);
            var expectedClassIdColumn    = new SqlColumnDefinitionExpression(typeof(string), "o", "ClassID", false);
            var expectedTimestampColumn  = new SqlColumnDefinitionExpression(typeof(DateTime), "o", "Timestamp", false);
            var expectedForeignKeyColumn = new SqlColumnDefinitionExpression(typeof(Guid), "o", "ForeignKey", false);
            var expectedColumn           = new SqlColumnDefinitionExpression(typeof(string), "o", "Column1", false);

            Assert.That(result.Type, Is.SameAs(typeof(Order)));
            Assert.That(result.TableAlias, Is.EqualTo("o"));
            Assert.That(result.Name, Is.Null);
            SqlExpressionTreeComparer.CheckAreEqualTrees(expectedIdColumn, result.GetIdentityExpression());
            Assert.That(result.Columns, Has.Count.EqualTo(5));
            SqlExpressionTreeComparer.CheckAreEqualTrees(expectedIdColumn, result.Columns[0]);
            SqlExpressionTreeComparer.CheckAreEqualTrees(expectedClassIdColumn, result.Columns[1]);
            SqlExpressionTreeComparer.CheckAreEqualTrees(expectedTimestampColumn, result.Columns[2]);
            SqlExpressionTreeComparer.CheckAreEqualTrees(expectedForeignKeyColumn, result.Columns[3]);
            SqlExpressionTreeComparer.CheckAreEqualTrees(expectedColumn, result.Columns[4]);
        }