Exemplo n.º 1
0
 public void SetUp()
 {
     _businessObjectStub = MockRepository.GenerateStub <IBusinessObject> ();
     _propertyStub       = MockRepository.GenerateStub <IBusinessObjectEnumerationProperty> ();
     _value1             = new EnumerationValueInfo("Value1", "ID1", "Value 1", true);
     _value2             = new EnumerationValueInfo("Value2", "ID2", "Value 2", true);
 }
Exemplo n.º 2
0
 public void SetUp()
 {
     _stringFormatterService = new BusinessObjectStringFormatterService();
     _mockRepository         = new MockRepository();
     _mockBusinessObject     = _mockRepository.StrictMock <IBusinessObject> ();
     _mockProperty           = _mockRepository.StrictMock <IBusinessObjectEnumerationProperty> ();
 }
Exemplo n.º 3
0
        public void IBusinessObjectEnumerationProperty_GetValueInfoByValue_WithTrue()
        {
            IBusinessObjectEnumerationProperty property = CreateProperty("Scalar");

            CheckEnumerationValueInfo(
                new BooleanEnumerationValueInfo(true, (IBusinessObjectBooleanProperty)property),
                property.GetValueInfoByValue(true, null));
        }
Exemplo n.º 4
0
        public void IBusinessObjectEnumerationProperty_GetValueInfoByIdentifier_WithFalse()
        {
            IBusinessObjectEnumerationProperty property = CreateProperty("Scalar");

            CheckEnumerationValueInfo(
                new BooleanEnumerationValueInfo(false, (IBusinessObjectBooleanProperty)property),
                property.GetValueInfoByIdentifier("False", null));
        }
Exemplo n.º 5
0
        public void ValidEnumValue()
        {
            IBusinessObjectEnumerationProperty property = CreateProperty(typeof(ClassWithValueType <TestEnum>), "Scalar");

            CheckEnumerationValueInfo(
                new EnumerationValueInfo(TestEnum.Value1, "Value1", "Value1", true),
                property.GetValueInfoByValue(TestEnum.Value1, null));
        }
Exemplo n.º 6
0
        public void InvalidEnumValue()
        {
            IBusinessObjectEnumerationProperty property = CreateProperty(typeof(ClassWithValueType <TestEnum>), "Scalar");

            CheckEnumerationValueInfo(
                new EnumerationValueInfo((TestEnum)(-1), "-1", "-1", false),
                property.GetValueInfoByValue((TestEnum)(-1), null));
        }
        private string GetStringValueForEnumerationProperty(object value, IBusinessObjectEnumerationProperty property, IBusinessObject businessObject)
        {
            IEnumerationValueInfo enumValueInfo = property.GetValueInfoByValue(value, businessObject);

            if (enumValueInfo == null)
            {
                return(string.Empty);
            }
            return(enumValueInfo.DisplayName);
        }
Exemplo n.º 8
0
        public void DisabledEnumValue()
        {
            IBusinessObjectEnumerationProperty property = CreateProperty(typeof(ClassWithDisabledEnumValue), "DisabledFromProperty");

            _mockRepository.ReplayAll();

            IEnumerationValueInfo actual = property.GetValueInfoByValue(TestEnum.Value1, _mockBusinessObject);

            _mockRepository.VerifyAll();
            CheckEnumerationValueInfo(new EnumerationValueInfo(TestEnum.Value1, "Value1", "Value1", false), actual);
        }
Exemplo n.º 9
0
        public void IBusinessObjectEnumerationProperty_GetEnabledValues()
        {
            IBusinessObjectEnumerationProperty property = CreateProperty("NullableScalar");

            BooleanEnumerationValueInfo[] expected = new []
            {
                new BooleanEnumerationValueInfo(true, (IBusinessObjectBooleanProperty)property),
                new BooleanEnumerationValueInfo(false, (IBusinessObjectBooleanProperty)property)
            };

            CheckEnumerationValueInfos(expected, property.GetEnabledValues(null));
        }
