public void GetProviderForBindableObjectType()
        {
            BindableObjectProvider provider = BindableObjectProvider.GetProviderForBindableObjectType(typeof(SimpleBusinessObjectClass));

            Assert.That(provider, Is.Not.Null);
            Assert.That(provider, Is.SameAs(BusinessObjectProvider.GetProvider(typeof(BindableObjectProviderAttribute))));
        }
        public void NullabilityResolvedFromAboveInheritanceRoot()
        {
            var provider            = BindableObjectProvider.GetProviderForBindableObjectType(typeof(BindableDomainObjectAboveInheritanceRoot));
            var businessObjectClass = provider.GetBindableObjectClass(typeof(BindableDomainObjectAboveInheritanceRoot));

            var notNullableBooleanProperty = businessObjectClass.GetPropertyDefinition("NotNullableBooleanProperty");

            Assert.That(notNullableBooleanProperty.IsRequired, Is.True);

            var notNullableStringProperty = businessObjectClass.GetPropertyDefinition("NotNullableStringPropertyWithLengthConstraint");

            Assert.That(notNullableStringProperty.IsRequired, Is.True);

            var notNullableRelationProperty = businessObjectClass.GetPropertyDefinition("MandatoryUnidirectionalRelation");

            Assert.That(notNullableRelationProperty.IsRequired, Is.True);

            var nullableBooleanProperty = businessObjectClass.GetPropertyDefinition("NullableBooleanProperty");

            Assert.That(nullableBooleanProperty.IsRequired, Is.False);

            var nullableStringProperty = businessObjectClass.GetPropertyDefinition("NullableStringPropertyWithoutLengthConstraint");

            Assert.That(nullableStringProperty.IsRequired, Is.False);

            var nullableRelationProperty = businessObjectClass.GetPropertyDefinition("NotMandatoryUnidirectionalRelation");

            Assert.That(nullableRelationProperty.IsRequired, Is.False);
        }
Ejemplo n.º 3
0
        public IconProxy GetIcon(string businessObjectClass, string businessObject, string arguments)
        {
            if (businessObjectClass == null)
            {
                return(null);
            }

            Type type = TypeUtility.GetType(businessObjectClass, true);
            var  businessObjectProvider = BindableObjectProvider.GetProviderForBindableObjectType(type);
            var  bindableObjectClass    = businessObjectProvider.GetBindableObjectClass(type);
            IBusinessObjectWithIdentity businessObjectWithIdentity = null;

            if (!string.IsNullOrEmpty(businessObject))
            {
                var businessObjectClassWithIdentity = (IBusinessObjectClassWithIdentity)bindableObjectClass;
                businessObjectWithIdentity = businessObjectClassWithIdentity.GetObject(businessObject);
            }

            var iconInfo = BusinessObjectBoundWebControl.GetIcon(businessObjectWithIdentity, bindableObjectClass.BusinessObjectProvider);

            if (iconInfo != null)
            {
                return(IconProxy.Create(new HttpContextWrapper(Context), iconInfo));
            }

            return(null);
        }
