public void CreateStoragePropertyDefinition_RelationToClassDefinitionWithoutHierarchy() { var endPointDefinition = GetNonVirtualEndPointDefinition(typeof(ClassWithManySideRelationProperties), "BidirectionalOneToOne"); var oppositeClassDefinition = endPointDefinition.GetOppositeEndPointDefinition().ClassDefinition; Assert.That(oppositeClassDefinition.IsPartOfInheritanceHierarchy, Is.False); _storageTypeInformationProviderStrictMock .Expect(mock => mock.GetStorageTypeForID(true)) .Return(_fakeStorageTypeInformation1); _storageNameProviderMock .Expect(mock => mock.GetRelationColumnName(endPointDefinition)) .Return("FakeRelationColumnName"); _storageNameProviderMock .Expect(mock => mock.GetRelationClassIDColumnName(endPointDefinition)) .Return("FakeRelationClassIDColumnName"); _storageProviderDefinitionFinderStub .Stub(stub => stub.GetStorageProviderDefinition(oppositeClassDefinition, null)) .Return(_factory.StorageProviderDefinition); var result = _factory.CreateStoragePropertyDefinition(endPointDefinition); _storageTypeInformationProviderStrictMock.VerifyAllExpectations(); _storageNameProviderMock.VerifyAllExpectations(); Assert.That(result, Is.TypeOf(typeof(ObjectIDWithoutClassIDStoragePropertyDefinition))); var objectIDWithoutClassIDStorageProperty = ((ObjectIDWithoutClassIDStoragePropertyDefinition)result); Assert.That(objectIDWithoutClassIDStorageProperty.ValueProperty, Is.TypeOf(typeof(SimpleStoragePropertyDefinition))); var valueStoragePropertyDefinition = ((SimpleStoragePropertyDefinition)objectIDWithoutClassIDStorageProperty.ValueProperty); Assert.That(valueStoragePropertyDefinition.PropertyType, Is.SameAs(typeof(object))); Assert.That(valueStoragePropertyDefinition.ColumnDefinition.Name, Is.EqualTo("FakeRelationColumnName")); Assert.That(valueStoragePropertyDefinition.ColumnDefinition.StorageTypeInfo, Is.SameAs(_fakeStorageTypeInformation1)); Assert.That(valueStoragePropertyDefinition.ColumnDefinition.IsPartOfPrimaryKey, Is.False); Assert.That( objectIDWithoutClassIDStorageProperty.ClassDefinition, Is.SameAs(endPointDefinition.GetOppositeEndPointDefinition().ClassDefinition)); }
public void CreateStoragePropertyDefinition_PropertyDefinition_NotSupportedType() { var propertyDefinition = PropertyDefinitionObjectMother.CreateForFakePropertyInfo(_someClassDefinition, "Test"); var exception = new NotSupportedException("Msg."); _storageTypeInformationProviderMock .Expect(mock => mock.GetStorageType(Arg.Is(propertyDefinition), Arg <bool> .Is.Anything)) .Throw(exception); var result = _factory.CreateStoragePropertyDefinition(propertyDefinition); _storageTypeInformationProviderMock.VerifyAllExpectations(); Assert.That( result, Is.TypeOf <UnsupportedStoragePropertyDefinition>() .With.Property <UnsupportedStoragePropertyDefinition> (pd => pd.Message).EqualTo( "There was an error when retrieving storage type for property 'Test' (declaring class: '" + _someClassDefinition.ID + "'): Msg.") .And.Property <UnsupportedStoragePropertyDefinition> (pd => pd.PropertyType).EqualTo(typeof(string)) .And.Property <UnsupportedStoragePropertyDefinition> (pd => pd.InnerException).SameAs(exception)); }