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"));
        }
        public void GetBindableObjectClass_WithMissingBusinessObjectInterace()
        {
            var provider = (BindableObjectProvider)BindableObjectProvider.GetProvider(typeof(BindableObjectProviderAttribute));

            Assert.That(
                () => provider.GetBindableObjectClass(typeof(StubBusinessObjectWithoutBusinessObjectInterface)),
                Throws.ArgumentException.With.Message.EqualTo(
                    "The type 'Remotion.ObjectBinding.UnitTests.TestDomain.StubBusinessObjectWithoutBusinessObjectInterface' "
                    + "is not a bindable object implementation. It must either have a mixin derived from BindableObjectMixinBase<T> applied "
                    + "or implement the IBusinessObject interface and apply the BindableObjectBaseClassAttribute.\r\nParameter name: type"));
        }
        public void SetUp()
        {
            Initialize();

            _enumValue = MockRepository.GenerateStub <IBocEnumValue>();
            var businessObjectProvider = BindableObjectProvider.GetProvider(typeof(BindableObjectProviderAttribute));
            var propertyInfo           = PropertyInfoAdapter.Create(typeof(TypeWithEnum).GetProperty("EnumValue"));
            IBusinessObjectEnumerationProperty property =
                new EnumerationProperty(
                    new PropertyBase.Parameters(
                        (BindableObjectProvider)businessObjectProvider,
                        propertyInfo,
                        typeof(TestEnum),
                        new Lazy <Type> (() => typeof(TestEnum)),
                        null,
                        true,
                        false,
                        new BindableObjectDefaultValueStrategy(),
                        MockRepository.GenerateStub <IBindablePropertyReadAccessStrategy>(),
                        MockRepository.GenerateStub <IBindablePropertyWriteAccessStrategy>(),
                        SafeServiceLocator.Current.GetInstance <BindableObjectGlobalizationService>()));

            _enumValue.Property = property;
            _enumValue.Stub(stub => stub.ClientID).Return(c_clientID);
            _enumValue.Stub(mock => mock.IsDesignMode).Return(false);

            var pageStub = MockRepository.GenerateStub <IPage>();

            pageStub.Stub(stub => stub.WrappedInstance).Return(new PageMock());
            _enumValue.Stub(stub => stub.Page).Return(pageStub);

            var values = new List <EnumerationValueInfo> (3);

            foreach (TestEnum value in Enum.GetValues(typeof(TestEnum)))
            {
                values.Add(new EnumerationValueInfo(value, value.ToString(), value.ToString(), true));
            }
            _enumerationInfos = values.ToArray();
            _enumValue.Stub(mock => mock.GetEnabledValues()).Return(_enumerationInfos);

            _enumValue.Stub(mock => mock.GetNullItemText()).Return("null");
            _enumValue.Stub(mock => mock.GetValueName()).Return(c_valueName);

            StateBag stateBag = new StateBag();

            _enumValue.Stub(mock => mock.Attributes).Return(new AttributeCollection(stateBag));
            _enumValue.Stub(mock => mock.Style).Return(_enumValue.Attributes.CssStyle);
            _enumValue.Stub(mock => mock.LabelStyle).Return(new Style(stateBag));
            _enumValue.Stub(mock => mock.ListControlStyle).Return(new ListControlStyle());
            _enumValue.Stub(mock => mock.ControlStyle).Return(new Style(stateBag));

            _resourceUrlFactory = new FakeResourceUrlFactory();
        }
Пример #4
0
 protected void Application_Start(object sender, EventArgs e)
 {
     BindableObjectProvider.GetProvider <BindableDomainObjectProviderAttribute>().AddService(
         typeof(BindableDomainObjectGetObjectService), new BindableDomainObjectGetObjectService());
 }