Ejemplo n.º 1
0
        public void SetValueToObject()
        {
            IBusinessObject referencedObject = (IBusinessObject)TypeWithReference.Create();

            _bocDropDownMenu.Value = referencedObject;
            Assert.That(_bocDropDownMenu.Value, Is.EqualTo(referencedObject));
        }
Ejemplo n.º 2
0
        protected void Initialize(bool withRowObjects)
        {
            base.Initialize();

            TypeWithReference businessObject;

            if (withRowObjects)
            {
                businessObject = TypeWithReference.Create(
                    TypeWithReference.Create("referencedObject1"),
                    TypeWithReference.Create("referencedObject2"));
                businessObject.ReferenceList = new[] { businessObject.FirstValue, businessObject.SecondValue };
            }
            else
            {
                businessObject = TypeWithReference.Create();
                businessObject.ReferenceList = new TypeWithReference[0];
            }
            BusinessObject = (IBusinessObject)businessObject;
            BusinessObject.BusinessObjectClass.BusinessObjectProvider.AddService <IBusinessObjectWebUIService>
                (new ReflectionBusinessObjectWebUIService());

            EventArgs = new BocListDataRowRenderEventArgs(10, (IBusinessObject)businessObject.FirstValue, false, true);

            InitializeMockList();
        }
Ejemplo n.º 3
0
        public void TestDiagnosticMetadataRenderingForBoundControl_DataSourceWithoutBusinessObject()
        {
            var businessObject = TypeWithReference.Create("MyBusinessObject");

            ((IBusinessObjectBoundControl)Control).Property =
                ((IBusinessObject)businessObject).BusinessObjectClass.GetPropertyDefinition("ReferenceValue");

            var dataSource = new BindableObjectDataSource {
                Type = typeof(TypeWithReference)
            };

            dataSource.Register(Control);
            Control.DataSource = dataSource;

            var renderingContext = CreateRenderingContext();

            BocRendererBase = new TestableBocRendererBase(_resourceUrlFactory, GlobalizationService, RenderingFeatures.WithDiagnosticMetadata);

            BocRendererBase.AddDiagnosticMetadataAttributes(renderingContext);
            renderingContext.Writer.RenderBeginTag(HtmlTextWriterTag.Span);
            renderingContext.Writer.RenderEndTag();

            var document = Html.GetResultDocument();
            var control  = document.DocumentElement;

            control.AssertAttributeValueEquals(DiagnosticMetadataAttributesForObjectBinding.IsBound, "true");
            control.AssertAttributeValueEquals(
                DiagnosticMetadataAttributesForObjectBinding.BoundType,
                "Remotion.ObjectBinding.Web.UnitTests.Domain.TypeWithReference, Remotion.ObjectBinding.Web.UnitTests");
            control.AssertAttributeValueEquals(DiagnosticMetadataAttributesForObjectBinding.BoundProperty, "ReferenceValue");
        }
Ejemplo n.º 4
0
        public override void SetUp()
        {
            base.SetUp();
            _control       = new BocAutoCompleteReferenceValueMock();
            _control.ID    = "BocAutoCompleteReferenceValue";
            _control.Value = (IBusinessObjectWithIdentity)_businessObject;

            MockRepository mockRepository = new MockRepository();

            _page = mockRepository.PartialMultiMock <Page> (typeof(ISmartPage));
            ((ISmartPage)_page).Stub(stub => stub.Context).Return(new HttpContextWrapper(HttpContext.Current));
            _page.Replay();
            _page.Controls.Add(_control);

            _businessObject = TypeWithReference.Create();

            _propertyReferenceValue =
                (IBusinessObjectReferenceProperty)((IBusinessObject)_businessObject).BusinessObjectClass.GetPropertyDefinition("ReferenceValue");

            _dataSource = new StubDataSource(((IBusinessObject)_businessObject).BusinessObjectClass);
            _dataSource.BusinessObject = (IBusinessObject)_businessObject;

            ((IBusinessObject)_businessObject).BusinessObjectClass.BusinessObjectProvider.AddService <IGetObjectService>
                (new GetObjectService((IBusinessObjectWithIdentity)TypeWithReference.Create()));
            ((IBusinessObject)_businessObject).BusinessObjectClass.BusinessObjectProvider.AddService <IBusinessObjectWebUIService>
                (new ReflectionBusinessObjectWebUIService());
        }
