public void TryParseDouble_FromDecimalAndNullableDecimal() { #region double - full method var success = ConvertibleDecimalValue.TryParseDouble(); Assert.AreEqual(success, ConvertibleDoubleValue, "Error converting double to double"); #endregion #region double - without DefaultValue param success = ConvertibleDecimalValue.TryParseDouble(); Assert.AreEqual(success, ConvertibleDoubleValue, "Error converting double to double"); #endregion #region double? - full method success = ConvertibleNullableDecimalValue.TryParseDouble(DefaultValue); var invalid1 = ((decimal?)null).TryParseDouble(DefaultValue); Assert.AreEqual(success, ConvertibleDoubleValue, "Error converting double? to double"); Assert.AreEqual(invalid1, DefaultValue, "Error converting double? to double"); #endregion #region double? - without DefaultValue param success = ConvertibleNullableDecimalValue.TryParseDouble(); invalid1 = ((decimal?)null).TryParseDouble(); Assert.AreEqual(success, ConvertibleDoubleValue, "Error converting double? to double"); Assert.AreEqual(invalid1, BasePrimitivesExtensions.GetDefaultIntConversionValue(), "Error converting double? to double"); #endregion }
public void TryParseFloat_FromDecimalAndNullableDecimal() { #region float - full method var success = ConvertibleDecimalValue.TryParseFloat(DefaultValue); Assert.AreEqual(success, ConvertibleFloatValue, "Error converting decimal to float"); #endregion #region float - without DefaultValue param success = ConvertibleDecimalValue.TryParseFloat(); Assert.AreEqual(success, ConvertibleFloatValue, "Error converting decimal to float"); #endregion #region float? - full method success = ConvertibleNullableDecimalValue.TryParseFloat(DefaultValue); var invalid1 = ((decimal?)null).TryParseFloat(DefaultValue); Assert.AreEqual(success, ConvertibleFloatValue, "Error converting decimal? to float"); Assert.AreEqual(invalid1, DefaultValue, "Error converting decimal? to float"); #endregion #region float? - without DefaultValue param success = ConvertibleNullableDecimalValue.TryParseFloat(); invalid1 = ((decimal?)null).TryParseFloat(); Assert.AreEqual(success, ConvertibleFloatValue, "Error converting decimal? to float"); Assert.AreEqual(invalid1, BasePrimitivesExtensions.GetDefaultFloatConversionValue(), "Error converting decimal? to float"); #endregion }
public void TryParseShort_FromDecimalAndNullableDecimal() { const decimal invalidValue1 = decimal.MaxValue; decimal? nullableInvalidValue1 = decimal.MaxValue; const decimal invalidValue2 = decimal.MinValue; decimal? nullableInvalidValue2 = decimal.MinValue; #region decimal - full method var success = ConvertibleDecimalValue.TryParseShort(DefaultValue); var invalid1 = invalidValue1.TryParseShort(DefaultValue); var invalid2 = invalidValue2.TryParseShort(DefaultValue); Assert.AreEqual(success, ConvertibleShortValue, "Error converting decimal to short"); Assert.AreEqual(invalid1, DefaultValue, "Error converting decimal to short"); Assert.AreEqual(invalid2, DefaultValue, "Error converting decimal to short"); #endregion #region decimal - without DefaultValue param success = ConvertibleDecimalValue.TryParseShort(); invalid1 = invalidValue1.TryParseShort(); invalid2 = invalidValue2.TryParseShort(); Assert.AreEqual(success, ConvertibleShortValue, "Error converting decimal to short"); Assert.AreEqual(invalid1, BasePrimitivesExtensions.GetDefaultShortConversionValue(), "Error converting decimal to short"); Assert.AreEqual(invalid2, BasePrimitivesExtensions.GetDefaultShortConversionValue(), "Error converting decimal to short"); #endregion #region decimal? - full method success = ConvertibleNullableDecimalValue.TryParseShort(DefaultValue); invalid1 = nullableInvalidValue1.TryParseShort(DefaultValue); invalid2 = nullableInvalidValue2.TryParseShort(DefaultValue); Assert.AreEqual(success, ConvertibleShortValue, "Error converting decimal? to short"); Assert.AreEqual(invalid1, DefaultValue, "Error converting decimal? to short"); Assert.AreEqual(invalid2, DefaultValue, "Error converting decimal? to short"); #endregion #region decimal? - without DefaultValue param success = ConvertibleNullableDecimalValue.TryParseShort(); invalid1 = nullableInvalidValue1.TryParseShort(); invalid2 = nullableInvalidValue2.TryParseShort(); Assert.AreEqual(success, ConvertibleShortValue, "Error converting decimal? to short"); Assert.AreEqual(invalid1, BasePrimitivesExtensions.GetDefaultShortConversionValue(), "Error converting decimal? to short"); Assert.AreEqual(invalid2, BasePrimitivesExtensions.GetDefaultShortConversionValue(), "Error converting decimal? to short"); #endregion }