views:

21

answers:

1

I currently have a business object with a validation business rule, which is it can only be created for the future, tomorrow onwards, and I cannot create new items for today.

I have a process, which runs the non-future business objects through some steps..

Because I have to set things up today, and test tomorrow, and when it fails, I can only create a new object tomorrow and test the following day.

Are there any easy ways to automate this process in any testing frameworks? I think our testers are using the visual studio 2010 test manager. How do you guys manage situations like this?

Cheers

+3  A: 

The easiest way is to abstract the concept of the current time...

/// <summary>Use this to get the current time</summary>
public class TimeService {
  public virtual DateTime GetCurrentTime() {
    return DateTime.Now;
  }
}

...then mock out that service when testing time sensitive things.

Great Answer! Time and date sensitive testing is exactly what this little service is for.
Gutzofter
Agreed, great answer.
shambleh