Test Driven Development Tools

The Test Driven Development tools make use of the UnitTestFramework.dll and allows developers to create a known data state for the purposes of testing and then revert the data state to a baseline state.


The following code defines the data for a "User" business entity that can be used for testing:

protected override void PopulateEntityBasicStateExpected() { this.EntityBasicState.Add("UserName", "jjones"); this.EntityBasicState.Add("Prefix", "Dr."); this.EntityBasicState.Add("Password", "1234"); this.EntityBasicState.Add("FirstName", "Joe"); this.EntityBasicState.Add("MiddleName", "Sidmond"); this.EntityBasicState.Add("LastName", "Jones"); this.EntityBasicState.Add("Suffix", "III"); this.EntityBasicState.Add("Title", "Professor"); this.EntityBasicState.Add("BirthDate", new DateTime(1970, 11, 25)); this.EntityBasicState.Add("Company", "Neverland Elementary School"); this.EntityBasicState.Add("Photo", new Bitmap(1, 1)); }


The following code runs a unit test on a "User" business entity by testing the adding of contact information. It cleans up after itself by removing any data added during the test:

/// <summary> /// Test adding communication info to a user. /// </summary> [Test] public void TestUserWithCommunicationInfo() { Collection<UserBusinessEntity> testEntities = BusinessObjectFixture<UserBusinessEntity>.GetNewTestEntities<UserFixture>(1); UserBusinessEntity userBE = testEntities[0]; try { INameCommInfoEntity email = userBE.CommunicationInfo.Add(CommInfoType.Email, "claudio@eps-software.com"); Assert.IsNotNull(email, "Failed adding a new item to the CommunicationInfo collection."); IEntitySubItemCollectionItem item = email as IEntitySubItemCollectionItem; Assert.IsNotNull(item, "Failed casting INameCommInfoEntity to IEntitySubItemCollectionItem"); Assert.AreNotEqual(Guid.Empty, item.PK); Assert.IsTrue(userBE.Save(), "Failed saving user entity after adding contact info."); } finally { BusinessObjectFixture<UserBusinessEntity>.DeleteTestEntities<UserFixture>(); } }


Last Updated: 7/17/2006