DateTime Assertions

These assertion extension methods can be applied to only DateTime object types.

ShouldBeBefore

Asserts that this DateTime value is before the specified DateTime value.

Usage

public static DateTime ShouldBeBefore(this DateTime source, DateTime comparer)
public static DateTime ShouldBeBefore(this DateTime source, DateTime comparer, string message)
public static DateTime ShouldBeBefore(this DateTime source, DateTime comparer, string message, params object[] parameters)

Example

[TestMethod]
public void Test()
{
   DateTime foo = DateTime.Now;
   foo.ShouldBeBefore(Datetime.MaxValue);
}
Supported Releases: 1.1 and later

ShouldBeBeforeOrSameAs

Asserts that this DateTime value is before or the same as the specified DateTime value.

Usage

public static DateTime ShouldBeBeforeOrSameAs(this DateTime source, DateTime comparer)
public static DateTime ShouldBeBeforeOrSameAs(this DateTime source, DateTime comparer, string message)
public static DateTime ShouldBeBeforeOrSameAs(this DateTime source, DateTime comparer, string message, params object[] parameters)

Example

[TestMethod]
public void Test()
{
   DateTime foo = DateTime.Now;
   foo.ShouldBeBeforeOrSameAs(Datetime.MaxValue);

   DateTime foo = DateTime.Now;
   foo.ShouldBeBeforeOrSameAs(foo);

}
Supported Releases: 1.1 and later

ShouldBeAfter

Asserts that this DateTime value is after the specified DateTime value.

Usage

public static DateTime ShouldBeAfter(this DateTime source, DateTime comparer)
public static DateTime ShouldBeAfter(this DateTime source, DateTime comparer, string message)
public static DateTime ShouldBeAfter(this DateTime source, DateTime comparer, string message, params object[] parameters)

Example

[TestMethod]
public void Test()
{
   DateTime foo = DateTime.Now;
   foo.ShouldBeAfter(Datetime.MinValue);
}
Supported Releases: 1.1 and later

ShouldBeAfterOrSameAs

Asserts that this DateTime value is after or the same as the specified DateTime value.

Usage

public static DateTime ShouldBeAfterOrSameAs(this DateTime source, DateTime comparer)
public static DateTime ShouldBeAfterOrSameAs(this DateTime source, DateTime comparer, string message)
public static DateTime ShouldBeAfterOrSameAs(this DateTime source, DateTime comparer, string message, params object[] parameters)

Example

[TestMethod]
public void Test()
{
   DateTime foo = DateTime.Now;
   foo.ShouldBeAfterOrSameAs(Datetime.MinValue);

   DateTime foo = DateTime.Now;
   foo.ShouldBeAfterOrSameAs(foo);

}
Supported Releases: 1.1 and later

Last edited Dec 9, 2010 at 2:53 PM by jeremiahclark, version 2

Comments

No comments yet.