This repo contains the files used for the Intro to Unit Testing Workshop presented by John Wang and Ray Singer at CPP.
To show what unit testing is, why it is so helpful and how you can use it in your own projects. Get you started with unit testing, and show how you can use unit testing to your advantage in CPP's VP1 project.
The files are designed to show how testing can be implemented against the VP1 project's datalayer, to check for a sound SQL connection and that the data returned is correct.
Rather than making a standard database with orders or movies like we do in class, I decided to make it based around a gang. It contains gang members and their corresponding weapons. I was planning to go further in implementing this and make a more detailed system, which I may still do at some stage. For now it seems more important to get this workshop done to provide students with a start into unit testing.
If you have a GitHub account you can fork this repository, else you can download the ZIP file.
- Once you have a copy of this project, first restore the database.
- The database is a .bak file. If this file doesn't up, ensure your global git ignore doesn't include *.bak files.
- Open SQL Management Studio, expand the Database Engine, select the server inside, right click and connect to it.
- Right click on the Databases folder in the Object Explorer and select the Restore Database option.
- In the dialog box select the Device under Source, click the ellipsis, ensure Backup Media Type is selected as File and click on the Add button.
- Navigate to the BadassGangDB.bak file location and click OK to restore the database.
- Now you can load up the solution in Visual Studio.
- With the solution open, reveal the Server Explorer panel in VS (Visual Studio). Right click on Data Connections, hit Refresh. Right click again and select Add Connection.
- Under Server Name enter localhost, this should populate the Connect to a database combobox.
- Select BadassGangDB and hit OK.
- With the database connected you can now run the tests
- Navigate to Test > Run > All Tests.
- Alternatively if you wish to debug you tests by positioning breakpoints in them, select Test > Debug > All Tests.