public void Equals_FormattedAndUnformatted_IsTrue() { var l = WeekDate.Parse("1997-14-6", CultureInfo.InvariantCulture); var r = WeekDate.Parse("1997-W14-6", CultureInfo.InvariantCulture); Assert.IsTrue(l.Equals(r)); }
/// <summary>Converts a string to a week date, 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 (str != null) { return(WeekDate.Parse(str, culture)); } return(base.ConvertFrom(context, culture, value)); }
public void Parse_InvalidInput_ThrowsFormatException() { using (new CultureInfoScope("en-GB")) { Assert.Catch<FormatException> (() => { WeekDate.Parse("InvalidInput"); }, "Not a valid week date"); } }
public void OrderByDescending_WeekDate_AreEqual() { var item0 = WeekDate.Parse("2000-W01-3"); var item1 = WeekDate.Parse("2000-W11-2"); var item2 = WeekDate.Parse("2000-W21-1"); var item3 = WeekDate.Parse("2000-W31-7"); var inp = new List<WeekDate>() { WeekDate.MinValue, item3, item2, item0, item1, WeekDate.MinValue }; var exp = new List<WeekDate>() { item3, item2, item1, item0, WeekDate.MinValue, WeekDate.MinValue }; var act = inp.OrderByDescending(item => item).ToList(); CollectionAssert.AreEqual(exp, act); }