public void Compare2() { DateComparer comparer = DateComparer.Default as DateComparer; Assert.IsTrue(comparer.Compare(DateTime.Today, DateTime.Today.AddDays(1)) < 0); Assert.IsTrue(comparer.Compare(DateTime.Today.AddDays(1), DateTime.Today) > 0); Assert.IsTrue(comparer.Compare(DateTime.Today, DateTime.Today) == 0); }
public void Compare1() { DateComparer comparer = DateComparer.Default as DateComparer; string x = "10/31/2006"; string y = "11/1/2006"; Assert.IsTrue(comparer.Compare(x, y) < 0); Assert.IsTrue(comparer.Compare(y, x) > 0); Assert.IsTrue(comparer.Compare(x, x) == 0); }
public void Compare3() { DateComparer comparer = DateComparer.Default as DateComparer; ExceptionAssert.Throws <FormatException>(() => comparer.Compare("10/31/2006", "abc123")); ExceptionAssert.Throws <FormatException>(() => comparer.Compare("abc123", "10/31/2006")); ExceptionAssert.Throws <FormatException>(() => comparer.Compare("10/31/2006", String.Empty)); ExceptionAssert.Throws <FormatException>(() => comparer.Compare(String.Empty, "10/31/2006")); ExceptionAssert.Throws <ArgumentNullException>(() => comparer.Compare("10/31/2006", null)); ExceptionAssert.Throws <ArgumentNullException>(() => comparer.Compare(null, "10/31/2006")); }
public void Compare7() { DateComparer comparer = DateComparer.DefaultInvariant as DateComparer; ExceptionAssert.Throws <FormatException>(() => comparer.Compare("10/31/2006", "abc123")); ExceptionAssert.Throws <FormatException>(() => comparer.Compare("abc123", "10/31/2006")); ExceptionAssert.Throws <FormatException>(() => comparer.Compare("10/31/2006", String.Empty)); ExceptionAssert.Throws <FormatException>(() => comparer.Compare(String.Empty, "10/31/2006")); ExceptionAssert.Throws <ArgumentNullException>(() => comparer.Compare("10/31/2006", null)).WithParameter("y"); ExceptionAssert.Throws <ArgumentNullException>(() => comparer.Compare(null, "10/31/2006")).WithParameter("x"); ExceptionAssert.Throws <ArgumentNullException>(() => new DateComparer(null)); }
public void Compare9() { var comparer = new DateComparer(); object x = "10/31/2006"; object y = "11/1/2006"; Assert.IsTrue(comparer.Compare(x, y) < 0); Assert.IsTrue(comparer.Compare(y, x) > 0); Assert.IsTrue(comparer.Compare(x, x) == 0); x = String.Empty; y = String.Empty; Assert.IsTrue(comparer.Compare(x, "10/31/2006") == -1); Assert.IsTrue(comparer.Compare("10/31/2006", y) == 1); Assert.IsTrue(comparer.Compare(x, y) == 0); }
public void Compare4() { DateComparer comparer = DateComparer.DefaultInvariant as DateComparer; object x = "10/31/2006"; object y = "11/1/2006"; Assert.IsTrue(comparer.Compare(x, y) < 0); Assert.IsTrue(comparer.Compare(y, x) > 0); Assert.IsTrue(comparer.Compare(x, x) == 0); x = String.Empty; y = String.Empty; Assert.IsTrue(comparer.Compare(x, "10/31/2006") == -1); Assert.IsTrue(comparer.Compare("10/31/2006", y) == 1); Assert.IsTrue(comparer.Compare(x, y) == 0); }
public void Compare9() { DateComparer comparer = new DateComparer(); object x = "10/31/2006"; object y = "11/1/2006"; Assert.IsTrue(comparer.Compare(x, y) < 0); Assert.IsTrue(comparer.Compare(y, x) > 0); Assert.IsTrue(comparer.Compare(x, x) == 0); x = String.Empty; y = String.Empty; Assert.IsTrue(comparer.Compare(x, "10/31/2006") == -1); Assert.IsTrue(comparer.Compare("10/31/2006", y) == 1); Assert.IsTrue(comparer.Compare(x, y) == 0); }