Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way to do TDD and CSLA

Tags:

tdd

csla

I would like to know what tools, patterns, etc people have used to be able to do TDD with CSLA .NET 3.8 and higher.

Which parts pose the most effort. Are there parts that are completely untested, etc.

Any and all information is most welcome.

Thanks

like image 658
Hagashen Avatar asked Aug 30 '11 14:08

Hagashen


1 Answers

I use a combination of SpecFlow with xUnit to test my CSLA business objects. SpecFlow with xUnit are used to define and test the user scenarios (think: functional/acceptance testing), and xUnit alone is used to test individual classes and combinations of such.

Dependencies within the CSLA classes, such as data-access, are injected via a container. Such dependencies can and often are mocked for unit testing.

The test client and our remote Data Portal have separate containers loaded with the correct dependencies. If a test needs to mock any of the Data Portal dependencies we have a special CSLA Command that is executed (via xUnit BeforeAfterTestAttribute) on the Data Portal and replaces standard dependencies with our mocked dependencies. When the tests complete the Command is executed again to put the standard dependencies back into the container.

I hope some of this helps.

like image 62
Ed James Avatar answered Sep 27 '22 21:09

Ed James