Ejemplo n.º 5
0
        public void LoadUnboundValueAndInterimFalseWithList()
        {
            TypeWithReference[] value = new[] { TypeWithReference.Create(), TypeWithReference.Create() };
            _bocTreeView.Value = null;

            _bocTreeView.LoadUnboundValue(value, false);
            Assert.That(_bocTreeView.Value, Is.EqualTo(value));
        }
Ejemplo n.º 6
0
        public void GetValidationValue_ValueSet()
        {
            var value = TypeWithReference.Create("Name");

            _bocReferenceValue.Value = (IBusinessObjectWithIdentity)value;

            Assert.That(_bocReferenceValue.ValidationValue, Is.EqualTo(value.UniqueIdentifier));
        }
Ejemplo n.º 7
0
        public void GetValidationValue_ValueSet()
        {
            var value = TypeWithReference.Create("Name");

            _control.Value = (IBusinessObjectWithIdentity)value;

            Assert.That(_control.ValidationValue, Is.EqualTo(value.UniqueIdentifier + "\n" + value.DisplayName));
        }
Ejemplo n.º 8
0
        public void SetUp()
        {
            Initialize();

            OptionsMenu  = new StubDropDownMenu();
            DropDownList = new StubDropDownList();

            Control = MockRepository.GenerateStub <IBocReferenceValue>();
            Control.Stub(stub => stub.ClientID).Return(c_clientID);
            Control.Stub(stub => stub.Command).Return(new BocCommand());
            Control.Command.Type = CommandType.Event;
            Control.Command.Show = CommandShow.Always;

            Control.Stub(stub => stub.OptionsMenu).Return(OptionsMenu);

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

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

            ClientScriptManagerMock = MockRepository.GenerateMock <IClientScriptManager>();
            pageStub.Stub(stub => stub.ClientScript).Return(ClientScriptManagerMock);

            BusinessObject = TypeWithReference.Create("MyBusinessObject");
            BusinessObject.ReferenceList = new[]
            {
                TypeWithReference.Create("ReferencedObject 0"),
                TypeWithReference.Create("ReferencedObject 1"),
                TypeWithReference.Create("ReferencedObject 2")
            };
            _dataSource = new BusinessObjectReferenceDataSource();
            _dataSource.BusinessObject = (IBusinessObject)BusinessObject;

            _provider = ((IBusinessObject)BusinessObject).BusinessObjectClass.BusinessObjectProvider;
            _provider.AddService <IBusinessObjectWebUIService> (new ReflectionBusinessObjectWebUIService());

            StateBag stateBag = new StateBag();

            Control.Stub(mock => mock.Attributes).Return(new AttributeCollection(stateBag));
            Control.Stub(mock => mock.Style).Return(Control.Attributes.CssStyle);
            Control.Stub(mock => mock.LabelStyle).Return(new Style(stateBag));
            Control.Stub(mock => mock.DropDownListStyle).Return(new DropDownListStyle());
            Control.Stub(mock => mock.ControlStyle).Return(new Style(stateBag));
            Control.Stub(stub => stub.GetValueName()).Return(c_valueName);
            Control.Stub(stub => stub.PopulateDropDownList(Arg <DropDownList> .Is.NotNull))
            .WhenCalled(
                invocation =>
            {
                foreach (var item in BusinessObject.ReferenceList)
                {
                    ((DropDownList)invocation.Arguments[0]).Items.Add(new ListItem(item.DisplayName, item.UniqueIdentifier));
                }
            });

            Control.Stub(stub => stub.GetLabelText()).Return("MyText");

            _resourceUrlFactory = new FakeResourceUrlFactory();
        }
Ejemplo n.º 9
0
 public void IsWxeFunctionCommandEnabledWithoutWcagOverride()
 {
     _businessObject.ReferenceValue = TypeWithReference.Create();
     _control.DataSource            = _dataSource;
     _control.Property            = _propertyReferenceValue;
     WebConfigurationMock.Current = WebConfigurationFactory.GetLevelUndefined();
     _control.Command.Type        = CommandType.WxeFunction;
     Assert.That(((IBocReferenceValueBase)_control).IsCommandEnabled(), Is.True);
 }
