Build the Object Delete Test

Purpose:

This method will test the constructor of the Region business object that requires a RegionID, the Select and Delete command methods of the RegionHelper class, and the Select and Delete stored procedures in the database.

Starting Point:

The Region business object test class is under construction.  The UpdateTheObject test should be complete.

Steps:

  1. Declare a private void function called DeleteTheObject.
  2. In the body of your new function, declare a new object of type Region and initialize it using the constructor that requires a RegionID.  Pass the constructor the RegionIDUpdate from the test row.
  3. Delete the new object using the object’s Delete method.
  4. Declare a second object of type Region and initialize it using the constructor that requires a RegionID.  Pass the constructor the RegionIDUpdate value from the test row.
  5. Check to see that the RegionDescription property contains a zero length string.
  6. Save the class.  The finished code should look something like this:

    private void DeleteTheObject()
    {
        Region myRegion = new Region(_testRow.RegionIDUpdate);
        myRegion.Delete();

        Region myRegion2 = new Region(_testRow.RegionIDUpdate);
        Assert.AreEqual("", myRegion2.RegionDescription, "This is the wrong description.");
    }

  7.  Compile and Save.

Rationale

This is just the best test we have thought of at the moment.  It begs for improvement.

Discussion:

This does not really verify that the object has been successfully deleted.  The test would pass if the object really had a zero length string in the RegionDescription field.  There are better tests but they are all a little more work and a little more complex.  This will do for now.  At least, we are sure that this exercises all of the remaining code in non-static part of the business object. 

When we have run this test, we can have a reasonable feeling of assurance that a user can declare an object of our business object class and use all of its operations without breaking the object casually.  There are still many ways to break the object, of course, but now we now that using the object as we planned is at least possible.

Previous Step: Build the Object Update Test

Next Step: Build the Test Case Runner