Ejemplo n.º 4
0
 protected PropertyBase.Parameters CreateParameters(
     BindableObjectProvider businessObjectProvider,
     IPropertyInformation propertyInfo,
     Type underlyingType,
     Type concreteType,
     IListInfo listInfo,
     bool isRequired,
     bool isReadOnly,
     IBindablePropertyReadAccessStrategy bindablePropertyReadAccessStrategy   = null,
     IBindablePropertyWriteAccessStrategy bindablePropertyWriteAccessStrategy = null,
     BindableObjectGlobalizationService bindableObjectGlobalizationService    = null)
 {
     return(new PropertyBase.Parameters(
                businessObjectProvider,
                propertyInfo,
                underlyingType,
                new Lazy <Type> (() => concreteType),
                listInfo,
                isRequired,
                isReadOnly,
                new BindableObjectDefaultValueStrategy(),
                bindablePropertyReadAccessStrategy ?? SafeServiceLocator.Current.GetInstance <IBindablePropertyReadAccessStrategy>(),
                bindablePropertyWriteAccessStrategy ?? SafeServiceLocator.Current.GetInstance <IBindablePropertyWriteAccessStrategy>(),
                bindableObjectGlobalizationService ?? SafeServiceLocator.Current.GetInstance <BindableObjectGlobalizationService>()));
 }
        public void GetBindableObjectClass()
        {
            var mockRepository      = new MockRepository();
            var metadataFactoryMock = mockRepository.StrictMock <IMetadataFactory>();
            var classReflectorMock  = mockRepository.StrictMock <IClassReflector>();

            var provider = new BindableObjectProvider(metadataFactoryMock, _serviceFactoryStub);

            BindableObjectProvider.SetProvider(typeof(BindableObjectProviderAttribute), provider);
            Type targetType   = typeof(SimpleBusinessObjectClass);
            Type concreteType = MixinTypeUtility.GetConcreteMixedType(targetType);
            var  expectedBindableObjectClass = new BindableObjectClass(
                concreteType,
                provider,
                SafeServiceLocator.Current.GetInstance <BindableObjectGlobalizationService>(),
                new PropertyBase[0]);

            Expect.Call(metadataFactoryMock.CreateClassReflector(targetType, provider)).Return(classReflectorMock);
            Expect.Call(classReflectorMock.GetMetadata()).Return(expectedBindableObjectClass);

            mockRepository.ReplayAll();

            BindableObjectClass actual = provider.GetBindableObjectClass(targetType);

            mockRepository.VerifyAll();

            Assert.That(actual, Is.SameAs(expectedBindableObjectClass));
        }
        public void UseBindableObjectProvider_WithBaseClass()
        {
            IBusinessObjectReferenceProperty property = new ReferenceProperty(
                new PropertyBase.Parameters(
                    _bindableObjectProvider,
                    GetPropertyInfo(typeof(ClassWithReferenceToClassDerivedFromBindableObjectBase), "ScalarReference"),
                    typeof(ClassDerivedFromBindableObjectBase),
                    new Lazy <Type> (() => typeof(ClassDerivedFromBindableObjectBase)),
                    null,
                    false,
                    false,
                    new BindableObjectDefaultValueStrategy(),
                    MockRepository.GenerateStub <IBindablePropertyReadAccessStrategy>(),
                    MockRepository.GenerateStub <IBindablePropertyWriteAccessStrategy>(),
                    SafeServiceLocator.Current.GetInstance <BindableObjectGlobalizationService>()));

            Assert.That(property.ReferenceClass, Is.SameAs(BindableObjectProviderTestHelper.GetBindableObjectClass(typeof(ClassDerivedFromBindableObjectBase))));
            Assert.That(
                property.BusinessObjectProvider,
                Is.SameAs(BindableObjectProvider.GetProviderForBindableObjectType(typeof(ClassWithReferenceToClassDerivedFromBindableObjectBase))));
            Assert.That(
                property.ReferenceClass.BusinessObjectProvider,
                Is.SameAs(BindableObjectProvider.GetProviderForBindableObjectType(typeof(ClassDerivedFromBindableObjectBase))));
            Assert.That(property.ReferenceClass.BusinessObjectProvider, Is.SameAs(property.BusinessObjectProvider));
        }
Ejemplo n.º 7
0
        private IBusinessObjectReferenceProperty GetBusinessObjectProperty(Type bindableObjectType, string propertyName)
        {
            var provider            = BindableObjectProvider.GetProviderForBindableObjectType(bindableObjectType);
            var bindableObjectClass = provider.GetBindableObjectClass(bindableObjectType);

            return((IBusinessObjectReferenceProperty)bindableObjectClass.GetPropertyDefinition(propertyName));
        }
        public virtual IClassReflector CreateClassReflector(Type targetType, BindableObjectProvider businessObjectProvider)
        {
            ArgumentUtility.CheckNotNull("targetType", targetType);
            ArgumentUtility.CheckNotNull("businessObjectProvider", businessObjectProvider);

            return(new ClassReflector(targetType, businessObjectProvider, this, _bindableObjectGlobalizationService));
        }
        public void GetProviderForBindableObjectType_WithIdentityType()
        {
            BindableObjectProvider provider = BindableObjectProvider.GetProviderForBindableObjectType(typeof(ClassWithIdentity));

            Assert.That(provider, Is.Not.Null);
            Assert.That(provider, Is.SameAs(BusinessObjectProvider.GetProvider(typeof(BindableObjectWithIdentityProviderAttribute))));
            Assert.That(provider, Is.Not.SameAs(BusinessObjectProvider.GetProvider(typeof(BindableObjectProviderAttribute))));
        }
        public override void SetUp()
        {
            base.SetUp();

            _bindableObjectProvider             = new BindableObjectProvider();
            _mockRepository                     = new MockRepository();
            _bindableObjectGlobalizationService = SafeServiceLocator.Current.GetInstance <BindableObjectGlobalizationService>();
        }