Ejemplo n.º 10
0
        public void LoadUnboundValueInitial()
        {
            var newValue = (IBusinessObjectWithIdentity)TypeWithReference.Create();

            _control.LoadUnboundValue(newValue, false);

            Assert.That(_control.Value, Is.EqualTo(newValue));
            Assert.That(!_control.IsDirty);
        }
Ejemplo n.º 11
0
        public void LoadUnboundValueAndInterimFalseWithNull()
        {
            IBusinessObject value = null;

            _bocDropDownMenu.Value = (IBusinessObject)TypeWithReference.Create();

            _bocDropDownMenu.LoadUnboundValue(value, false);
            Assert.That(_bocDropDownMenu.Value, Is.EqualTo(value));
        }
Ejemplo n.º 12
0
        public void LoadValueAndInterimFalseWithDataSourceBusinessObjectNull()
        {
            _dataSource.BusinessObject = null;
            _bocTreeView.DataSource    = _dataSource;
            _bocTreeView.Value         = new[] { TypeWithReference.Create() };

            _bocTreeView.LoadValue(false);
            Assert.That(_bocTreeView.Value, Is.EqualTo(null));
        }
Ejemplo n.º 13
0
        public void LoadValueAndInterimFalseWithDataSourceNull()
        {
            var value = new[] { TypeWithReference.Create() };

            _bocTreeView.DataSource = null;
            _bocTreeView.Value      = value;

            _bocTreeView.LoadValue(false);
            Assert.That(_bocTreeView.Value, Is.EqualTo(value));
        }
Ejemplo n.º 14
0
        public void LoadValueAndInterimFalseWithObject()
        {
            _businessObject.ReferenceValue = TypeWithReference.Create();
            _bocDropDownMenu.DataSource    = _dataSource;
            _bocDropDownMenu.Property      = _propertyReferenceValue;
            _bocDropDownMenu.Value         = null;

            _bocDropDownMenu.LoadValue(false);
            Assert.That(_bocDropDownMenu.Value, Is.EqualTo(_businessObject.ReferenceValue));
        }
Ejemplo n.º 15
0
        public void LoadValueAndInterimFalseWithDataSourceBusinessObjectNull()
        {
            _dataSource.BusinessObject  = null;
            _bocDropDownMenu.DataSource = _dataSource;
            _bocDropDownMenu.Property   = _propertyReferenceValue;
            _bocDropDownMenu.Value      = (IBusinessObjectWithIdentity)TypeWithReference.Create();

            _bocDropDownMenu.LoadValue(false);
            Assert.That(_bocDropDownMenu.Value, Is.EqualTo(null));
        }
Ejemplo n.º 16
0
        public void LoadUnboundValueInterim()
        {
            var oldValue = _control.Value;
            var newValue = (IBusinessObjectWithIdentity)TypeWithReference.Create();

            _control.LoadUnboundValue(newValue, true);

            Assert.That(_control.Value, Is.EqualTo(oldValue));
            Assert.That(_control.IsDirty);
        }
Ejemplo n.º 17
0
        public void LoadUnboundValueAndInterimFalseWithListAndDirty()
        {
            TypeWithReference[] value = new[] { TypeWithReference.Create(), TypeWithReference.Create() };
            _bocList.DataSource = _dataSource;
            _bocList.Value      = null;
            _bocList.IsDirty    = true;

            _bocList.LoadUnboundValue(value, false);
            Assert.That(_bocList.Value, Is.SameAs(value));
            Assert.That(_bocList.IsDirty, Is.False);
        }
Ejemplo n.º 18
0
        public void LoadValueAndInterimFalseWithListAndDirty()
        {
            _businessObject.ReferenceList = new[] { TypeWithReference.Create(), TypeWithReference.Create() };
            _bocList.DataSource           = _dataSource;
            _bocList.Property             = _propertyReferenceList;
            _bocList.Value   = null;
            _bocList.IsDirty = true;

            _bocList.LoadValue(false);
            Assert.That(_bocList.Value, Is.SameAs(_businessObject.ReferenceList));
            Assert.That(_bocList.IsDirty, Is.False);
        }
