public void GetIdentifier_ReturnsIdentifier() { var provider = BindableObjectProvider.GetProviderForBindableObjectType(typeof(TypeOne)); var typeOneClass = provider.GetBindableObjectClass(typeof(TypeOne)); IBusinessObjectPropertyPath path = StaticBusinessObjectPropertyPath.Parse("TypeTwoValue.TypeThreeValue.TypeFourValue.IntValue", typeOneClass); Assert.That(path.Identifier, Is.EqualTo("TypeTwoValue.TypeThreeValue.TypeFourValue.IntValue")); }
public void GetIsDynamic_ReturnsFalse() { var provider = BindableObjectProvider.GetProviderForBindableObjectType(typeof(TypeOne)); var typeOneClass = provider.GetBindableObjectClass(typeof(TypeOne)); IBusinessObjectPropertyPath path = StaticBusinessObjectPropertyPath.Parse("TypeTwoValue", typeOneClass); Assert.That(path.IsDynamic, Is.False); }
public void Parse_InvalidPropertyPath_NonLastPropertyNotReferenceProperty_ThrowsParseException() { var root = TypeOne.Create(); Assert.That( () => StaticBusinessObjectPropertyPath.Parse("TypeTwoValue.IntValue.TypeFourValue", ((IBusinessObject)root).BusinessObjectClass), Throws.TypeOf <ParseException>()); }
public void Parse_InvalidPropertyPath_PropertyNotFound_ThrowsParseException() { var root = TypeOne.Create(); Assert.That( () => StaticBusinessObjectPropertyPath.Parse("TypeTwoValue.TypeThreeValue.TypeFourValue1", ((IBusinessObject)root).BusinessObjectClass), Throws.TypeOf <ParseException>()); }
public void Create_FromSingleProperty() { var provider = BindableObjectProvider.GetProviderForBindableObjectType(typeof(TypeOne)); var properties = new[] { provider.GetBindableObjectClass(typeof(TypeOne)).GetPropertyDefinition("TypeTwoValue") }; var path = StaticBusinessObjectPropertyPath.Create(properties); Assert.That(path.Properties, Is.EqualTo(properties)); Assert.That(path.Identifier, Is.EqualTo("TypeTwoValue")); }
public void GetProperties_ThrowsNotSupportedException() { var provider = BindableObjectProvider.GetProviderForBindableObjectType(typeof(TypeOne)); var typeOneClass = provider.GetBindableObjectClass(typeof(TypeOne)); var expectedProperties = new[] { typeOneClass.GetPropertyDefinition("TypeTwoValue"), provider.GetBindableObjectClass(typeof(TypeTwo)).GetPropertyDefinition("TypeThreeValue"), provider.GetBindableObjectClass(typeof(TypeThree)).GetPropertyDefinition("TypeFourValue"), provider.GetBindableObjectClass(typeof(TypeFour)).GetPropertyDefinition("IntValue"), }; IBusinessObjectPropertyPath path = StaticBusinessObjectPropertyPath.Parse("TypeTwoValue.TypeThreeValue.TypeFourValue.IntValue", typeOneClass); Assert.That(() => path.Properties, Is.EqualTo(expectedProperties)); }
public void GetResult_ValidPropertyPath_EndsWithReferenceProperty() { var root = TypeOne.Create(); var path = StaticBusinessObjectPropertyPath.Parse( "TypeTwoValue.TypeThreeValue.TypeFourValue", ((IBusinessObject)root).BusinessObjectClass); var result = path.GetResult( (IBusinessObject)root, BusinessObjectPropertyPath.UnreachableValueBehavior.FailForUnreachableValue, BusinessObjectPropertyPath.ListValueBehavior.FailForListProperties); Assert.That(result, Is.InstanceOf <EvaluatedBusinessObjectPropertyPathResult>()); Assert.That(result.ResultObject, Is.SameAs(root.TypeTwoValue.TypeThreeValue)); Assert.That(result.ResultProperty.Identifier, Is.EqualTo("TypeFourValue")); }
public void Create_ContainsNonReferenceProperty_ThrowsArgumentException() { var provider = BindableObjectProvider.GetProviderForBindableObjectType(typeof(TypeOne)); var properties = new[] { provider.GetBindableObjectClass(typeof(TypeOne)).GetPropertyDefinition("TypeTwoValue"), provider.GetBindableObjectClass(typeof(TypeTwo)).GetPropertyDefinition("IntValue"), provider.GetBindableObjectClass(typeof(TypeThree)).GetPropertyDefinition("TypeFourValue"), provider.GetBindableObjectClass(typeof(TypeFour)).GetPropertyDefinition("IntValue"), }; Assert.That( () => StaticBusinessObjectPropertyPath.Create(properties), Throws.ArgumentException.With.Message.StartsWith( "Property #1 ('IntValue') is not of type IBusinessObjectReferenceProperty. Every property except the last property must be a reference property.")); }
public void Create_NextPropertyNotPartOfClass_ThrowsArgumentException() { var provider = BindableObjectProvider.GetProviderForBindableObjectType(typeof(TypeOne)); var properties = new[] { provider.GetBindableObjectClass(typeof(TypeOne)).GetPropertyDefinition("TypeTwoValue"), provider.GetBindableObjectClass(typeof(TypeThree)).GetPropertyDefinition("TypeFourValue"), provider.GetBindableObjectClass(typeof(TypeFour)).GetPropertyDefinition("IntValue"), }; Assert.That( () => StaticBusinessObjectPropertyPath.Create(properties), Throws.ArgumentException.With.Message.StartsWith( "Property #1 ('TypeFourValue') is not part of the previous business object class " + "'Remotion.ObjectBinding.UnitTests.BusinessObjectPropertyPaths.TestDomain.TypeTwo, Remotion.ObjectBinding.UnitTests'." + " The property path must form a continuous chain.")); }
public void GetResult_ValidPropertyPath_EndsWithInt() { var root = TypeOne.Create(); IBusinessObjectPropertyPath path = StaticBusinessObjectPropertyPath.Parse( "TypeTwoValue.TypeThreeValue.TypeFourValue.IntValue", ((IBusinessObject)root).BusinessObjectClass); var result = path.GetResult( (IBusinessObject)root, BusinessObjectPropertyPath.UnreachableValueBehavior.FailForUnreachableValue, BusinessObjectPropertyPath.ListValueBehavior.FailForListProperties); Assert.That(result, Is.InstanceOf <EvaluatedBusinessObjectPropertyPathResult>()); Assert.That(result.ResultObject, Is.SameAs(root.TypeTwoValue.TypeThreeValue.TypeFourValue)); Assert.That( result.ResultProperty, Is.SameAs(((IBusinessObject)root.TypeTwoValue.TypeThreeValue.TypeFourValue).BusinessObjectClass.GetPropertyDefinition("IntValue"))); }
public static IBusinessObjectPropertyPath CreateStatic(IBusinessObjectProperty[] properties) { return(StaticBusinessObjectPropertyPath.Create(properties)); }
public static IBusinessObjectPropertyPath CreateStatic(IBusinessObjectClass objectClass, string propertyPathIdentifier) { return(StaticBusinessObjectPropertyPath.Parse(propertyPathIdentifier, objectClass)); }
public static IBusinessObjectPropertyPath CreatePropertyPath(this IBusinessObjectProvider provider, IBusinessObjectProperty[] properties) { ArgumentUtility.CheckNotNullOrEmpty("properties", properties); return(StaticBusinessObjectPropertyPath.Create(properties)); }