Ejemplo n.º 11
0
        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"));
        }
Ejemplo n.º 12
0
        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 CreateClassReflector()
        {
            BindableObjectProvider provider       = new BindableObjectProvider();
            IClassReflector        classReflector = BindableObjectMetadataFactory.Create().CreateClassReflector(typeof(TestClass), provider);

            Assert.That(classReflector.TargetType, Is.SameAs(typeof(TestClass)));
            Assert.That(classReflector.BusinessObjectProvider, Is.SameAs(provider));
        }
Ejemplo n.º 14
0
        public override void SetUp()
        {
            base.SetUp();

            _type = typeof(DerivedBusinessObjectClass);
            _businessObjectProvider             = new BindableObjectProvider();
            _metadataFactory                    = BindableObjectMetadataFactory.Create();
            _bindableObjectGlobalizationService = SafeServiceLocator.Current.GetInstance <BindableObjectGlobalizationService>();
        }
Ejemplo n.º 15
0
        public override void SetUp()
        {
            base.SetUp();

            _businessObjectProvider = CreateBindableObjectProviderWithStubBusinessObjectServiceFactory();

            _mockRepository     = new MockRepository();
            _mockBusinessObject = _mockRepository.StrictMock <IBusinessObject>();
        }
 public void GetServiceFactory_WithMixin()
 {
     using (MixinConfiguration.BuildNew().ForClass(typeof(BindableObjectServiceFactory)).AddMixin <MixinStub>().EnterScope())
     {
         var provider = new BindableObjectProvider();
         Assert.That(provider.ServiceFactory, Is.InstanceOf(typeof(BindableObjectServiceFactory)));
         Assert.That(provider.ServiceFactory, Is.InstanceOf(typeof(IMixinTarget)));
     }
 }
Ejemplo n.º 17
0
 public void GetProvider()
 {
     Assert.That(
         BindableObjectProvider.GetProviderForBindableObjectType(typeof(ClassDerivedFromBindableObjectBase)),
         Is.SameAs(BusinessObjectProvider.GetProvider <BindableObjectProviderAttribute>()));
     Assert.That(
         BindableObjectProvider.GetProviderForBindableObjectType(typeof(ClassDerivedFromBindableObjectBase)),
         Is.Not.SameAs(BusinessObjectProvider.GetProvider <BindableObjectWithIdentityProviderAttribute>()));
 }
        public override void SetUp()
        {
            base.SetUp();

            var provider = BindableObjectProvider.GetProviderForBindableObjectType(typeof(BindableDomainObjectWithProperties));

            _businessObjectClassWithProperties = provider.GetBindableObjectClass(typeof(BindableDomainObjectWithProperties));
            _businessObjectSampleClass         = provider.GetBindableObjectClass(typeof(SampleBindableMixinDomainObject));
        }
        public void IsBindableObjectImplementation_TrueWithClosedGenericType()
        {
            var mixinTargetType    = typeof(ManualBusinessObject);
            var businessObjectType = typeof(GenericBindableObject <string>);

            Assertion.IsTrue(mixinTargetType.IsAssignableFrom(businessObjectType));

            Assert.That(BindableObjectProvider.IsBindableObjectImplementation(businessObjectType), Is.True);
        }
        public override void SetUp()
        {
            base.SetUp();

            _provider = new BindableObjectProvider();
            BindableObjectProvider.SetProvider(typeof(BindableObjectProviderAttribute), _provider);
            _metadataFactoryStub = MockRepository.GenerateStub <IMetadataFactory>();
            _serviceFactoryStub  = MockRepository.GenerateStub <IBusinessObjectServiceFactory>();
        }
        public void GetProviderForBindableObjectType_WithAttributeFromTypeOverridingAttributeFromMixin()
        {
            BindableObjectProvider provider =
                BindableObjectProvider.GetProviderForBindableObjectType(typeof(DerivedBusinessObjectClassWithSpecificBusinessObjectProviderAttribute));

            Assert.That(provider, Is.Not.Null);
            Assert.That(provider, Is.SameAs(BusinessObjectProvider.GetProvider(typeof(BindableObjectWithIdentityProviderAttribute))));
            Assert.That(provider, Is.Not.SameAs(BusinessObjectProvider.GetProvider(typeof(BindableObjectProviderAttribute))));
        }
 public static BindableDomainObjectPropertyReflector Create(
     IPropertyInformation propertyInfo,
     BindableObjectProvider businessObjectProvider,
     IDomainModelConstraintProvider domainModelConstraintProvider,
     IDefaultValueStrategy defaultValueStrategy)
 {
     return(ObjectFactory.Create <BindableDomainObjectPropertyReflector> (
                true,
                ParamList.Create(propertyInfo, businessObjectProvider, domainModelConstraintProvider, defaultValueStrategy)));
 }