Ejemplo n.º 19
0
        public void LoadValueAndInterimFalseWithPropertyNull()
        {
            TypeWithReference[] value = new[] { TypeWithReference.Create(), TypeWithReference.Create() };
            _bocList.DataSource = _dataSource;
            _bocList.Property   = null;
            _bocList.Value      = value;
            _bocList.IsDirty    = true;

            _bocList.LoadValue(false);
            Assert.That(_bocList.Value, Is.EqualTo(value));
            Assert.That(_bocList.IsDirty, Is.True);
        }
Ejemplo n.º 20
0
        public void LoadValueAndInterimTrueWithDataSourceBusinessObjectNull()
        {
            _dataSource.BusinessObject = null;
            _bocList.DataSource        = _dataSource;
            _bocList.Property          = _propertyReferenceList;
            _bocList.Value             = new[] { TypeWithReference.Create(), TypeWithReference.Create() };
            _bocList.IsDirty           = true;

            _bocList.LoadValue(true);
            Assert.That(_bocList.Value, Is.EqualTo(null));
            Assert.That(_bocList.IsDirty, Is.True);
        }
Ejemplo n.º 21
0
        public void LoadValueAndInterimTrue()
        {
            _businessObject.ReferenceValue = TypeWithReference.Create();
            _bocReferenceValue.DataSource  = _dataSource;
            _bocReferenceValue.Property    = _propertyReferenceValue;
            _bocReferenceValue.Value       = null;
            _bocReferenceValue.IsDirty     = true;

            _bocReferenceValue.LoadValue(true);
            Assert.That(_bocReferenceValue.Value, Is.EqualTo(null));
            Assert.That(_bocReferenceValue.IsDirty, Is.True);
        }
Ejemplo n.º 22
0
        public void LoadValueAndInterimFalseWithNull()
        {
            _businessObject.ReferenceValue = null;
            _bocReferenceValue.DataSource  = _dataSource;
            _bocReferenceValue.Property    = _propertyReferenceValue;
            _bocReferenceValue.Value       = (IBusinessObjectWithIdentity)TypeWithReference.Create();
            _bocReferenceValue.IsDirty     = true;

            _bocReferenceValue.LoadValue(false);
            Assert.That(_bocReferenceValue.Value, Is.EqualTo(_businessObject.ReferenceValue));
            Assert.That(_bocReferenceValue.IsDirty, Is.False);
        }
Ejemplo n.º 23
0
        public void LoadUnboundValueAndInterimTrue()
        {
            IBusinessObjectWithIdentity value = (IBusinessObjectWithIdentity)TypeWithReference.Create();

            _bocReferenceValue.Property = _propertyReferenceValue;
            _bocReferenceValue.Value    = null;
            _bocReferenceValue.IsDirty  = true;

            _bocReferenceValue.LoadUnboundValue(value, true);
            Assert.That(_bocReferenceValue.Value, Is.EqualTo(null));
            Assert.That(_bocReferenceValue.IsDirty, Is.True);
        }
Ejemplo n.º 24
0
        public void LoadValueAndInterimFalseWithObject()
        {
            _businessObject.ReferenceValue = TypeWithReference.Create();
            _control.DataSource            = _dataSource;
            _control.Property = _propertyReferenceValue;
            _control.Value    = null;
            _control.IsDirty  = true;

            _control.LoadValue(false);
            Assert.That(_control.Value, Is.EqualTo(_businessObject.ReferenceValue));
            Assert.That(_control.IsDirty, Is.False);
        }
Ejemplo n.º 25
0
        public override void SetUp()
        {
            base.SetUp();
            _bocTreeView    = new BocTreeViewMock();
            _bocTreeView.ID = "BocTreeView";
            NamingContainer.Controls.Add(_bocTreeView);

            _businessObject = TypeWithReference.Create();

            _dataSource = new BusinessObjectReferenceDataSource();
            _dataSource.BusinessObject = (IBusinessObject)_businessObject;
        }
Ejemplo n.º 26
0
        public void LoadUnboundValueAndInterimFalseWithNull()
        {
            const IBusinessObjectWithIdentity value = null;

            _control.Property = _propertyReferenceValue;
            _control.Value    = (IBusinessObjectWithIdentity)TypeWithReference.Create();
            _control.IsDirty  = true;

            _control.LoadUnboundValue(value, false);
            Assert.That(_control.Value, Is.EqualTo(value));
            Assert.That(_control.IsDirty, Is.False);
        }
