Build the Object Update Test

Purpose:

This method will test the constructor of the Region business object that requires a RegionID, the get routines for each of its properties, the Select command method of the RegionHelper class, and the Select stored procedure in the database.

Starting Point:

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

Steps:

  1. Declare a private void function called ReadTheObject.
  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 RegionID from the test row.
  3. Compare the RegionID and RegionDescription properties of the new object to the values in the test row using NUnit’s Assert.AreEqual method.
  4. Save the object.  The finished code should look something like this:

    private void UpdateTheObject()
    {
        Region myRegion = new Region(_testRow.RegionID);
        myRegion.RegionID = _testRow.RegionIDUpdate;
        myRegion.RegionDescription = _testRow.RegionDescriptionUpdate;
        myRegion.Save();

        Region myRegion2 = new Region(_testRow.RegionIDUpdate);
        Assert.AreEqual(_testRow.RegionIDUpdate, myRegion2.RegionID, "You gave me the wrong ID, idiot!!!");
        Assert.AreEqual(_testRow.RegionDescriptionUpdate, myRegion2.RegionDescription, "This is the wrong description.");
    }
     
  5. Compile and Save.

Rationale

This repeats the actions of the Create and Read tests, but it exercises portions of the code not exercised until now.

Discussion:

This is also a very simple test.  All it does is read the properties to see if they contain the values that they should.  It verifies that the object was created correctly, and that it can be retrieved from the database.  It exercises sections of the Region business object that were not exercised when the object was created, and it tests the select command method and stored procedure.

Previous Step: Build the Object Read Test

Next Step: Build the Object Delete Test