<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Microsoft Dynamics Mobile Team blog : development</title><link>http://blogs.msdn.com/dynamicsmobile/archive/tags/development/default.aspx</link><description>Tags: development</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>How to enable barcode scanning on existing Microsoft Dynamics Mobile tasklets</title><link>http://blogs.msdn.com/dynamicsmobile/archive/2009/04/06/how-to-enable-barcode-scanning-on-existing-microsoft-dynamics-mobile-tasklets.aspx</link><pubDate>Tue, 07 Apr 2009 00:07:40 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9534456</guid><dc:creator>Jan Zeman</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/dynamicsmobile/comments/9534456.aspx</comments><wfw:commentRss>http://blogs.msdn.com/dynamicsmobile/commentrss.aspx?PostID=9534456</wfw:commentRss><description>&lt;p&gt;This is an installment of &lt;a href="http://blogs.msdn.com/dynamicsmobile/archive/2009/01/21/barcode-scanning-with-microsoft-dynamics-mobile.aspx"&gt;Barcode Scanning With Microsoft Dynamics Mobile&lt;/a&gt; series.&lt;/p&gt;  &lt;p&gt;… and concurrently it is the shortest blog article I have ever written :-)&lt;/p&gt;  &lt;p&gt;Just follow the MSDN link: &lt;a href="http://msdn.microsoft.com/en-us/library/cc563948.aspx"&gt;How to: Set Up Barcode Scanning for Mobile Sales&lt;/a&gt;. Use this approach for SimpleList or similarly for ItemList tasklet.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9534456" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/dynamicsmobile/archive/tags/Dynamics+Mobile+2008/default.aspx">Dynamics Mobile 2008</category><category domain="http://blogs.msdn.com/dynamicsmobile/archive/tags/development/default.aspx">development</category><category domain="http://blogs.msdn.com/dynamicsmobile/archive/tags/Windows+Mobile/default.aspx">Windows Mobile</category><category domain="http://blogs.msdn.com/dynamicsmobile/archive/tags/Scanning/default.aspx">Scanning</category><category domain="http://blogs.msdn.com/dynamicsmobile/archive/tags/Barcode/default.aspx">Barcode</category></item><item><title>Where To Get Barcode Drivers</title><link>http://blogs.msdn.com/dynamicsmobile/archive/2009/01/21/where-to-get-barcode-drivers.aspx</link><pubDate>Wed, 21 Jan 2009 21:46:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9357444</guid><dc:creator>Jan Zeman</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/dynamicsmobile/comments/9357444.aspx</comments><wfw:commentRss>http://blogs.msdn.com/dynamicsmobile/commentrss.aspx?PostID=9357444</wfw:commentRss><description>&lt;P&gt;This is an installment of &lt;A href="http://blogs.msdn.com/dynamicsmobile/archive/2009/01/21/barcode-scanning-with-microsoft-dynamics-mobile.aspx" mce_href="http://blogs.msdn.com/dynamicsmobile/archive/2009/01/21/barcode-scanning-with-microsoft-dynamics-mobile.aspx"&gt;Barcode Scanning With Microsoft Dynamics Mobile&lt;/A&gt; series.&lt;/P&gt;
&lt;P&gt;Barcode drivers are the most essential prerequisites for barcode scanning functionality on a particular device. Out of the box, Microsoft Dynamics Mobile supports two barcode enabled device manufacturers:&amp;nbsp; &lt;STRONG&gt;&lt;A href="http://business.motorola.com/us/enterprisemobility/index.html" mce_href="http://business.motorola.com/us/enterprisemobility/index.html"&gt;Motorola&lt;/A&gt;&lt;/STRONG&gt; (formerly Symbol) and &lt;STRONG&gt;&lt;A href="http://www.intermec.com/" mce_href="http://www.intermec.com/"&gt;Intermec&lt;/A&gt;&lt;/STRONG&gt;. To achieve any barcode related functionality you need to acquire appropriate barcode drivers. These are usually wrapped in some .NET Compact Framework assembly which is shipped as a part of a particular SDK of the given manufacturer. Third parties (in this case Microsoft) are not allowed to redistribute manufacturers’ drivers so you have to get them by your own. To make your life easier I prepared the following mini-tutorials describing where to download appropriate SDK and how to extract barcode driver out of them.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Please notice!&lt;/STRONG&gt; The description below is very precise and all links are currently working (January 2009). However it can change as time goes by. Feel free to add your comment to the blog article, we will update the description.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Motorola&lt;/STRONG&gt; (formerly Symbol): You need two assemblies called &lt;STRONG&gt;Symbol&lt;/STRONG&gt; and &lt;STRONG&gt;Symbol.Barcode&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Go to &lt;A href="https://docs.symbol.com/KanisaPlatform/Publishing/903/11777_f.html" mce_href="https://docs.symbol.com/KanisaPlatform/Publishing/903/11777_f.html"&gt;Motorola EMDK for .NET v2.0&lt;/A&gt; (EMDK stands for Enterprise Mobility Developer Kit formerly known as SMDK - Symbol Mobility Developer Kit) and download &lt;A href="https://docs.symbol.com/downloads/EMDK-M-020005-Up2.zip" mce_href="https://docs.symbol.com/downloads/EMDK-M-020005-Up2.zip"&gt;EMDK-M-020005-Up2.zip&lt;/A&gt;. &lt;/LI&gt;
&lt;LI&gt;Unzip and locate the following CAB file: symbol.all.arm.cab (typically in .\SDK\Smart Devices\wce500\armv4i folder). &lt;/LI&gt;
&lt;LI&gt;Install the CAB file on any Windows Mobile device or emulator, and locate Symbol.dll and Symbol.Barcode.dll on that device under \Windows &lt;/LI&gt;
&lt;LI&gt;Copy Symbol.dll and Symbol.Barcode.dll to your PC for future use. &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;STRONG&gt;Intermec&lt;/STRONG&gt;: You need one assembly called &lt;STRONG&gt;Intermec.DataCollection.CF2&lt;/STRONG&gt; a&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Notice that you must be a registered user to be able to perform any download from the Intermec web site. If you are not, go to the Intermec &lt;A href="http://webapps.intermec.com/EFulfillment/LoginForm.aspx" mce_href="http://webapps.intermec.com/EFulfillment/LoginForm.aspx"&gt;downloads login page&lt;/A&gt;, click on the “create a new account” link, provide all required information and click on the “Register” button. &lt;/LI&gt;
&lt;LI&gt;Having your Intermec account you can download the &lt;A href="http://webapps.intermec.com/EFulfillment/SoftwareListForm.aspx?SoftwareID=2344" mce_href="http://webapps.intermec.com/EFulfillment/SoftwareListForm.aspx?SoftwareID=2344"&gt;Intermec Development Toolkit&lt;/A&gt;. You must enter your Intermec account credentials and go through a short wizard to reach the download link. &lt;/LI&gt;
&lt;LI&gt;Install the toolkit (00002344_IDLDCRK_Setup.exe). &lt;/LI&gt;
&lt;LI&gt;Locate Intermec.DataCollection.CF2.dll assembly under the following path: %PROGRAMFILES%\Intermec\Developer Library\Dot NET Assemblies\CF 2.0 &lt;/LI&gt;
&lt;LI&gt;Copy Intermec.DataCollection.CF2.dll to your PC for future use. &lt;/LI&gt;&lt;/UL&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9357444" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/dynamicsmobile/archive/tags/Dynamics+Mobile+2008/default.aspx">Dynamics Mobile 2008</category><category domain="http://blogs.msdn.com/dynamicsmobile/archive/tags/development/default.aspx">development</category><category domain="http://blogs.msdn.com/dynamicsmobile/archive/tags/Windows+Mobile/default.aspx">Windows Mobile</category><category domain="http://blogs.msdn.com/dynamicsmobile/archive/tags/Scanning/default.aspx">Scanning</category><category domain="http://blogs.msdn.com/dynamicsmobile/archive/tags/Barcode/default.aspx">Barcode</category></item><item><title>Barcode Scanning With Microsoft Dynamics Mobile</title><link>http://blogs.msdn.com/dynamicsmobile/archive/2009/01/21/barcode-scanning-with-microsoft-dynamics-mobile.aspx</link><pubDate>Wed, 21 Jan 2009 21:40:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9357393</guid><dc:creator>Jan Zeman</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/dynamicsmobile/comments/9357393.aspx</comments><wfw:commentRss>http://blogs.msdn.com/dynamicsmobile/commentrss.aspx?PostID=9357393</wfw:commentRss><description>&lt;P&gt;My plan is to post a short series of articles related to barcode scanning experience with Microsoft Dynamics Mobile. Today’s post should act as an overview of posted and will-be-posted articles touching the barcode functionality. &lt;BR&gt;&lt;/P&gt;
&lt;P&gt;Here is the plan:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Barcode scanning prerequisites: &lt;A href="http://blogs.msdn.com/dynamicsmobile/archive/2009/01/21/where-to-get-barcode-drivers.aspx" mce_href="http://blogs.msdn.com/dynamicsmobile/archive/2009/01/21/where-to-get-barcode-drivers.aspx"&gt;Where to get barcode drivers&lt;/A&gt; &lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://blogs.msdn.com/dynamicsmobile/archive/2009/04/06/how-to-enable-barcode-scanning-on-existing-microsoft-dynamics-mobile-tasklets.aspx" mce_href="http://blogs.msdn.com/dynamicsmobile/archive/2009/04/06/how-to-enable-barcode-scanning-on-existing-microsoft-dynamics-mobile-tasklets.aspx"&gt;How to enable barcode scanning on existing Microsoft Dynamics Mobile tasklets&lt;/A&gt; &lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://blogs.msdn.com/dynamicsmobile/archive/2009/04/07/how-to-code-your-own-barcode-enabled-tasklets-motorola-and-intermec-devices.aspx" mce_href="http://blogs.msdn.com/dynamicsmobile/archive/2009/04/07/how-to-code-your-own-barcode-enabled-tasklets-motorola-and-intermec-devices.aspx"&gt;How to code your own barcode enabled tasklets (Motorola and Intermec devices)&lt;/A&gt; &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Bullets above will be transformed to http links after the corresponding article has been issued.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9357393" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/dynamicsmobile/archive/tags/Dynamics+Mobile+2008/default.aspx">Dynamics Mobile 2008</category><category domain="http://blogs.msdn.com/dynamicsmobile/archive/tags/development/default.aspx">development</category><category domain="http://blogs.msdn.com/dynamicsmobile/archive/tags/Windows+Mobile/default.aspx">Windows Mobile</category><category domain="http://blogs.msdn.com/dynamicsmobile/archive/tags/Scanning/default.aspx">Scanning</category><category domain="http://blogs.msdn.com/dynamicsmobile/archive/tags/Barcode/default.aspx">Barcode</category></item><item><title>Unit Testing DocumentHandlers With Parameters</title><link>http://blogs.msdn.com/dynamicsmobile/archive/2009/01/13/unit-testing-documenthandlers-with-parameters.aspx</link><pubDate>Tue, 13 Jan 2009 09:20:38 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9313188</guid><dc:creator>ploeh</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/dynamicsmobile/comments/9313188.aspx</comments><wfw:commentRss>http://blogs.msdn.com/dynamicsmobile/commentrss.aspx?PostID=9313188</wfw:commentRss><description>&lt;p&gt;In my &lt;a href="http://blogs.msdn.com/dynamicsmobile/archive/2009/01/07/unit-testing-documenthandlers.aspx"&gt;previous post&lt;/a&gt;, I described how to unit test custom DocumentHandlers. When your DocumentHandler has one or more &lt;a href="http://blogs.msdn.com/dynamicsmobile/archive/2008/12/18/documenthandlerparameter-best-practices.aspx"&gt;DocumentHandlerParameters&lt;/a&gt;, you have to manually assign values to these, since, during unit testing, the DocumentHandler instance runs outside the warm and fuzzy Mobile Server environment.&lt;/p&gt;  &lt;p&gt;This is as simple as setting the property to the desired value before invoking the Submit or GetDocumentDescription methods.&lt;/p&gt; &lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;\red43\green145\blue175;\red0\green0\blue255;\red0\green128\blue0;}??\fs20 [\cf3 TestMethod\cf0 ]\par ??\cf4 public\cf0  \cf4 void\cf0  TestUsingMyIntegerParameter()\par ??\{\par ??    \cf5 // Fixture setup\par ??\cf0     \cf4 string\cf0  anonymousNumber = 7.ToString();\par ??    \cf3 MyDocumentHandler\cf0  sut = \cf4 new\cf0  \cf3 MyDocumentHandler\cf0 ();\par ??    sut.MyInteger = anonymousNumber;\par ??    \cf5 // Exercise system\par ??\cf0     \cf5 // ...\par ??\cf0     \cf5 // Verify outcome\par ??\cf0     \cf5 // ...\par ??\cf0     \cf5 // Teardown\par ??\cf0 \}}
--&gt;  &lt;div style="font-size: 10pt; background: white; color: black; font-family: courier new"&gt;   &lt;pre style="margin: 0px"&gt;[&lt;span style="color: #2b91af"&gt;TestMethod&lt;/span&gt;]&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;void&lt;/span&gt; TestUsingMyIntegerParameter()&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;{&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: green"&gt;// Fixture setup&lt;/span&gt;&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;string&lt;/span&gt; anonymousNumber = 7.ToString();&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #2b91af"&gt;MyDocumentHandler&lt;/span&gt; sut = &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;MyDocumentHandler&lt;/span&gt;();&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; sut.MyInteger = anonymousNumber;&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: green"&gt;// Exercise system&lt;/span&gt;&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: green"&gt;// ...&lt;/span&gt;&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: green"&gt;// Verify outcome&lt;/span&gt;&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: green"&gt;// ...&lt;/span&gt;&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: green"&gt;// Teardown&lt;/span&gt;&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;}&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Notice how, in the above test, the MyInteger property is assigned to an &lt;a href="http://blogs.msdn.com/ploeh/archive/2008/11/17/anonymous-variables.aspx"&gt;Anonymous Variable&lt;/a&gt; before the &lt;a href="http://xunitpatterns.com/SUT.html"&gt;SUT&lt;/a&gt; is exercised.&lt;/p&gt;

&lt;p&gt;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 &lt;a href="http://xunitpatterns.com/fixture%20setup.html"&gt;setting up your Fixture&lt;/a&gt;.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9313188" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/dynamicsmobile/archive/tags/development/default.aspx">development</category><category domain="http://blogs.msdn.com/dynamicsmobile/archive/tags/Mobile+Server/default.aspx">Mobile Server</category></item><item><title>Unit Testing DocumentHandlers</title><link>http://blogs.msdn.com/dynamicsmobile/archive/2009/01/07/unit-testing-documenthandlers.aspx</link><pubDate>Wed, 07 Jan 2009 12:06:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9287060</guid><dc:creator>ploeh</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/dynamicsmobile/comments/9287060.aspx</comments><wfw:commentRss>http://blogs.msdn.com/dynamicsmobile/commentrss.aspx?PostID=9287060</wfw:commentRss><description>&lt;P&gt;As I promised in a &lt;A href="http://blogs.msdn.com/dynamicsmobile/archive/2008/12/11/documenthandler-behind-the-scenes.aspx" mce_href="http://blogs.msdn.com/dynamicsmobile/archive/2008/12/11/documenthandler-behind-the-scenes.aspx"&gt;previous post&lt;/A&gt;, I'd like to discuss how to unit test a custom DocumentHandler. There's really nothing to it: Just create a new instance of your DocumentHandler and start invoking its members.&lt;/P&gt;
&lt;P&gt;Here's a test of the Submit method:&lt;/P&gt;&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;\red43\green145\blue175;\red0\green0\blue255;\red0\green128\blue0;\red163\green21\blue21;}??\fs20 [\cf3 TestMethod\cf0 ]\par ??\cf4 public\cf0  \cf4 void\cf0  SubmitWillReturnCorrectDescription()\par ??\{\par ??    \cf5 // Fixture setup\par ??\cf0     \cf4 string\cf0  anonymousXml = \cf6 "&amp;lt;anonymous&amp;gt;XML&amp;lt;/anonymous&amp;gt;"\cf0 ;\par ??    \cf3 Guid\cf0  anonymousMessageId = \cf3 Guid\cf0 .NewGuid();\par ??    \cf4 string\cf0  anonymousDeviceId = \cf6 "Anonymous device ID"\cf0 ;\par ??    \cf3 IPrincipal\cf0  anonymousPrincipal =\par ??        \cf4 new\cf0  \cf3 GenericPrincipal\cf0 (\par ??            \cf4 new\cf0  \cf3 GenericIdentity\cf0 (\cf6 "Someone"\cf0 ), \cf4 new\cf0  \cf4 string\cf0 [0]);\par ??\par ??    \cf4 string\cf0  expectedDescription =\par ??        \cf4 string\cf0 .Format(\cf6 "Message \{0\} was successfully submitted"\cf0 ,\par ??        anonymousMessageId);\par ??\par ??    \cf3 MyDocumentHandler\cf0  sut = \cf4 new\cf0  \cf3 MyDocumentHandler\cf0 ();\par ??    \cf5 // Exercise system\par ??\cf0     \cf3 DocumentResponse\cf0  result =\par ??        sut.Submit(anonymousXml, anonymousMessageId,\par ??        anonymousDeviceId, anonymousPrincipal);\par ??    \cf5 // Verify outcome\par ??\cf0     \cf3 Assert\cf0 .AreEqual&amp;lt;\cf4 string\cf0 &amp;gt;(expectedDescription,\par ??        result.Description, \cf6 "Description"\cf0 );\par ??    \cf5 // Teardown\par ??\cf0 \}}
--&gt;
&lt;DIV style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: courier new"&gt;&lt;PRE style="MARGIN: 0px"&gt;[&lt;SPAN style="COLOR: #2b91af"&gt;TestMethod&lt;/SPAN&gt;]&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; SubmitWillReturnCorrectDescription()&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;{&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: green"&gt;// Fixture setup&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; anonymousXml = &lt;SPAN style="COLOR: #a31515"&gt;"&amp;lt;anonymous&amp;gt;XML&amp;lt;/anonymous&amp;gt;"&lt;/SPAN&gt;;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: #2b91af"&gt;Guid&lt;/SPAN&gt; anonymousMessageId = &lt;SPAN style="COLOR: #2b91af"&gt;Guid&lt;/SPAN&gt;.NewGuid();&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; anonymousDeviceId = &lt;SPAN style="COLOR: #a31515"&gt;"Anonymous device ID"&lt;/SPAN&gt;;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: #2b91af"&gt;IPrincipal&lt;/SPAN&gt; anonymousPrincipal =&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;GenericPrincipal&lt;/SPAN&gt;(&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;GenericIdentity&lt;/SPAN&gt;(&lt;SPAN style="COLOR: #a31515"&gt;"Someone"&lt;/SPAN&gt;), &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt;[0]);&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; expectedDescription =&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt;.Format(&lt;SPAN style="COLOR: #a31515"&gt;"Message {0} was successfully submitted"&lt;/SPAN&gt;,&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; anonymousMessageId);&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: #2b91af"&gt;MyDocumentHandler&lt;/SPAN&gt; sut = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;MyDocumentHandler&lt;/SPAN&gt;();&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: green"&gt;// Exercise system&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: #2b91af"&gt;DocumentResponse&lt;/SPAN&gt; result =&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sut.Submit(anonymousXml, anonymousMessageId,&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; anonymousDeviceId, anonymousPrincipal);&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: green"&gt;// Verify outcome&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: #2b91af"&gt;Assert&lt;/SPAN&gt;.AreEqual&amp;lt;&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt;&amp;gt;(expectedDescription,&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; result.Description, &lt;SPAN style="COLOR: #a31515"&gt;"Description"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: green"&gt;// Teardown&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;}&lt;/PRE&gt;&lt;/DIV&gt;
&lt;P&gt;Since the Submit method takes four parameters, you must create these four objects prior to invoking the method. In this example, I'm naming the variables using the &lt;A href="http://blogs.msdn.com/ploeh/archive/2008/11/17/anonymous-variables.aspx" mce_href="http://blogs.msdn.com/ploeh/archive/2008/11/17/anonymous-variables.aspx"&gt;Anonymous Variable Naming&lt;/A&gt; coding idiom.&lt;/P&gt;
&lt;P&gt;In many cases, the XML string containing the document to submit is probably the most interesting parameter, and you will likely need to write many separate tests to verify that your custom DocumentHandler correctly deals with different instances of your particular XML document format.&lt;/P&gt;
&lt;P&gt;In this context, it's worth noting that you can obviously debug into your code when running a test, so this is a very effective troubleshooting technique. Due to the way we load and host DocumentHandlers, it's not possible to attach a debugger to a custom DocumentHandler while it's executing in Mobile Server, so debugging into a unit test is a good alternative. If your custom DocumentHandler throws an exception while executing in Mobile Server, the event log will contain a copy of the message, and you can then use this copy to reproduce the problem in a unit test.&lt;/P&gt;
&lt;P&gt;In the test shown above, notice that I create a new &lt;A href="http://msdn.microsoft.com/en-us/library/system.security.principal.genericprincipal.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.security.principal.genericprincipal.aspx"&gt;GenericPrincipal&lt;/A&gt; instance to use as the &lt;EM&gt;mobileUser&lt;/EM&gt; parameter. Be aware that &lt;EM&gt;any&lt;/EM&gt; &lt;A href="http://msdn.microsoft.com/en-us/library/system.security.principal.iprincipal.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.security.principal.iprincipal.aspx"&gt;IPrincipal&lt;/A&gt; instance is acceptable, so I just created a GenericPrincipal because it was the easiest thing to do. When executing your custom DocumentHandler, Mobile Server doesn't use GenericPrincipal, but rather a different implementation of IPrincipal, and it makes no guarantees that it will always use the same implementation type. In other words, your custom DocumentHandler should follow the Liskov Substitution Principle.&lt;/P&gt;
&lt;P&gt;As you can see, it's really straightforward to unit test custom DocumentHandlers. The Submit method has by far the most complex signature, so testing the FriendlyName and GetDocumentDescription members is even simpler.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Update:&lt;/STRONG&gt; A &lt;A class="" href="http://blogs.msdn.com/dynamicsmobile/archive/2009/01/13/unit-testing-documenthandlers-with-parameters.aspx" mce_href="http://blogs.msdn.com/dynamicsmobile/archive/2009/01/13/unit-testing-documenthandlers-with-parameters.aspx"&gt;follow-up post dealing with unit testing and DocumentHandlerParameters&lt;/A&gt; is now available.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9287060" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/dynamicsmobile/archive/tags/development/default.aspx">development</category><category domain="http://blogs.msdn.com/dynamicsmobile/archive/tags/Mobile+Server/default.aspx">Mobile Server</category></item><item><title>DocumentHandlerParameter Best Practices</title><link>http://blogs.msdn.com/dynamicsmobile/archive/2008/12/18/documenthandlerparameter-best-practices.aspx</link><pubDate>Thu, 18 Dec 2008 16:47:12 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9236207</guid><dc:creator>ploeh</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/dynamicsmobile/comments/9236207.aspx</comments><wfw:commentRss>http://blogs.msdn.com/dynamicsmobile/commentrss.aspx?PostID=9236207</wfw:commentRss><description>&lt;p&gt;When you create a custom &lt;a href="http://blogs.msdn.com/dynamicsmobile/archive/2008/12/11/documenthandler-behind-the-scenes.aspx"&gt;DocumentHandler&lt;/a&gt;, it is very likely that you may need to supply it with some configuration data. Common examples include the address of your back-end server, credentials to the back-end system, etc.&lt;/p&gt;  &lt;p&gt;DocumentHandlers can be configured by adding public read/write string properties and decorating them with the DocumentHandlerParameter attribute. This is all described in the documentation, but in this post, I'd like to expand a bit on the subject to describe some best practices for dealing with such parameters.&lt;/p&gt;  &lt;p&gt;If all you need is a string, you can get by with an implementation as simple as this:&lt;/p&gt; &lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;\red43\green145\blue175;\red163\green21\blue21;\red0\green0\blue255;}??\fs20 [\cf3 DocumentHandlerParameter\cf0 (\cf4 "Descrption template"\cf0 )]\par ??\cf5 public\cf0  \cf5 string\cf0  DescriptionTemplate \{ \cf5 get\cf0 ; \cf5 set\cf0 ; \}}
--&gt;  &lt;div style="font-size: 10pt; background: white; color: black; font-family: courier new"&gt;   &lt;pre style="margin: 0px"&gt;[&lt;span style="color: #2b91af"&gt;DocumentHandlerParameter&lt;/span&gt;(&lt;span style="color: #a31515"&gt;&amp;quot;Description template&amp;quot;&lt;/span&gt;)]&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;string&lt;/span&gt; DescriptionTemplate { &lt;span style="color: blue"&gt;get&lt;/span&gt;; &lt;span style="color: blue"&gt;set&lt;/span&gt;; }&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;However, if you really need something else, you will have to parse the text yourself, since only strings are supported. Imagine that you really need to expose an integer property. Basically, you have two options:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;You can parse it as the value is being assigned &lt;/li&gt;

  &lt;li&gt;You can parse it when you need it &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Parsing the value right away is the preferable alternative, since this gives Mobile Server a chance to verify the configuration as soon as the operator saves the document type (right now, Mobile Server doesn't do that, but it &lt;em&gt;might&lt;/em&gt; do that in a future version, in which case you'll get validation for free). It also makes for cleaner code.&lt;/p&gt;

