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")); }
public void InvalidEnumValue() { IBusinessObjectEnumerationProperty property = CreateProperty(typeof(ClassWithValueType <TestEnum>), "Scalar"); CheckEnumerationValueInfo( new EnumerationValueInfo((TestEnum)(-1), "-1", "-1", false), property.GetValueInfoByValue((TestEnum)(-1), null)); }
public void ValidEnumValue() { IBusinessObjectEnumerationProperty property = CreateProperty(typeof(ClassWithValueType <TestEnum>), "Scalar"); CheckEnumerationValueInfo( new EnumerationValueInfo(TestEnum.Value1, "Value1", "Value1", true), property.GetValueInfoByValue(TestEnum.Value1, null)); }
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); }
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); }
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); }
public void UndefinedEnumValue() { IBusinessObjectEnumerationProperty property = CreateProperty(typeof(ClassWithValueType <EnumWithUndefinedValue>), "Scalar"); Assert.That(property.GetValueInfoByValue(EnumWithUndefinedValue.UndefinedValue, null), Is.Null); }
public void Null() { IBusinessObjectEnumerationProperty property = CreateProperty(typeof(ClassWithValueType <TestEnum>), "Scalar"); Assert.That(property.GetValueInfoByValue(null, null), Is.Null); }
public void EnumValueFromOtherType() { IBusinessObjectEnumerationProperty property = CreateProperty(typeof(ClassWithValueType <TestEnum>), "Scalar"); property.GetValueInfoByValue(EnumWithUndefinedValue.Value1, null); }
public void IBusinessObjectEnumerationProperty_GetValueInfoByValue_WithNull() { IBusinessObjectEnumerationProperty property = CreateProperty("Scalar"); Assert.That(property.GetValueInfoByValue(null, null), Is.Null); }