public void TryParseByte_FromShortAndNullableShort() { const short invalidValue1 = short.MaxValue; short? nullableInvalidValue1 = short.MaxValue; const short invalidValue2 = short.MinValue; short? nullableInvalidValue2 = short.MinValue; #region short - full method var success = ConvertibleShortValue.TryParseByte(DefaultValue); var invalid1 = invalidValue1.TryParseByte(DefaultValue); var invalid2 = invalidValue2.TryParseByte(DefaultValue); Assert.AreEqual(success, ConvertibleByteValue, "Error converting short to byte"); Assert.AreEqual(invalid1, DefaultValue, "Error converting short to byte"); Assert.AreEqual(invalid2, DefaultValue, "Error converting short to byte"); #endregion #region short - without DefaultValue param success = ConvertibleShortValue.TryParseByte(); invalid1 = invalidValue1.TryParseByte(); invalid2 = invalidValue2.TryParseByte(); Assert.AreEqual(success, ConvertibleByteValue, "Error converting short to byte"); Assert.AreEqual(invalid1, BasePrimitivesExtensions.GetDefaultByteConversionValue(), "Error converting short to byte"); Assert.AreEqual(invalid2, BasePrimitivesExtensions.GetDefaultByteConversionValue(), "Error converting short to byte"); #endregion #region short? - full method success = ConvertibleNullableShortValue.TryParseByte(DefaultValue); invalid1 = nullableInvalidValue1.TryParseByte(DefaultValue); invalid2 = nullableInvalidValue2.TryParseByte(DefaultValue); Assert.AreEqual(success, ConvertibleByteValue, "Error converting short? to byte"); Assert.AreEqual(invalid1, DefaultValue, "Error converting short? to byte"); Assert.AreEqual(invalid2, DefaultValue, "Error converting short? to byte"); #endregion #region short? - without DefaultValue param success = ConvertibleNullableShortValue.TryParseByte(); invalid1 = nullableInvalidValue1.TryParseByte(); invalid2 = nullableInvalidValue2.TryParseByte(); Assert.AreEqual(success, ConvertibleByteValue, "Error converting short? to byte"); Assert.AreEqual(invalid1, BasePrimitivesExtensions.GetDefaultByteConversionValue(), "Error converting short? to byte"); Assert.AreEqual(invalid2, BasePrimitivesExtensions.GetDefaultByteConversionValue(), "Error converting short? to byte"); #endregion }
public void TryParseShort_NullableShort() { #region full method var success = ConvertibleNullableShortValue.TryParseShort(DefaultValue); var invalid = ((short?)null).TryParseShort(DefaultValue); Assert.AreEqual(success, ConvertibleShortValue, "Error converting nullable short to short"); Assert.AreEqual(invalid, DefaultValue, "Error converting nullable short to short"); #endregion #region simple method success = ConvertibleNullableShortValue.TryParseShort(); invalid = ((short?)null).TryParseShort(); Assert.AreEqual(success, ConvertibleShortValue, "Error converting nullable short to short"); Assert.AreEqual(invalid, BasePrimitivesExtensions.GetDefaultShortConversionValue(), "Error converting nullable short to short"); #endregion }
public void TryParseDouble_FromShortAndNullableShort() { #region byte - full method var success = ConvertibleShortValue.TryParseDouble(); Assert.AreEqual(success, ConvertibleDoubleValueInt, "Error converting byte to double"); #endregion #region byte? - full method success = ConvertibleNullableShortValue.TryParseDouble(DefaultValue); var invalid1 = ((short?)null).TryParseDouble(DefaultValue); Assert.AreEqual(success, ConvertibleDoubleValueInt, "Error converting byte? to double"); Assert.AreEqual(invalid1, DefaultValue, "Error converting byte? to double"); #endregion #region byte? - without DefaultValue param success = ConvertibleNullableShortValue.TryParseDouble(); invalid1 = ((short?)null).TryParseDouble(); Assert.AreEqual(success, ConvertibleDoubleValueInt, "Error converting byte? to double"); Assert.AreEqual(invalid1, BasePrimitivesExtensions.GetDefaultIntConversionValue(), "Error converting byte? to double"); #endregion }