&lt;p&gt;Here's one possible implementation of an integer property:&lt;/p&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;\red43\green145\blue175;\red163\green21\blue21;\red0\green0\blue255;}??\fs20 [\cf3 DocumentHandlerParameter\cf0 (\cf4 "My integer"\cf0 )]\par ??\cf5 public\cf0  \cf5 string\cf0  MyInteger\par ??\{\par ??    \cf5 get\cf0  \{ \cf5 return\cf0  \cf5 this\cf0 .myInt.ToString(); \}\par ??    \cf5 set\cf0  \par ??    \{\par ??        \cf5 int\cf0  i;\par ??        \cf5 if\cf0  (\cf5 int\cf0 .TryParse(\cf5 value\cf0 , \cf5 out\cf0  i))\par ??        \{\par ??            \cf5 this\cf0 .myInt = i;\par ??            \cf5 return\cf0 ;\par ??        \}\par ??        \cf5 throw\cf0  \cf5 new\cf0  \cf3 ArgumentException\cf0 (\par ??            \cf4 "Value was not an integer"\cf0 , \cf4 "value"\cf0 );\par ??    \}\par ??\}}
--&gt;

&lt;div style="font-size: 10pt; background: white; color: black; font-family: courier new"&gt;
  &lt;pre style="margin: 0px"&gt;[&lt;span style="color: #2b91af"&gt;DocumentHandlerParameter&lt;/span&gt;(&lt;span style="color: #a31515"&gt;&amp;quot;My integer&amp;quot;&lt;/span&gt;)]&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;string&lt;/span&gt; MyInteger&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;{&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;get&lt;/span&gt; { &lt;span style="color: blue"&gt;return&lt;/span&gt; &lt;span style="color: blue"&gt;this&lt;/span&gt;.myInt.ToString(); }&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;set&lt;/span&gt; &lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; {&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;int&lt;/span&gt; i;&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;if&lt;/span&gt; (&lt;span style="color: blue"&gt;int&lt;/span&gt;.TryParse(&lt;span style="color: blue"&gt;value&lt;/span&gt;, &lt;span style="color: blue"&gt;out&lt;/span&gt; i))&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;this&lt;/span&gt;.myInt = i;&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;return&lt;/span&gt;;&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;throw&lt;/span&gt; &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;ArgumentException&lt;/span&gt;(&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #a31515"&gt;&amp;quot;Value was not an integer&amp;quot;&lt;/span&gt;, &lt;span style="color: #a31515"&gt;&amp;quot;value&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; }&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;}&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;where &lt;em&gt;myInt&lt;/em&gt; is a private member variable. Notice how the setter attempts to parse the string to an integer, and throws a descriptive exception if this is not possible.&lt;/p&gt;

&lt;p&gt;Whenever the value of this property is required, the rest of the code can simply reference this.myInt, which is now guaranteed to be correct. Int32 is a value type, so referencing this.myInt will always be correct, since the default is &lt;em&gt;0&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;This is not the case for reference type properties like the DescriptionTemplate property above. Keep in mind that reference types may be null, so that it becomes necessary to check for this before using the property:&lt;/p&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue255;\red255\green255\blue255;\red0\green0\blue0;\red43\green145\blue175;\red163\green21\blue21;}??\fs20 \cf1 public\cf0  \cf1 override\cf0  \cf4 DocumentResponse\cf0  Submit(\cf1 string\cf0  xmlDocument,\par ??    \cf4 Guid\cf0  messageId, \cf1 string\cf0  deviceId, \cf4 IPrincipal\cf0  mobileUser)\par ??\{\par ??    \cf1 string\cf0  template = \par ??        \cf1 string\cf0 .IsNullOrEmpty(\cf1 this\cf0 .DescriptionTemplate) ?\par ??        \cf5 "Message \{0\} was successfully submitted"\cf0  :\par ??        \cf1 this\cf0 .DescriptionTemplate;\par ??\par ??    \cf4 DocumentResponse\cf0  dr = \cf1 new\cf0  \cf4 DocumentResponse\cf0 ();\par ??    dr.Description = \cf1 string\cf0 .Format(template, messageId);\par ??    \cf1 return\cf0  dr;\par ??\}}
--&gt;

&lt;div style="font-size: 10pt; background: white; color: black; font-family: courier new"&gt;
  &lt;pre style="margin: 0px"&gt;&lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;override&lt;/span&gt; &lt;span style="color: #2b91af"&gt;DocumentResponse&lt;/span&gt; Submit(&lt;span style="color: blue"&gt;string&lt;/span&gt; xmlDocument,&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #2b91af"&gt;Guid&lt;/span&gt; messageId, &lt;span style="color: blue"&gt;string&lt;/span&gt; deviceId, &lt;span style="color: #2b91af"&gt;IPrincipal&lt;/span&gt; mobileUser)&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;{&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;string&lt;/span&gt; template = &lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;string&lt;/span&gt;.IsNullOrEmpty(&lt;span style="color: blue"&gt;this&lt;/span&gt;.DescriptionTemplate) ?&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #a31515"&gt;&amp;quot;Message {0} was successfully submitted&amp;quot;&lt;/span&gt; :&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;this&lt;/span&gt;.DescriptionTemplate;&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #2b91af"&gt;DocumentResponse&lt;/span&gt; dr = &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;DocumentResponse&lt;/span&gt;();&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; dr.Description = &lt;span style="color: blue"&gt;string&lt;/span&gt;.Format(template, messageId);&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;return&lt;/span&gt; dr;&lt;/pre&gt;

  &lt;pre style="margin: 0px"&gt;}&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;In this implementation of the Submit method, I test the DescriptionTemplate property's value before using it, defaulting to a hard-coded value if it's not defined. It is important to realize that Mobile Server makes no guarantee regarding the values of DocumentHandlerProperties, since it is entirely up to the operator whether he or she cares to fill in the values or not, so either have some good default values or throw an exception with a descriptive error message.&lt;/p&gt;

&lt;p&gt;As the above example illustrates, you can reference DocumentHandlerProperties from within the Submit method. This is the main scenario, but Mobile Server will also fill in the values of these properties when invoking the GetDocumentDescription method.&lt;/p&gt;

&lt;p&gt;As a contrast to the Submit and GetDocumentDescription methods, the FriendlyName property of DocumentHandler is only being used in the UI when the operator selects a DocumentHandler to configure; that is, &lt;em&gt;before the properties are being configured&lt;/em&gt;. For that reason, when the code inside the FriendlyName property executes, the property values will always have their default values.&lt;/p&gt;

&lt;p&gt;In short:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Validate parameter values in their setters and &lt;em&gt;fail fast&lt;/em&gt;. &lt;/li&gt;

  &lt;li&gt;Don't assume values have been set. &lt;/li&gt;

  &lt;li&gt;Consume values from Submit and GetDocumentDescription only. You cannot consume the values from within the FriendlyName property's code. &lt;/li&gt;
&lt;/ul&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9236207" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/dynamicsmobile/archive/tags/development/default.aspx">development</category><category domain="http://blogs.msdn.com/dynamicsmobile/archive/tags/Mobile+Server/default.aspx">Mobile Server</category></item><item><title>DocumentHandler - Behind The Scenes</title><link>http://blogs.msdn.com/dynamicsmobile/archive/2008/12/11/documenthandler-behind-the-scenes.aspx</link><pubDate>Thu, 11 Dec 2008 17:18:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9195855</guid><dc:creator>ploeh</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/dynamicsmobile/comments/9195855.aspx</comments><wfw:commentRss>http://blogs.msdn.com/dynamicsmobile/commentrss.aspx?PostID=9195855</wfw:commentRss><description>&lt;P&gt;Mobile Server gives you the option of developing custom code that integrates to your back-end system. One way you can do this is by implementing one or more .NET classes that derive from the abstract DocumentHandler class. This is already described in the documentation along with the other options for back-end integration, but in this post, I'd like to provide some background information on this API. In future posts, I'll discuss some best practices for developing custom DocumentHandlers.&lt;/P&gt;
&lt;P&gt;Here's the DocumentHandler API to establish the context:&lt;/P&gt;&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue255;\red255\green255\blue255;\red0\green0\blue0;\red43\green145\blue175;}??\fs20 \cf1 public\cf0  \cf1 abstract\cf0  \cf1 class\cf0  \cf4 DocumentHandler\par ??\cf0 \{\par ??    \cf1 protected\cf0  DocumentHandler();\par ??\par ??    \cf1 public\cf0  \cf1 abstract\cf0  \cf1 string\cf0  FriendlyName \{ \cf1 get\cf0 ; \}\par ??\par ??    \cf1 public\cf0  \cf1 abstract\cf0  \cf1 string\cf0  GetDocumentDescription(\par ??        \cf1 string\cf0  xmlDocument);\par ??    \cf1 public\cf0  \cf1 abstract\cf0  \cf4 DocumentResponse\cf0  Submit(\par ??        \cf1 string\cf0  xmlDocument, \cf4 Guid\cf0  messageId,\par ??        \cf1 string\cf0  deviceId, \cf4 IPrincipal\cf0  mobileUser);\par ??\}}
--&gt;
&lt;DIV style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: courier new"&gt;&lt;PRE style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;abstract&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;class&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;DocumentHandler&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;{&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;protected&lt;/SPAN&gt; DocumentHandler();&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;abstract&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; FriendlyName { &lt;SPAN style="COLOR: blue"&gt;get&lt;/SPAN&gt;; }&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;abstract&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; GetDocumentDescription(&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; xmlDocument);&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;abstract&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;DocumentResponse&lt;/SPAN&gt; Submit(&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; xmlDocument, &lt;SPAN style="COLOR: #2b91af"&gt;Guid&lt;/SPAN&gt; messageId,&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; deviceId, &lt;SPAN style="COLOR: #2b91af"&gt;IPrincipal&lt;/SPAN&gt; mobileUser);&lt;/PRE&gt;&lt;PRE style="MARGIN: 0px"&gt;}&lt;/PRE&gt;&lt;/DIV&gt;
&lt;P&gt;When we designed DocumentHandler, we had several design goals in mind:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;It should be as simple as possible to implement a custom DocumentHandler &lt;/LI&gt;
&lt;LI&gt;It should provide as much flexibility as possible &lt;/LI&gt;
&lt;LI&gt;It should be testable &lt;/LI&gt;
&lt;LI&gt;It should adhere to the .NET Framework Design Guideline that states that you should prefer abstract classes over interfaces (consequently, this is why DocumentHandler is not an interface) &lt;/LI&gt;
&lt;LI&gt;It should be CLS compliant &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;While I personally could wish for even more flexibility, I think we succeeded very well on all the other points. In the Dynamics Mobile Team, we use TDD, so it was particularly important to us that the DocumentHandler API is testable - and it is.&lt;/P&gt;
&lt;P&gt;The DocumentHandler constructor is empty, so we don't require you to pass some weird, internal or sealed object as a constructor parameter; on the contrary, in fact we &lt;EM&gt;require&lt;/EM&gt; that your custom DocumentHandler has a default constructor. That makes it super-easy to create a new instance as part of a test:&lt;/P&gt;&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red43\green145\blue175;\red255\green255\blue255;\red0\green0\blue0;\red0\green0\blue255;}??\fs20 \cf1 MyDocumentHandler\cf0  sut = \cf4 new\cf0  \cf1 MyDocumentHandler\cf0 ();}
--&gt;
&lt;DIV style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: courier new"&gt;&lt;PRE style="MARGIN: 0px"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;MyDocumentHandler&lt;/SPAN&gt; sut = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;MyDocumentHandler&lt;/SPAN&gt;();&lt;/PRE&gt;&lt;/DIV&gt;
&lt;P&gt;All the members of DocumentHandler works on well-known BCL types (string, Guid, and IPrincipal) with the single exception of the Submit method, which returns a DocumentResponse instance, which is a type that we have defined in the same library.&lt;/P&gt;
&lt;P&gt;DocumentResponse is a public, non-sealed class with a default constructor, and it works almost exclusively with BCL types such as string, DateTime, bool, etc. Again, there's a single exception in the use of the DocumentResponseStatus enum, but also here we are dealing with a public type that is easily created.&lt;/P&gt;
&lt;P&gt;The bottom line is that the entire DocumentHandler API contains only three custom types, and all of those types are very susceptible to unit testing.&lt;/P&gt;
&lt;P&gt;In a &lt;A class="" href="http://blogs.msdn.com/dynamicsmobile/archive/2009/01/07/unit-testing-documenthandlers.aspx" mce_href="http://blogs.msdn.com/dynamicsmobile/archive/2009/01/07/unit-testing-documenthandlers.aspx"&gt;future post&lt;/A&gt;, I will discuss the matter of unit testing custom DocumentHandlers in greater detail.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9195855" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/dynamicsmobile/archive/tags/development/default.aspx">development</category><category domain="http://blogs.msdn.com/dynamicsmobile/archive/tags/Mobile+Server/default.aspx">Mobile Server</category></item><item><title>Additional place to get help using Microsoft Dynamics Mobile bits</title><link>http://blogs.msdn.com/dynamicsmobile/archive/2008/06/23/additional-place-to-get-help-using-microsoft-dynamics-mobile-bits.aspx</link><pubDate>Mon, 23 Jun 2008 14:40:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8641865</guid><dc:creator>Tim Skauge</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/dynamicsmobile/comments/8641865.aspx</comments><wfw:commentRss>http://blogs.msdn.com/dynamicsmobile/commentrss.aspx?PostID=8641865</wfw:commentRss><description>As a non official role in our team I’m searching the internet for people who needs help using our bits, and has on several occasions helped. I would like to point you to a site where you can get some quality answers without waiting for the team to write...(&lt;a href="http://blogs.msdn.com/dynamicsmobile/archive/2008/06/23/additional-place-to-get-help-using-microsoft-dynamics-mobile-bits.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8641865" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/dynamicsmobile/archive/tags/installation/default.aspx">installation</category><category domain="http://blogs.msdn.com/dynamicsmobile/archive/tags/orchestration/default.aspx">orchestration</category><category domain="http://blogs.msdn.com/dynamicsmobile/archive/tags/development/default.aspx">development</category><category domain="http://blogs.msdn.com/dynamicsmobile/archive/tags/documentation/default.aspx">documentation</category></item><item><title>Using SSIS with Microsoft Dynamics Mobile</title><link>http://blogs.msdn.com/dynamicsmobile/archive/2008/06/14/using-ssis-with-microsoft-dynamics-mobile.aspx</link><pubDate>Sat, 14 Jun 2008 12:54:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8596714</guid><dc:creator>Jan Zeman</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/dynamicsmobile/comments/8596714.aspx</comments><wfw:commentRss>http://blogs.msdn.com/dynamicsmobile/commentrss.aspx?PostID=8596714</wfw:commentRss><description>Let me start with a small announcement I am happy to announce that we have upgraded our SSIS ( SQL Server Integration Services ) solution for Mobile Sales from the 2005 to the 2008 version of Microsoft SQL Server Integration Services. So from now on we...(&lt;a href="http://blogs.msdn.com/dynamicsmobile/archive/2008/06/14/using-ssis-with-microsoft-dynamics-mobile.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8596714" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/dynamicsmobile/archive/tags/Dynamics+Mobile+2008/default.aspx">Dynamics Mobile 2008</category><category domain="http://blogs.msdn.com/dynamicsmobile/archive/tags/architecture/default.aspx">architecture</category><category domain="http://blogs.msdn.com/dynamicsmobile/archive/tags/development/default.aspx">development</category><category domain="http://blogs.msdn.com/dynamicsmobile/archive/tags/SSIS/default.aspx">SSIS</category></item><item><title>How to send a requestdocument from a service</title><link>http://blogs.msdn.com/dynamicsmobile/archive/2008/05/27/how-to-send-a-requestdocument-from-a-service.aspx</link><pubDate>Tue, 27 May 2008 10:00:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8556171</guid><dc:creator>Tim Skauge</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/dynamicsmobile/comments/8556171.aspx</comments><wfw:commentRss>http://blogs.msdn.com/dynamicsmobile/commentrss.aspx?PostID=8556171</wfw:commentRss><description>Yesterday I was sitting with a potential partner here at MDCC (Microsoft Development Center Copenhagen) to get them introduced to Microsoft Dynamics Mobile. All in all I think we had a good and productive day where we covered most of the major topics...(&lt;a href="http://blogs.msdn.com/dynamicsmobile/archive/2008/05/27/how-to-send-a-requestdocument-from-a-service.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8556171" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/dynamicsmobile/archive/tags/Dynamics+Mobile+2008/default.aspx">Dynamics Mobile 2008</category><category domain="http://blogs.msdn.com/dynamicsmobile/archive/tags/development/default.aspx">development</category></item></channel></rss>