Exemplo n.º 10
0
        public void DisableWithBusinessObject()
        {
            IBusinessObjectEnumerationProperty property = CreateProperty(typeof(ClassWithDisabledEnumValue), "DisabledWithObject");

            EnumerationValueInfo[] expected = new[]
            {
                new EnumerationValueInfo(TestEnum.Value1, "Value1", "Value1", true),
                new EnumerationValueInfo(TestEnum.Value3, "Value3", "Value3", true),
                new EnumerationValueInfo(TestEnum.Value5, "Value5", "Value5", true),
            };

            CheckEnumerationValueInfos(expected, property.GetEnabledValues(MockRepository.GenerateStub <IBusinessObject>()));
        }
Exemplo n.º 11
0
        public void UndefinedValueEnum()
        {
            IBusinessObjectEnumerationProperty property = CreateProperty(typeof(ClassWithValueType <EnumWithUndefinedValue>), "Scalar");

            EnumerationValueInfo[] expected = new[]
            {
                new EnumerationValueInfo(EnumWithUndefinedValue.Value1, "Value1", "Value1", true),
                new EnumerationValueInfo(EnumWithUndefinedValue.Value2, "Value2", "Value2", true),
                new EnumerationValueInfo(EnumWithUndefinedValue.Value3, "Value3", "Value3", true)
            };

            CheckEnumerationValueInfos(expected, property.GetAllValues(null));
        }
        public void SetUp()
        {
            _businessObjectStub = MockRepository.GenerateStub <IBusinessObject>();
            _propertyStub       = MockRepository.GenerateStub <IBusinessObjectEnumerationProperty>();

            _value1 = new EnumerationValueInfo("Value1", "ID1", "Value 1", true);

            _trueFilterStub = MockRepository.GenerateStub <IEnumerationValueFilter>();
            _trueFilterStub.Stub(stub => stub.IsEnabled(_value1, _businessObjectStub, _propertyStub)).Return(true);

            _falseFilterStub = MockRepository.GenerateStub <IEnumerationValueFilter>();
            _falseFilterStub.Stub(stub => stub.IsEnabled(_value1, _businessObjectStub, _propertyStub)).Return(false);
        }
Exemplo n.º 13
0
        public void IsEnabled_WithTrue()
        {
            IBusinessObject mockBusinessObject = _mockRepository.StrictMock <IBusinessObject> ();
            IBusinessObjectEnumerationProperty mockProperty = _mockRepository.StrictMock <IBusinessObjectEnumerationProperty> ();

            IEnumerationValueFilter filter = new ConstantEnumerationValueFilter(new Enum[] { TestEnum.Value1, TestEnum.Value4 });

            _mockRepository.ReplayAll();

            bool actual = filter.IsEnabled(new EnumerationValueInfo(TestEnum.Value2, "Value2", null, true), mockBusinessObject, mockProperty);

            _mockRepository.VerifyAll();
            Assert.That(actual, Is.True);
        }
Exemplo n.º 14
0
        public void DisableFromPropertyType()
        {
            IBusinessObjectEnumerationProperty property = CreateProperty(typeof(ClassWithDisabledEnumValue), "DisabledFromPropertyType");

            EnumerationValueInfo[] expected = new[]
            {
                new EnumerationValueInfo(TestEnum.Value1, "Value1", "Value1", true),
                new EnumerationValueInfo(TestEnum.Value2, "Value2", "Value2", true),
                new EnumerationValueInfo(TestEnum.Value3, "Value3", "Value3", true),
                new EnumerationValueInfo(TestEnum.Value4, "Value4", "Value4", true)
            };

            CheckEnumerationValueInfos(expected, property.GetEnabledValues(null));
        }
