Skip to content

Task1.0 Expectations

costea32 edited this page Feb 4, 2014 · 1 revision

Expected tests for implementation:

As means of testing all this tests should be present:

  • AddUser tests - add user and check count increases, User can be retrieved by Name, Age and is present in the list of users
  • ClearData tests - verify that after clear data is called, there are no users in the list, no users returned by Name or Age, and user count is 0
  • GetByName tests - verify user is returned if exists with exactly this first and last name, and no user is returned in any other case
  • GetByAge tests - verify that correct user is returned in list, and check that all users in list have the correct age.
  • Data validation - verify that system has some data validation: adding a null user, user without first or last name, adding a user with the same first and last names as an existing one.
  1. Check that even if exception is thrown - user is not added and can not be retrieved via any method
  2. Check that count doesn't increase in case user is not added due to validation issues

Expected implementation

  • TestInitialize and TestCleanup should be used for data setup, and clearing data after the test.
  • Assert.AreEqual should not be used on objects.
  • User objects should be compared by fields, with a helper method, that will check all fields - then Assert and write which fields are different than expected
  • Searching in a list should be done via LINQ, by search criteria: first/last name, age
  • Unit tests that expect Exceptions should be made, via ExpectedException attribute or helper method
  • All unit test have meaningful names that clearly tell what exactly they test
  • Assert messages should not provide more than enough information related to assertion.

Links

  • Anatomy of UnitTests here
  • How to LINQ with Lambda here
  • How to assert exceptions here

Clone this wiki locally