示例#1
0
        /// <summary>
        ///   Sets the value accessed through the <see cref="IBusinessObjectProperty"/> identified by the passed <paramref name="propertyIdentifier"/>.
        /// </summary>
        /// <param name="businessObject">The <see cref="IBusinessObject"/> for which the property is declared. Must not be <see langword="null" />.</param>
        /// <param name="propertyIdentifier">
        ///   A <see cref="String"/> identifing the <see cref="IBusinessObjectProperty"/> used to access the value.
        /// </param>
        /// <param name="value">
        ///   The new value for the <see cref="IBusinessObjectProperty"/> identified by the
        ///   <paramref name="propertyIdentifier"/> parameter.
        /// </param>
        /// <exception cref="BusinessObjectPropertyAccessException">
        ///   Thrown if the property's value could not be read.
        /// </exception>
        /// <exception cref="InvalidOperationException">
        ///   The <see cref="IBusinessObjectProperty"/> identified through the <paramref name="propertyIdentifier"/> is not part of this
        ///   <paramref name="businessObject"/>'s <see cref="IBusinessObject.BusinessObjectClass"/>.
        /// </exception>
        public static void SetProperty(this IBusinessObject businessObject, string propertyIdentifier, object value)
        {
            ArgumentUtility.CheckNotNull("businessObject", businessObject);
            ArgumentUtility.CheckNotNullOrEmpty("propertyIdentifier", propertyIdentifier);

            var propertyDefinition = GetPropertyDefinition(businessObject, propertyIdentifier);

            businessObject.SetProperty(propertyDefinition, value);
        }
示例#2
0
        public void PropertyWithNoSetter()
        {
            var propertyInformationStub = MockRepository.GenerateStub <IPropertyInformation> ();

            propertyInformationStub.Stub(stub => stub.PropertyType).Return(typeof(bool));
            propertyInformationStub.Stub(stub => stub.GetIndexParameters()).Return(new ParameterInfo[0]);
            propertyInformationStub.Stub(stub => stub.GetSetMethod(true)).Return(null);

            var booleanProperty = CreateProperty(propertyInformationStub);

            _newBusinessOrder.SetProperty(booleanProperty, new object());
        }
示例#3
0
        private void LoadAndSaveValue <T> (string propertyidentifier, T initialValue, T newValue, string newValueAsString = null)
        {
            _businessObject.SetProperty(propertyidentifier, initialValue);
            _bocTextValue.DataSource = _dataSource;
            _bocTextValue.Property   = _businessObject.BusinessObjectClass.GetPropertyDefinition(propertyidentifier);

            _bocTextValue.LoadValue(false);
            Assert.That(_bocTextValue.Value, Is.EqualTo(initialValue));
            Assert.That(_bocTextValue.IsDirty, Is.False);

            _bocTextValue.Text = newValueAsString ?? newValue.ToString();
            Assert.That(_bocTextValue.IsDirty, Is.True);

            _bocTextValue.SaveValue(false);
            Assert.That(_bocTextValue.Value, Is.EqualTo(newValue));
            Assert.That(_bocTextValue.IsDirty, Is.False);
            _bocTextValue.SaveValue(false);

            Assert.That(_businessObject.GetProperty(propertyidentifier), Is.EqualTo(newValue));
        }
示例#4
0
        public void WithoutSetter()
        {
            IBusinessObject businessObject = Mixin.Get <BindableObjectMixin> (ObjectFactory.Create <SimpleBusinessObjectClass>(ParamList.Empty));

            businessObject.SetProperty("StringWithoutSetter", null);
        }
示例#5
0
        public void WithBusinessObjectProperty()
        {
            _businessObject.SetProperty(_businessObject.BusinessObjectClass.GetPropertyDefinition("String"), "A String");

            Assert.That(_bindableObject.String, Is.EqualTo("A String"));
        }