Exemplo n.º 15
0
        public void NullableEnum()
        {
            IBusinessObjectEnumerationProperty property = CreateProperty(typeof(ClassWithValueType <TestEnum>), "NullableScalar");

            EnumerationValueInfo[] expected = new[]
            {
                new EnumerationValueInfo(TestEnum.Value1, "Value1", "Value1", true),
                new EnumerationValueInfo(TestEnum.Value2, "Value2", "Value2", true),
                new EnumerationValueInfo(TestEnum.Value3, "Value3", "Value3", true),
                new EnumerationValueInfo(TestEnum.Value4, "Value4", "Value4", true),
                new EnumerationValueInfo(TestEnum.Value5, "Value5", "Value5", false)
            };

            CheckEnumerationValueInfos(expected, property.GetAllValues(null));
        }
Exemplo n.º 16
0
        public override void SetUp()
        {
            base.SetUp();
            _bocEnumValue    = new BocEnumValueMock();
            _bocEnumValue.ID = "BocEnumValue";
            NamingContainer.Controls.Add(_bocEnumValue);

            _businessObject = TypeWithEnum.Create();

            _propertyEnumValue =
                (IBusinessObjectEnumerationProperty)((IBusinessObject)_businessObject).BusinessObjectClass.GetPropertyDefinition("EnumValue");

            _dataSource = new StubDataSource(((IBusinessObject)_businessObject).BusinessObjectClass);
            _dataSource.BusinessObject = (IBusinessObject)_businessObject;
        }
Exemplo n.º 17
0
        public void GetDisplayNameFromGlobalizationSerivce()
        {
            var mockEnumerationGlobalizationService     = _mockRepository.StrictMock <IEnumerationGlobalizationService>();
            IBusinessObjectEnumerationProperty property = CreateProperty(
                typeof(ClassWithValueType <TestEnum>),
                "Scalar",
                bindableObjectGlobalizationService: new BindableObjectGlobalizationService(
                    MockRepository.GenerateStub <IGlobalizationService>(),
                    MockRepository.GenerateStub <IMemberInformationGlobalizationService>(),
                    mockEnumerationGlobalizationService,
                    MockRepository.GenerateStub <IExtensibleEnumGlobalizationService>()));

            Expect.Call(
                mockEnumerationGlobalizationService.TryGetEnumerationValueDisplayName(Arg.Is(TestEnum.Value1), out Arg <string> .Out("MockValue1").Dummy))
            .Return(true);
            _mockRepository.ReplayAll();

            IEnumerationValueInfo actual = property.GetValueInfoByValue(TestEnum.Value1, null);

            _mockRepository.VerifyAll();
            CheckEnumerationValueInfo(new EnumerationValueInfo(TestEnum.Value1, "Value1", "MockValue1", true), actual);
        }
Exemplo n.º 18
0
 public override void SetUp()
 {
     base.SetUp();
     _ace      = CreateAceForStateless();
     _property = GetPropertyDefinition(_ace, "TenantCondition");
 }
 public bool IsEnabled(IEnumerationValueInfo value, IBusinessObject businessObject, IBusinessObjectEnumerationProperty property)
 {
     return(true);
 }
Exemplo n.º 20
0
        public bool IsEnabled(IEnumerationValueInfo value, IBusinessObject businessObject, IBusinessObjectEnumerationProperty property)
        {
            ArgumentUtility.CheckNotNull("value", value);
            ArgumentUtility.CheckNotNullAndType <AccessControlEntry> ("businessObject", businessObject);
            ArgumentUtility.CheckNotNull("property", property);

            AccessControlEntry ace = (AccessControlEntry)businessObject;
            bool isStateful        = ace.AccessControlList is StatefulAccessControlList;

            switch (property.Identifier)
            {
            case "TenantCondition":
                return(value.IsEnabled && IsTenantConditionEnabled((TenantCondition)value.Value, isStateful));

            case "GroupCondition":
                return(value.IsEnabled && IsGroupConditionEnabled((GroupCondition)value.Value, isStateful));

            case "UserCondition":
                return(value.IsEnabled && IsUserConditionEnabled((UserCondition)value.Value, isStateful));

            default:
                throw CreateInvalidOperationException("The property '{0}' is not supported by the '{1}'.", property.Identifier, typeof(AccessControlEntryPropertiesEnumerationValueFilter).FullName);
            }
        }
