c# - Testing Conditional Logic based on a Date -


i have c# mvc ef6 code first solution. there project repository, services, model , web. requirement screen lists out cases in system. case has bool property called attention read has business logic in return true if responsedue property > datetime.now.

for testing purposes, client wants able fake date today if responsedue property 3 weeks future able screen 3 weeks , make sure cases listed marked attention when date comes.

i not sure how accommodate testing requirement without hurting design or performance. thinking of having comparedate property on case class default datetime.now set different date if needed wasn't sure how pass date in service layer , repository layer cases set comparedate got passed public virtual ienumerable getall() method.

what defining virtual method or property can override in test.

here example of this. not same property, still demonstration of general concept. http://unit-testing.net/currentarticle/how-to-remove-data-dependencies-in-unit-tests.html

alternatively can use mocking framework.


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -