public void TryParseDouble_FromString() { const string invalidValue1 = ""; const string invalidValue2 = "b"; #region full method var success = ConvertibleStringValue.TryParseDouble(DefaultValue, BasePrimitivesExtensions.GetDefaultDoubleAllowDefaultConversion(), BasePrimitivesExtensions.GetDefaultDoubleNumberStyle(), BasePrimitivesExtensions.GetCurrentCulture()); var invalid1 = invalidValue1.TryParseDouble(DefaultValue, BasePrimitivesExtensions.GetDefaultDoubleAllowDefaultConversion(), BasePrimitivesExtensions.GetDefaultDoubleNumberStyle(), BasePrimitivesExtensions.GetCurrentCulture()); var invalid2 = invalidValue2.TryParseDouble(DefaultValue, BasePrimitivesExtensions.GetDefaultDoubleAllowDefaultConversion(), BasePrimitivesExtensions.GetDefaultDoubleNumberStyle(), BasePrimitivesExtensions.GetCurrentCulture()); Assert.AreEqual(success, ConvertibleDoubleValue, "Error converting string to double"); Assert.AreEqual(invalid1, DefaultValue, "Error converting string to double"); Assert.AreEqual(invalid2, DefaultValue, "Error converting string to double"); #endregion #region without allowZero param success = ConvertibleStringValue.TryParseDouble(DefaultValue, BasePrimitivesExtensions.GetDefaultDoubleNumberStyle(), BasePrimitivesExtensions.GetCurrentCulture()); invalid1 = invalidValue1.TryParseDouble(DefaultValue, BasePrimitivesExtensions.GetDefaultDoubleNumberStyle(), BasePrimitivesExtensions.GetCurrentCulture()); invalid2 = invalidValue2.TryParseDouble(DefaultValue, BasePrimitivesExtensions.GetDefaultDoubleNumberStyle(), BasePrimitivesExtensions.GetCurrentCulture()); Assert.AreEqual(success, ConvertibleDoubleValue, "Error converting string to double"); Assert.AreEqual(invalid1, DefaultValue, "Error converting string to double"); Assert.AreEqual(invalid2, DefaultValue, "Error converting string to double"); #endregion #region without allowZero and DefaultValue params success = ConvertibleStringValue.TryParseDouble(BasePrimitivesExtensions.GetDefaultDoubleNumberStyle(), BasePrimitivesExtensions.GetCurrentCulture()); invalid1 = invalidValue1.TryParseDouble(BasePrimitivesExtensions.GetDefaultDoubleNumberStyle(), BasePrimitivesExtensions.GetCurrentCulture()); invalid2 = invalidValue2.TryParseDouble(BasePrimitivesExtensions.GetDefaultDoubleNumberStyle(), BasePrimitivesExtensions.GetCurrentCulture()); Assert.AreEqual(success, ConvertibleDoubleValue, "Error converting string to double"); Assert.AreEqual(invalid1, BasePrimitivesExtensions.GetDefaultIntConversionValue(), "Error converting string to double"); Assert.AreEqual(invalid2, BasePrimitivesExtensions.GetDefaultIntConversionValue(), "Error converting string to double"); #endregion #region without number style and culture params success = ConvertibleStringValue.TryParseDouble(DefaultValue, BasePrimitivesExtensions.GetDefaultDoubleAllowDefaultConversion()); invalid1 = invalidValue1.TryParseDouble(DefaultValue, BasePrimitivesExtensions.GetDefaultDoubleAllowDefaultConversion()); invalid2 = invalidValue2.TryParseDouble(DefaultValue, BasePrimitivesExtensions.GetDefaultDoubleAllowDefaultConversion()); Assert.AreEqual(success, ConvertibleDoubleValue, "Error converting string to double"); Assert.AreEqual(invalid1, DefaultValue, "Error converting string to double"); Assert.AreEqual(invalid2, DefaultValue, "Error converting string to double"); #endregion #region without number style, culture and allowZero params success = ConvertibleStringValue.TryParseDouble(DefaultValue); invalid1 = invalidValue1.TryParseDouble(DefaultValue); invalid2 = invalidValue2.TryParseDouble(DefaultValue); Assert.AreEqual(success, ConvertibleDoubleValue, "Error converting string to double"); Assert.AreEqual(invalid1, DefaultValue, "Error converting string to double"); Assert.AreEqual(invalid2, DefaultValue, "Error converting string to double"); #endregion #region simple conversion success = ConvertibleStringValue.TryParseDouble(); invalid1 = invalidValue1.TryParseDouble(); invalid2 = invalidValue2.TryParseDouble(); Assert.AreEqual(success, ConvertibleDoubleValue, "Error converting string to double"); Assert.AreEqual(invalid1, BasePrimitivesExtensions.GetDefaultIntConversionValue(), "Error converting string to double"); Assert.AreEqual(invalid2, BasePrimitivesExtensions.GetDefaultIntConversionValue(), "Error converting string to double"); #endregion }