public void ToString_FormatValueSpanishEcuador_AreEqual() { var act = HouseNumber.Parse("1700").ToString("00000.0", new CultureInfo("es-EC")); var exp = "01700,0"; Assert.AreEqual(exp, act); }
public void ToString_FormatValueEnglishGreatBritain_AreEqual() { using (new CultureInfoScope("en-GB")) { var act = HouseNumber.Parse("800").ToString("0000"); var exp = "0800"; Assert.AreEqual(exp, act); } }
public void ToString_FormatValueDutchBelgium_AreEqual() { using (new CultureInfoScope("nl-BE")) { var act = HouseNumber.Parse("800").ToString("0000"); var exp = "0800"; Assert.AreEqual(exp, act); } }
public void Parse_Unknown_AreEqual() { using (new CultureInfoScope("en-GB")) { var act = HouseNumber.Parse("?"); var exp = HouseNumber.Unknown; Assert.AreEqual(exp, act); } }
/// <summary>Converts a string to a house number, using the specified /// context and culture information. /// </summary> /// <param name="context"> /// An System.ComponentModel.ITypeDescriptorContext that provides a format context. /// </param> /// <param name="culture"> /// The System.Globalization.CultureInfo to use as the current culture. /// </param> /// <param name="value"> /// The System.Object to convert. /// </param> /// <returns> /// An System.Object that represents the converted value. /// </returns> /// <exception cref="NotSupportedException"> /// The conversion cannot be performed. /// </exception> public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { var str = value as string; if (value == null || str != null) { return(HouseNumber.Parse(str, culture)); } return(base.ConvertFrom(context, culture, value)); }
public void Parse_InvalidInput_ThrowsFormatException() { using (new CultureInfoScope("en-GB")) { Assert.Catch <FormatException> (() => { HouseNumber.Parse("InvalidInput"); }, "Not a valid house number"); } }