Ejemplo n.º 23
0
        public override void SetUp()
        {
            base.SetUp();

            _bindableObjectProvider = CreateBindableObjectProviderWithStubBusinessObjectServiceFactory();
            BusinessObjectProvider.SetProvider <BindableObjectProviderAttribute> (_bindableObjectProvider);
            BusinessObjectProvider.SetProvider <BindableObjectWithIdentityProviderAttribute> (_bindableObjectProvider);
            _mockRepository      = new MockRepository();
            _bindableObjectClass = BindableObjectProviderTestHelper.GetBindableObjectClass(typeof(SimpleBusinessObjectClass));
        }
Ejemplo n.º 24
0
        public void GetFromUniqueIdentifier()
        {
            BusinessObjectProvider.GetProvider <BindableDomainObjectProviderAttribute>().AddService(typeof(IGetObjectService), new BindableDomainObjectGetObjectService());
            SampleBindableMixinDomainObject original = SampleBindableMixinDomainObject.NewObject();

            var provider = BindableObjectProvider.GetProviderForBindableObjectType(typeof(SampleBindableMixinDomainObject));
            var boClass  = (BindableObjectClassWithIdentity)provider.GetBindableObjectClass(typeof(SampleBindableMixinDomainObject));

            Assert.That(boClass.GetObject(original.ID.ToString()), Is.SameAs(original));
        }
Ejemplo n.º 25
0
        public override void SetUp()
        {
            base.SetUp();

            _dataSource = new BindableObjectDataSource();

            _provider = new BindableObjectProvider();
            BusinessObjectProvider.SetProvider(typeof(BindableObjectProviderAttribute), _provider);
            BusinessObjectProvider.SetProvider(typeof(BindableObjectWithIdentityProviderAttribute), _provider);
        }
        public void GetBindableObjectClass_WithOpenGeneric()
        {
            var provider = (BindableObjectProvider)BindableObjectProvider.GetProvider(typeof(BindableObjectProviderAttribute));

            Assert.That(
                () => provider.GetBindableObjectClass(typeof(GenericBindableObject <>)),
                Throws.ArgumentException.With.Message.EqualTo(
                    "The type 'Remotion.ObjectBinding.UnitTests.TestDomain.GenericBindableObject`1' "
                    + "is not a bindable object implementation. Open generic types are not supported.\r\nParameter name: type"));
        }
Ejemplo n.º 27
0
        public override void SetUp()
        {
            base.SetUp();

            _bindableObjectProvider = CreateBindableObjectProviderWithStubBusinessObjectServiceFactory();
            BusinessObjectProvider.SetProvider <BindableObjectProviderAttribute> (_bindableObjectProvider);
            BusinessObjectProvider.SetProvider <BindableObjectWithIdentityProviderAttribute> (_bindableObjectProvider);
            _bindableObjectGlobalizationService = SafeServiceLocator.Current.GetInstance <BindableObjectGlobalizationService>();
            _mockRepository = new MockRepository();
        }
Ejemplo n.º 28
0
 private BooleanProperty CreateProperty(
     string propertyName,
     BindableObjectProvider provider = null,
     BindableObjectGlobalizationService bindableObjectGlobalizationService = null)
 {
     return(new BooleanProperty(
                GetPropertyParameters(
                    GetPropertyInfo(typeof(ClassWithValueType <bool>), propertyName),
                    provider ?? _businessObjectProvider,
                    bindableObjectGlobalizationService: bindableObjectGlobalizationService)));
 }
Ejemplo n.º 29
0
        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 override void SetUp()
        {
            base.SetUp();

            _mockRepository                     = new MockRepository();
            _bindableObjectProvider             = CreateBindableObjectProviderWithStubBusinessObjectServiceFactory();
            _bindableObjectWithIdentityProvider = CreateBindableObjectProviderWithStubBusinessObjectServiceFactory();

            BusinessObjectProvider.SetProvider <BindableObjectProviderAttribute> (_bindableObjectProvider);
            BusinessObjectProvider.SetProvider <BindableObjectWithIdentityProviderAttribute> (_bindableObjectWithIdentityProvider);
        }