public void TryParseByte_FromString() { var invalidValue1 = double.MaxValue.ToString(CultureInfo.InvariantCulture); var invalidValue2 = double.MinValue.ToString(CultureInfo.InvariantCulture); #region full method var success = ConvertibleStringValue.TryParseByte(DefaultValue, BasePrimitivesExtensions.GetDefaultByteAllowDefaultConversion(), BasePrimitivesExtensions.GetDefaultByteNumberStyle(), BasePrimitivesExtensions.GetCurrentCulture()); var invalid1 = invalidValue1.TryParseByte(DefaultValue, BasePrimitivesExtensions.GetDefaultByteAllowDefaultConversion(), BasePrimitivesExtensions.GetDefaultByteNumberStyle(), BasePrimitivesExtensions.GetCurrentCulture()); var invalid2 = invalidValue2.TryParseByte(DefaultValue, BasePrimitivesExtensions.GetDefaultByteAllowDefaultConversion(), BasePrimitivesExtensions.GetDefaultByteNumberStyle(), BasePrimitivesExtensions.GetCurrentCulture()); Assert.AreEqual(success, ConvertibleByteValue, "Error converting string to byte"); Assert.AreEqual(invalid1, DefaultValue, "Error converting string to byte"); Assert.AreEqual(invalid2, DefaultValue, "Error converting string to byte"); #endregion #region without allowZero param success = ConvertibleStringValue.TryParseByte(DefaultValue, BasePrimitivesExtensions.GetDefaultByteNumberStyle(), BasePrimitivesExtensions.GetCurrentCulture()); invalid1 = invalidValue1.TryParseByte(DefaultValue, BasePrimitivesExtensions.GetDefaultByteNumberStyle(), BasePrimitivesExtensions.GetCurrentCulture()); invalid2 = invalidValue2.TryParseByte(DefaultValue, BasePrimitivesExtensions.GetDefaultByteNumberStyle(), BasePrimitivesExtensions.GetCurrentCulture()); Assert.AreEqual(success, ConvertibleByteValue, "Error converting string to byte"); Assert.AreEqual(invalid1, DefaultValue, "Error converting string to byte"); Assert.AreEqual(invalid2, DefaultValue, "Error converting string to byte"); #endregion #region without allowZero and DefaultValue params success = ConvertibleStringValue.TryParseByte(BasePrimitivesExtensions.GetDefaultByteNumberStyle(), BasePrimitivesExtensions.GetCurrentCulture()); invalid1 = invalidValue1.TryParseByte(BasePrimitivesExtensions.GetDefaultByteNumberStyle(), BasePrimitivesExtensions.GetCurrentCulture()); invalid2 = invalidValue2.TryParseByte(BasePrimitivesExtensions.GetDefaultByteNumberStyle(), BasePrimitivesExtensions.GetCurrentCulture()); Assert.AreEqual(success, ConvertibleByteValue, "Error converting string to byte"); Assert.AreEqual(invalid1, BasePrimitivesExtensions.GetDefaultByteConversionValue(), "Error converting string to byte"); Assert.AreEqual(invalid2, BasePrimitivesExtensions.GetDefaultByteConversionValue(), "Error converting string to byte"); #endregion #region without number style and culture params success = ConvertibleStringValue.TryParseByte(DefaultValue, BasePrimitivesExtensions.GetDefaultByteAllowDefaultConversion()); invalid1 = invalidValue1.TryParseByte(DefaultValue, BasePrimitivesExtensions.GetDefaultByteAllowDefaultConversion()); invalid2 = invalidValue2.TryParseByte(DefaultValue, BasePrimitivesExtensions.GetDefaultByteAllowDefaultConversion()); Assert.AreEqual(success, ConvertibleByteValue, "Error converting string to byte"); Assert.AreEqual(invalid1, DefaultValue, "Error converting string to byte"); Assert.AreEqual(invalid2, DefaultValue, "Error converting string to byte"); #endregion #region without number style, culture and allowZero params success = ConvertibleStringValue.TryParseByte(DefaultValue); invalid1 = invalidValue1.TryParseByte(DefaultValue); invalid2 = invalidValue2.TryParseByte(DefaultValue); Assert.AreEqual(success, ConvertibleByteValue, "Error converting string to byte"); Assert.AreEqual(invalid1, DefaultValue, "Error converting string to byte"); Assert.AreEqual(invalid2, DefaultValue, "Error converting string to byte"); #endregion #region simple conversion success = ConvertibleStringValue.TryParseByte(); invalid1 = invalidValue1.TryParseByte(); invalid2 = invalidValue2.TryParseByte(); Assert.AreEqual(success, ConvertibleByteValue, "Error converting string to byte"); Assert.AreEqual(invalid1, BasePrimitivesExtensions.GetDefaultByteConversionValue(), "Error converting string to byte"); Assert.AreEqual(invalid2, BasePrimitivesExtensions.GetDefaultByteConversionValue(), "Error converting string to byte"); #endregion }