Unit Testing DocumentHandlers With Parameters

In my previous post, I described how to unit test custom DocumentHandlers. When your DocumentHandler has one or more DocumentHandlerParameters, you have to manually assign values to these, since, during unit testing, the DocumentHandler instance runs outside the warm and fuzzy Mobile Server environment.

This is as simple as setting the property to the desired value before invoking the Submit or GetDocumentDescription methods.

 [TestMethod]
 public void TestUsingMyIntegerParameter()
 {
     // Fixture setup
     string anonymousNumber = 7.ToString();
     MyDocumentHandler sut = new MyDocumentHandler();
     sut.MyInteger = anonymousNumber;
     // Exercise system
     // ...
     // Verify outcome
     // ...
     // Teardown
 }

Notice how, in the above test, the MyInteger property is assigned to an Anonymous Variable before the SUT is exercised.

It's very simple, so the main purpose of this post was just to remind you that you have to remember setting all relevant properties appropriately as part of setting up your Fixture.