This method will test the default constructor of the Region business object, the set routines for each of its properties, its Save method, its private InsertNewRecord method, the Insert command method of the RegionHelper class, and the Insert stored procedure in the database.
The Region business object test class is under construction. The class variables have been declared and the constructor should have been modified to read in the data file.
1. Declare a private void function called CreateTheObject.
This test can get more complex when the business object gets more complex, but it solves the problem of making exercising critical functionality, and it provides us with an object that we can use in additional tests.
This is a very simple test. All it does is exercise the code. This test doesn’t verify that any code ran correctly, but it does verify that it ran. It also will create a record that will be verified in the Read test.
As simple as it is, note that it does test a lot of code. If you don’t notice how much is being tested when we wrote this test, you are almost certain to notice it when you run this test. The first test is rarely pretty.
All of your tests will be slightly different if you are talking about a business object that uses a key that is generated. Any table based on an identity key (auto-number) will need a test that returns the ID of the new object. The other tests will require this value to test the object created here. Think about that structural difference as we construct the remainder of this set of tests.
Previous Step: Create the Business Object Test Class
Next Step: Build the Object Read Test