Exemplo n.º 21
0
        public void UndefinedEnumValue()
        {
            IBusinessObjectEnumerationProperty property = CreateProperty(typeof(ClassWithValueType <EnumWithUndefinedValue>), "Scalar");

            Assert.That(property.GetValueInfoByValue(EnumWithUndefinedValue.UndefinedValue, null), Is.Null);
        }
Exemplo n.º 22
0
        public void Null()
        {
            IBusinessObjectEnumerationProperty property = CreateProperty(typeof(ClassWithValueType <TestEnum>), "Scalar");

            Assert.That(property.GetValueInfoByValue(null, null), Is.Null);
        }
Exemplo n.º 23
0
        public bool IsEnabled(IEnumerationValueInfo value, IBusinessObject businessObject, IBusinessObjectEnumerationProperty property)
        {
            ArgumentUtility.CheckNotNull("value", value);
            ArgumentUtility.CheckNotNull("businessObject", businessObject);
            ArgumentUtility.CheckNotNull("property", property);

            return((int)value.Value % 2 == 1);
        }
Exemplo n.º 24
0
        public void EnumValueFromOtherType()
        {
            IBusinessObjectEnumerationProperty property = CreateProperty(typeof(ClassWithValueType <TestEnum>), "Scalar");

            property.GetValueInfoByValue(EnumWithUndefinedValue.Value1, null);
        }
Exemplo n.º 25
0
        /// <summary>
        /// Determines whether the specified value is enabled. A value is enabled if it is not in the list of <see cref="DisabledIDs"/>.
        /// </summary>
        /// <param name="value">The value to check.</param>
        /// <param name="businessObject">The business object hosting the property for which the check is performed.</param>
        /// <param name="property">The property for which the check is performed.</param>
        /// <returns>
        ///     <see langword="true" /> if the specified value is enabled; otherwise, <see langword="false" />.
        /// </returns>
        public bool IsEnabled(IEnumerationValueInfo value, IBusinessObject businessObject, IBusinessObjectEnumerationProperty property)
        {
            ArgumentUtility.CheckNotNull("value", value);
            ArgumentUtility.CheckNotNull("property", property);

            return(!_disabledIDs.Contains(value.Identifier));
        }
Exemplo n.º 26
0
        public void IBusinessObjectEnumerationProperty_GetValueInfoByIdentifier_WithEmptyString()
        {
            IBusinessObjectEnumerationProperty property = CreateProperty("Scalar");

            Assert.That(property.GetValueInfoByIdentifier(string.Empty, null), Is.Null);
        }
        public bool IsEnabled(IEnumerationValueInfo value, IBusinessObject businessObject, IBusinessObjectEnumerationProperty property)
        {
            ArgumentUtility.CheckNotNull("value", value);
            ArgumentUtility.CheckNotNull("property", property);

            return(!_filters.Any(f => !f.IsEnabled(value, businessObject, property)));
        }
Exemplo n.º 28
0
        public void IBusinessObjectEnumerationProperty_GetValueInfoByValue_WithNull()
        {
            IBusinessObjectEnumerationProperty property = CreateProperty("Scalar");

            Assert.That(property.GetValueInfoByValue(null, null), Is.Null);
        }
 public bool IsEnabled(IEnumerationValueInfo value, IBusinessObject businessObject, IBusinessObjectEnumerationProperty property)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 30
0
        public bool IsEnabled(IEnumerationValueInfo value, IBusinessObject businessObject, IBusinessObjectEnumerationProperty property)
        {
            ArgumentUtility.CheckNotNull("value", value);
            ArgumentUtility.CheckNotNull("property", property);

            return(!Array.Exists(_disabledEnumValues, disabledValue => disabledValue.Equals(value.Value)));
        }