O'Reilly logo

Visual Basic 2010 Unleashed by Alessandro Del Sole

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating Unit Tests

First, you need some code to test. Imagine you have a Rectangle class that exposes methods for math calculations on a rectangle’s perimeter and area. Create a new class library, name it UnitTestDemo; then rename Class1.vb as Rectangle.vb and write the following code:

image

Imagine you want to test both methods to check if they work correctly but inside an isolated environment, abstracted from the original project. In the code editor select both methods; then right-click and select Create Unit Tests. This launches the Create Unit Tests dialog, where you can select objects to add to the test project. Expand the UnitTestDemo namespace ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required