public void ResolveDefinition_InterfaceImplementation_NotImplemented() { var property = PropertyInfoAdapter.Create(typeof(IInterfaceWithProperty).GetProperty("Property")); var classDefinition = GetTypeDefinition(typeof(ClassWithSimpleProperties)); // does not implement this property var result = ReflectionBasedPropertyResolver.ResolveDefinition(property, classDefinition, classDefinition.GetPropertyDefinition); Assert.That(result, Is.Null); }
public void ResolveDefinition_StorageClassNoneProperty() { var property = PropertyInfoAdapter.Create(typeof(ClassWithSimpleProperties).GetProperty("StorageClassNoneProperty")); var classDefinition = GetTypeDefinition(typeof(ClassWithSimpleProperties)); var result = ReflectionBasedPropertyResolver.ResolveDefinition(property, classDefinition, classDefinition.GetPropertyDefinition); Assert.That(result, Is.Null); }
public void ResolveDefinition_InterfaceImplementation_FromImplementationProperty() { var property = PropertyInfoAdapter.Create(typeof(ClassWithInterface).GetProperty("Property")); var classDefinition = GetTypeDefinition(typeof(ClassWithInterface)); var result = ReflectionBasedPropertyResolver.ResolveDefinition(property, classDefinition, classDefinition.GetPropertyDefinition); var expected = GetPropertyDefinition(typeof(ClassWithInterface), "Property"); Assert.That(result, Is.Not.Null); Assert.That(result, Is.SameAs(expected)); }
public void ResolveDefinition() { var property = PropertyInfoAdapter.Create(typeof(ClassWithSimpleProperties).GetProperty("StorageClassPersistentProperty")); var classDefinition = GetTypeDefinition(typeof(ClassWithSimpleProperties)); var result = ReflectionBasedPropertyResolver.ResolveDefinition(property, classDefinition, classDefinition.GetPropertyDefinition); var expected = GetPropertyDefinition(typeof(ClassWithSimpleProperties), "StorageClassPersistentProperty"); Assert.That(result, Is.Not.Null); Assert.That(result, Is.SameAs(expected)); }
public void ResolveDefinition_ClassWithSameInterfaceAsMixin_ButStorageClassNone() { var property = PropertyInfoAdapter.Create(typeof(IInterfaceWithProperty).GetProperty("Property")); var classDefinition = GetTypeDefinition(typeof(ClassWithSameInterfaceAsMixinWithStorageClassNone)); var result = ReflectionBasedPropertyResolver.ResolveDefinition(property, classDefinition, classDefinition.GetPropertyDefinition); var expected = GetPropertyDefinition(typeof(ClassWithSameInterfaceAsMixinWithStorageClassNone), typeof(MixinWithPersistentProperty), "Property"); Assert.That(result, Is.Not.Null); Assert.That(result, Is.SameAs(expected)); }
public void ResolveDefinition_MixinWithDuplicateInterface_DueToInheritance() { var property = PropertyInfoAdapter.Create(typeof(IInterfaceWithProperty).GetProperty("Property")); var classDefinition = GetTypeDefinition(typeof(ClassWithDerivedMixinDerivedFromClassWithMixinWithPersistentProperty)); var result = ReflectionBasedPropertyResolver.ResolveDefinition(property, classDefinition, classDefinition.GetPropertyDefinition); var expected = GetPropertyDefinition(typeof(ClassWithMixinWithPersistentProperty), typeof(MixinWithPersistentProperty), "Property"); Assert.That(result, Is.Not.Null); Assert.That(result, Is.SameAs(expected)); }
public void ResolveDefinition_ExplicitInterfaceImplementation_FromInterfaceProperty_FromDerivedClass() { var property = PropertyInfoAdapter.Create(typeof(IInterfaceWithProperty).GetProperty("Property")); var classDefinition = GetTypeDefinition(typeof(ClassDerivedFromClassWithInterfaceExplicitImplementation)); var result = ReflectionBasedPropertyResolver.ResolveDefinition(property, classDefinition, classDefinition.GetPropertyDefinition); var implementationPropertyName = property.DeclaringType.FullName + "." + property.Name; var expected = GetPropertyDefinition(typeof(ClassWithInterfaceExplicitImplementation), implementationPropertyName); Assert.That(result, Is.Not.Null); Assert.That(result, Is.SameAs(expected)); }
public void ResolveDefinition_ClassWithSameInterfaceAsMixin_BothStorageClassPersistent() { var property = PropertyInfoAdapter.Create(typeof(IInterfaceWithProperty).GetProperty("Property")); var classDefinition = GetTypeDefinition(typeof(ClassWithSameInterfaceAsMixinWithStorageClassPersistent)); Assert.That(() => ReflectionBasedPropertyResolver.ResolveDefinition( property, classDefinition, classDefinition.GetPropertyDefinition), Throws.TypeOf <InvalidOperationException> ().With.Message.EqualTo( "The property 'Property' is ambiguous, it is implemented by the following types valid in the context of class " + "'ClassWithSameInterfaceAsMixinWithStorageClassPersistent': " + "'Remotion.Data.DomainObjects.UnitTests.Mapping.TestDomain.ReflectionBasedPropertyResolver.ClassWithSameInterfaceAsMixinWithStorageClassPersistent', " + "'Remotion.Data.DomainObjects.UnitTests.Mapping.TestDomain.ReflectionBasedPropertyResolver.MixinWithPersistentProperty'.")); }
public void ResolveDefinition_ExplicitInterfaceImplementation_FromImplementationProperty() { var property = CreatePropertyInfoAdapterForExplicitImplementation( typeof(IInterfaceWithProperty), "Property", typeof(ClassWithInterfaceExplicitImplementation)); var classDefinition = GetTypeDefinition(typeof(ClassWithInterfaceExplicitImplementation)); var result = ReflectionBasedPropertyResolver.ResolveDefinition(property, classDefinition, classDefinition.GetPropertyDefinition); var expected = GetPropertyDefinition(typeof(ClassWithInterfaceExplicitImplementation), property.Name); Assert.That(result, Is.Not.Null); Assert.That(result, Is.SameAs(expected)); }