Exemplo n.º 1
0
        public void Scalar_WithValue()
        {
            IEnumerationValueInfo enumValueInfo = new EnumerationValueInfo(TestEnum.Value5, "Value5", "ExpectedStringValue", true);

            Expect.Call(_mockProperty.IsList).Return(false);
            Expect.Call(_mockBusinessObject.GetProperty(_mockProperty)).Return(TestEnum.Value5);
            Expect.Call(_mockProperty.GetValueInfoByValue(TestEnum.Value5, _mockBusinessObject)).Return(enumValueInfo);
            _mockRepository.ReplayAll();

            string actual = _stringFormatterService.GetPropertyString(_mockBusinessObject, _mockProperty, null);

            _mockRepository.VerifyAll();
            Assert.That(actual, Is.EqualTo("ExpectedStringValue"));
        }
Exemplo n.º 2
0
        public void InvalidEnumValue()
        {
            IBusinessObjectEnumerationProperty property = CreateProperty(typeof(ClassWithValueType <TestEnum>), "Scalar");

            CheckEnumerationValueInfo(
                new EnumerationValueInfo((TestEnum)(-1), "-1", "-1", false),
                property.GetValueInfoByValue((TestEnum)(-1), null));
        }
Exemplo n.º 3
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.º 4
0
        public void IBusinessObjectEnumerationProperty_GetValueInfoByValue_WithFalse()
        {
            IBusinessObjectEnumerationProperty property = CreateProperty("Scalar");

            CheckEnumerationValueInfo(
                new BooleanEnumerationValueInfo(false, (IBusinessObjectBooleanProperty)property),
                property.GetValueInfoByValue(false, 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.º 6
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.º 7
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.º 8
0
        public void UndefinedEnumValue()
        {
            IBusinessObjectEnumerationProperty property = CreateProperty(typeof(ClassWithValueType <EnumWithUndefinedValue>), "Scalar");

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

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

            property.GetValueInfoByValue(EnumWithUndefinedValue.Value1, null);
        }
Exemplo n.º 11
0
        public void IBusinessObjectEnumerationProperty_GetValueInfoByValue_WithNull()
        {
            IBusinessObjectEnumerationProperty property = CreateProperty("Scalar");

            Assert.That(property.GetValueInfoByValue(null, null), Is.Null);
        }