Ejemplo n.º 27
0
        public void LoadValueAndInterimFalseWithDataSourceBusinessObjectNull()
        {
            _dataSource.BusinessObject = null;
            _control.DataSource        = _dataSource;
            _control.Property          = _propertyReferenceValue;
            _control.Value             = (IBusinessObjectWithIdentity)TypeWithReference.Create();
            _control.IsDirty           = true;

            _control.LoadValue(false);
            Assert.That(_control.Value, Is.EqualTo(null));
            Assert.That(_control.IsDirty, Is.False);
        }
Ejemplo n.º 28
0
        public void SaveValueAndIsListEditModeActiveTrueAndInterimFalse()
        {
            _bocList.DataSource = _dataSource;
            _bocList.Property   = _propertyReferenceList;
            _bocList.Value      = new[] { TypeWithReference.Create() };
            _bocList.SwitchListIntoEditMode();
            Assert.That(_bocList.IsListEditModeActive, Is.True);

            var result = _bocList.SaveValue(false);

            Assert.That(result, Is.True);
            Assert.That(_bocList.IsListEditModeActive, Is.False);
        }
Ejemplo n.º 29
0
        public void LoadValueAndInterimFalseWithPropertyNull()
        {
            var value = (IBusinessObjectWithIdentity)TypeWithReference.Create();

            _control.DataSource = _dataSource;
            _control.Property   = null;
            _control.Value      = value;
            _control.IsDirty    = true;

            _control.LoadValue(false);
            Assert.That(_control.Value, Is.EqualTo(value));
            Assert.That(_control.IsDirty, Is.True);
        }
        public void SetUp()
        {
            Initialize();

            OptionsMenu = new StubDropDownMenu();
            TextBox     = new StubTextBox();

            Control = MockRepository.GenerateStub <IBocAutoCompleteReferenceValue> ();
            Control.Stub(stub => stub.ClientID).Return(c_clientID);
            Control.Stub(stub => stub.GetTextValueName()).Return(c_textValueName);
            Control.Stub(stub => stub.GetKeyValueName()).Return(c_keyValueName);
            Control.Stub(stub => stub.Command).Return(new BocCommand());
            Control.Command.Type = CommandType.Event;
            Control.Command.Show = CommandShow.Always;
            Control.Stub(stub => stub.SearchServicePath).Return("~/SearchService.asmx");

            Control.Stub(stub => stub.OptionsMenu).Return(OptionsMenu);

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

            Control.Stub(stub => stub.Page).Return(pageStub);

            ClientScriptManagerMock = MockRepository.GenerateMock <IClientScriptManager> ();
            pageStub.Stub(stub => stub.ClientScript).Return(ClientScriptManagerMock);

            BusinessObject = TypeWithReference.Create("MyBusinessObject");
            BusinessObject.ReferenceList = new[]
            {
                TypeWithReference.Create("ReferencedObject 0"),
                TypeWithReference.Create("ReferencedObject 1"),
                TypeWithReference.Create("ReferencedObject 2")
            };
            _dataSource = new BusinessObjectReferenceDataSource();
            _dataSource.BusinessObject = (IBusinessObject)BusinessObject;

            _provider = ((IBusinessObject)BusinessObject).BusinessObjectClass.BusinessObjectProvider;
            _provider.AddService <IBusinessObjectWebUIService> (new ReflectionBusinessObjectWebUIService());

            StateBag stateBag = new StateBag();

            Control.Stub(mock => mock.Attributes).Return(new AttributeCollection(stateBag));
            Control.Stub(mock => mock.Style).Return(Control.Attributes.CssStyle);
            Control.Stub(mock => mock.CommonStyle).Return(new Style(stateBag));
            Control.Stub(mock => mock.LabelStyle).Return(new Style(stateBag));
            Control.Stub(mock => mock.TextBoxStyle).Return(new SingleRowTextBoxStyle());
            Control.Stub(mock => mock.ControlStyle).Return(new Style(stateBag));

            Control.Stub(stub => stub.GetLabelText()).Return("MyText");

            _resourceUrlFactory = new FakeResourceUrlFactory();
        }