2 minute read

During the development of our CodeSmith Generator CSLA templates we have spent a lot time unit testing the generated code to ensure everything was working correctly.

PetShop Unit Test Session

In the future we would like to generate basic CRUD unit tests for any project. We decided to unit test the PetShop database to go along with our PetShop Sample application. We have a solution both in VB and C# that can be found in (Documents\CodeSmith\Samples\v5.3\Projects\Framework-Samples\Csla) when you install CodeSmith Generator or grab the latest version from git. We have unit tests for all the Data Access implementations as well as collections. We test primarily against two tables, Category and LineItem.

PetShop Solution

These NUnit tests will give you a good understanding of how different operations are performed in CSLA. Feel free to submit to CodeSmith Generator support or CodeSmith Community Forums any unit tests you think we don’t have. If you find a bug in the CSLA templates, its a huge help to the community and us if you submit a failing unit test for the PetShop sample application that can reproduce your bug. This ensures we have more testability and no regressions in future versions. However, any unit test will be appreciated along with the respected sample schema. When contributing new unit tests, please try to follow our common testing pattern for consistency that outputs a description and how long it took to run the test.

Unit Testing Code

Join the mailing list

Get notified of new posts and related content to your inbox. I will never sell you anything and I will NEVER sell your email address.