Unit Testing
There are 2 entries for the tag Unit Testing

Unit testing a method that relies on DateTime.Now is generally a challenge. Take the below example, which was the first version of a method to get the Current Price of a Product. The business rule for GetCurrentPrice() is simple: find the most recent price where the effective date is not in the future. For this scenario, imagine the user sets the Price of a product to $25,000 but that price doesn't take effect until the next year. Until that time, we must make sure that the system returns the previous (existing) price. The poorly testable method public decimal GetCurrentPrice() { ...

Today I began integration testing my SqlRepository while I experiment with an MVC prototype. I tried googling for a simple base class for integration testing a LINQ to SQL DataContext that would provide automatic rollback between each test, but after (minimal) searching, decided to simply write my own. Perhaps this will help someone. This base class was written for MS Test, but simply renaming the attributes accordingly would yield the same results on nUnit, xUnit, etc. The Code Simply inherit your test class from this base class and any changes done via the internal Context property will be...