Skip to main content

This documentation is for an older version of this product. See the latest version of this content.Opens in a new tab

Exercises

Exercise 1: MyPackage.TestMe contains a method named CreateContact. This method creates and returns a Contact instance. It accepts Name and ContactType values as arguments. Create a unit test that tests the following:

  • The Contact instance returned from CreateContact has the correct Name value.

  • The Contact instance returned from CreateContact has the correct ContactType value.

  • The Contact instance returned from CreateContact saves correctly, that is, %Save returns an OK status.

Exercise 2: MyPackage.Contact contains a class query named ByContactType. It returns the ID values for all Contact instances with specified value for ContactType. Add a unit test to MyPackages.Tests that tests the following:

  • The query returns the correct number of ID values for the specified ContactType. To do this, the database must be initialized correctly.

  • Each ID value returned by the query corresponds to a Contact with the specified ContactType value.

Note that the addition of this test should not break the tests that you added to MyPackage.Tests while completing the examples in the body of the tutorial. So, you must initialize and restore the database in the correct manner.

FeedbackOpens in a new tab