public void SetUp()
 {
     _stringFormatterService = new BusinessObjectStringFormatterService();
     _mockRepository         = new MockRepository();
     _mockBusinessObject     = _mockRepository.StrictMock <IBusinessObject>();
     _mockProperty           = _mockRepository.StrictMock <IBusinessObjectDateTimeProperty>();
 }
示例#2
0
 /// <summary> Returns the proper <see cref="BocTextValueType"/> for the passed <see cref="IBusinessObjectProperty"/>. </summary>
 /// <param name="property"> The <see cref="IBusinessObjectProperty"/> to analyze. </param>
 /// <exception cref="NotSupportedException"> The specialized type of the <paremref name="property"/> is not supported. </exception>
 private BocTextValueType GetBocTextValueType(IBusinessObjectProperty property)
 {
     if (property is IBusinessObjectStringProperty)
     {
         return(BocTextValueType.String);
     }
     else if (property is IBusinessObjectNumericProperty)
     {
         IBusinessObjectNumericProperty numericProperty = (IBusinessObjectNumericProperty)property;
         if (numericProperty.Type == typeof(byte))
         {
             return(BocTextValueType.Byte);
         }
         else if (numericProperty.Type == typeof(decimal))
         {
             return(BocTextValueType.Decimal);
         }
         else if (numericProperty.Type == typeof(double))
         {
             return(BocTextValueType.Double);
         }
         else if (numericProperty.Type == typeof(short))
         {
             return(BocTextValueType.Int16);
         }
         else if (numericProperty.Type == typeof(int))
         {
             return(BocTextValueType.Int32);
         }
         else if (numericProperty.Type == typeof(long))
         {
             return(BocTextValueType.Int64);
         }
         else if (numericProperty.Type == typeof(float))
         {
             return(BocTextValueType.Single);
         }
         else
         {
             throw new NotSupportedException("BocTextValue does not support property type " + property.GetType());
         }
     }
     else if (property is IBusinessObjectDateTimeProperty)
     {
         IBusinessObjectDateTimeProperty dateTimeProperty = (IBusinessObjectDateTimeProperty)property;
         if (dateTimeProperty.Type == DateTimeType.Date)
         {
             return(BocTextValueType.Date);
         }
         else
         {
             return(BocTextValueType.DateTime);
         }
     }
     else
     {
         throw new NotSupportedException("BocTextValue does not support property type " + property.GetType());
     }
 }
示例#3
0
        public override void SetUp()
        {
            base.SetUp();
            _bocDateTimeValue    = new BocDateTimeValueMock();
            _bocDateTimeValue.ID = "BocDateTimeValue";
            NamingContainer.Controls.Add(_bocDateTimeValue);

            _businessObject = TypeWithDateTime.Create();

            _propertyDateTimeValue         = (IBusinessObjectDateTimeProperty)((IBusinessObject)_businessObject).BusinessObjectClass.GetPropertyDefinition("DateTimeValue");
            _propertyNullableDateTimeValue = (IBusinessObjectDateTimeProperty)((IBusinessObject)_businessObject).BusinessObjectClass.GetPropertyDefinition("NullableDateTimeValue");

            _dataSource = new StubDataSource(((IBusinessObject)_businessObject).BusinessObjectClass);
            _dataSource.BusinessObject = (IBusinessObject)_businessObject;
        }
        private string GetStringValueForDateTimeProperty(object value, IBusinessObjectDateTimeProperty property, string format)
        {
            if (string.IsNullOrEmpty(format))
            {
                if (property.Type == DateTimeType.Date)
                {
                    format = "d";
                }
                else
                {
                    format = "g";
                }
            }

            return(GetStringValueForFormattableValue((IFormattable)value, format));
        }
示例#5
0
        /// <summary>
        ///   Evaluates the type of <paramref name="property"/> and returns the appropriate <see cref="BocDateTimeValueType"/>.
        /// </summary>
        /// <param name="property"> The <see cref="IBusinessObjectProperty"/> to be evaluated. </param>
        /// <returns> The matching <see cref="BocDateTimeValueType"/></returns>
        private BocDateTimeValueType GetBocDateTimeValueType(IBusinessObjectProperty property)
        {
            if (property == null)
            {
                return(BocDateTimeValueType.Undefined);
            }

            IBusinessObjectDateTimeProperty dateTimeProperty = property as IBusinessObjectDateTimeProperty;

            if (dateTimeProperty == null)
            {
                throw new NotSupportedException("BocDateTimeValue does not support property type " + property.GetType());
            }

            if (dateTimeProperty.Type == DateTimeType.Date)
            {
                return(BocDateTimeValueType.Date);
            }
            else
            {
                return(BocDateTimeValueType.DateTime);
            }
        }