<?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>Application design and programming in .NET</title><link>http://blogs.msdn.com/b/atverma/</link><description>Design and code need to be coherent. The intent of having this blog is to share knowledge to achieve right balance between design and code.</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>Unit Test a project having external dependency(WCF Proxy) using Fakes &amp; Visual Studio 11 Beta</title><link>http://blogs.msdn.com/b/atverma/archive/2012/05/03/unit-test-a-project-having-external-dependency-wcf-proxy-using-fakes-amp-visual-studio-11-beta.aspx</link><pubDate>Thu, 03 May 2012 09:05:13 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10300339</guid><dc:creator>Atul.Verma</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/atverma/rsscomments.aspx?WeblogPostID=10300339</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/atverma/commentapi.aspx?WeblogPostID=10300339</wfw:comment><comments>http://blogs.msdn.com/b/atverma/archive/2012/05/03/unit-test-a-project-having-external-dependency-wcf-proxy-using-fakes-amp-visual-studio-11-beta.aspx#comments</comments><description>&lt;p&gt;&lt;font size="3" face="Calibri"&gt;In this post I’ll explain the steps to generate unit tests for a project which calls a WCF service using Fakes. Microsoft Fakes is an isolation framework for creating delegate-based test stubs and shims in .NET Framework applications. The Fakes framework can be used to shim any .NET method, including non-virtual and static methods in sealed types. &lt;/font&gt;&lt;/p&gt;  &lt;font size="3" face="Calibri"&gt;&lt;/font&gt;  &lt;p&gt;&lt;font size="3" face="Calibri"&gt;The Fakes framework helps developers create, maintain, and inject dummy implementations in their unit tests. The Fakes framework generates and maintains stub types and shim types for a system under test.&lt;/font&gt;&lt;/p&gt;  &lt;font size="3" face="Calibri"&gt;&lt;/font&gt;  &lt;p&gt;&lt;font size="3" face="Calibri"&gt;I had previously discussed about &lt;a href="http://blogs.msdn.com/b/atverma/archive/2012/01/18/how-to-use-pex-and-moles-to-generate-unit-tests-for-a-project-having-external-dependency-wcf-proxy-using-visual-studio-2010-sp1.aspx" target="_blank"&gt;creating Unit Tests using Pex, Moles and Visual Studio 2010&lt;/a&gt;. The projects inside the sample solution are&lt;/font&gt;&lt;/p&gt;  &lt;font size="3" face="Calibri"&gt;&lt;/font&gt;  &lt;ol&gt;&lt;font size="3" face="Calibri"&gt;&lt;/font&gt;    &lt;li&gt;&lt;font size="3" face="Calibri"&gt;DemoService: This project is a WCF Service.&lt;/font&gt;&lt;/li&gt;   &lt;font size="3" face="Calibri"&gt;&lt;/font&gt;    &lt;li&gt;&lt;font size="3" face="Calibri"&gt;DemoLibrary: This project is a Class library and service reference to DemoService has been added. Unit tests will be generated for this project.&lt;/font&gt;&lt;/li&gt;   &lt;font size="3" face="Calibri"&gt;&lt;/font&gt;    &lt;li&gt;&lt;font size="3" face="Calibri"&gt;ConsoleApp: This project is a Console application.&lt;/font&gt;&lt;/li&gt;   &lt;font size="3" face="Calibri"&gt;&lt;/font&gt;    &lt;li&gt;&lt;font size="3" face="Calibri"&gt;DemoLibrary.Tests: This is a Test project and contains unit tests for DemoLibrary.&lt;/font&gt;&lt;/li&gt;   &lt;font size="3" face="Calibri"&gt;&lt;/font&gt;&lt;/ol&gt;  &lt;font size="3" face="Calibri"&gt;&lt;/font&gt;  &lt;p&gt;&lt;font size="3" face="Calibri"&gt;The solution structure is displayed below&lt;/font&gt;&lt;/p&gt;  &lt;font size="3" face="Calibri"&gt;&lt;/font&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-37-36-metablogapi/8875.image_5F00_3044B09A.png"&gt;&lt;font color="#333333" size="3" face="Calibri"&gt;&lt;img title="image" style="display: inline;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-37-36-metablogapi/0841.image_5F00_thumb_5F00_4223D518.png" width="310" height="472" /&gt;&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;  &lt;font size="3" face="Calibri"&gt;&lt;/font&gt;  &lt;p&gt;&lt;font size="3" face="Calibri"&gt;DemoLibrary calls DemoService though proxy as displayed in the Layer diagram&lt;/font&gt;&lt;/p&gt;  &lt;font size="3" face="Calibri"&gt;&lt;/font&gt;  &lt;p&gt;&lt;font size="3" face="Calibri"&gt;&lt;img alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-37-36-metablogapi/0118.image_5F00_thumb_5F00_00B3DD1C.png" width="548" height="213" /&gt;&lt;/font&gt;&lt;/p&gt;  &lt;font size="3" face="Calibri"&gt;&lt;/font&gt;  &lt;p&gt;&lt;font size="3" face="Calibri"&gt;I’ll now discuss in brief the code snippets of each project&lt;/font&gt;&lt;/p&gt;  &lt;font size="3" face="Calibri"&gt;&lt;/font&gt;  &lt;p&gt;&lt;font size="3"&gt;&lt;font face="Calibri"&gt;&lt;strong&gt;WCF Service(DemoService):&lt;/strong&gt; This service provides only a single operation&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 200px; background-color: rgb(244, 244, 244);"&gt;   &lt;div id="codeSnippet" style="padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;     &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;[ServiceContract]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;interface&lt;/span&gt; IDemoService&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;    [OperationContract]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; Search(&lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; criteria);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;pre&gt;&amp;#160;&lt;/pre&gt;

&lt;p&gt;&lt;font size="3"&gt;&lt;font face="Calibri"&gt;&lt;strong&gt;WCF Service Client(DemoLibrary):&lt;/strong&gt; It calls the Search method of DemoService through proxy as displayed below&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;

&lt;div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 200px; background-color: rgb(244, 244, 244);"&gt;
  &lt;div id="codeSnippet" style="padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;
    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; GetResults(&lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; s)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;    DemoServiceReference.DemoServiceClient client = &lt;span style="color: rgb(0, 0, 255);"&gt;null&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;try&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;        client = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; DemoServiceReference.DemoServiceClient();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;        client.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;                &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;        client.ChannelFactory.Credentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;        s = client.Search(s);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt; s;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;    }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;finally&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt; (client != &lt;span style="color: rgb(0, 0, 255);"&gt;null&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;        {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;            &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt; (client.State == CommunicationState.Opened)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;            {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;                client.Close();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;            }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;            &lt;span style="color: rgb(0, 0, 255);"&gt;else&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt; (client.State == CommunicationState.Faulted)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;            {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;                client.Abort();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;            }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;        }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;    }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;pre&gt;&amp;#160;&lt;/pre&gt;

&lt;p&gt;&lt;font size="4" face="Calibri"&gt;&lt;strong&gt;Adding Unit Tests for DemoLibrary:&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;
&lt;font size="3" face="Calibri"&gt;&lt;/font&gt;

&lt;p&gt;&lt;font size="3" face="Calibri"&gt;In order to Unit Test WCF Service Client(DemoLibrary) project using Fakes and Visual Studio 11 the steps are&lt;/font&gt;&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;font size="3" face="Calibri"&gt;Add a new Unit Test project as displayed below&lt;/font&gt;&lt;/li&gt;

  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-37-36-metablogapi/7762.image31_5F00_7A64DCE1.png"&gt;&lt;img title="image" style="display: inline;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-37-36-metablogapi/7268.image31_5F00_thumb_5F00_6575EB1F.png" width="444" height="268" /&gt;&lt;/a&gt;&lt;/p&gt;

  &lt;li&gt;&lt;font size="3" face="cal"&gt;In order to isolate the dependencies we need to add Fakes for DemoLibrary and System.ServiceModel assemblies and behaviour will be redefined using delegates. Add Fakes assembly as displayed below&lt;/font&gt;

    &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-37-36-metablogapi/8814.image6_5F00_294CB028.png"&gt;&lt;img title="image" style="display: inline;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-37-36-metablogapi/1452.image6_5F00_thumb_5F00_5B46E163.png" width="448" height="235" /&gt;&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;

  &lt;li&gt;&lt;font size="3" face="ca"&gt;A .fakes file will be added to the project under Fakes folder and reference to {Assembly}.Fakes.dll will be added as displayed below&lt;/font&gt;&amp;#160; &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-37-36-metablogapi/5672.image91_5F00_25D0AFEF.png"&gt;&lt;img title="image" style="display: inline;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-37-36-metablogapi/2022.image91_5F00_thumb_5F00_09C281B5.png" width="449" height="297" /&gt;&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;

  &lt;li&gt;&lt;font size="3" face="Calibri"&gt;Similarly as explained above we need to generate Fakes for System.ServiceModel assembly. I got “Failed to generate Stub/Shim for type …” error messages on building the project. There are couple of ways to fix it.&lt;/font&gt;&lt;/li&gt;
  &lt;font size="3" face="Calibri"&gt;&lt;/font&gt;

  &lt;ol&gt;&lt;font size="3" face="Calibri"&gt;&lt;/font&gt;

    &lt;li&gt;&lt;font size="3" face="Calibri"&gt;Change the Target Framework of the Test project from .NET Framework 4.5 to .NET Framework 4.0&lt;/font&gt;&lt;/li&gt;
    &lt;font size="3" face="Calibri"&gt;&lt;/font&gt;

    &lt;li&gt;&lt;font size="3" face="Calibri"&gt;Open the System.ServiceModel.fakes and remove the types for which Shim/Stub generation is failing. Since I’m not using Stubs I’ve disabled the StubGeneration as displayed below&lt;/font&gt;

      &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-37-36-metablogapi/4743.image_5F00_21E87CC1.png"&gt;&lt;img title="image" style="display: inline;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-37-36-metablogapi/7041.image_5F00_thumb_5F00_6A385341.png" width="417" height="424" /&gt;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;

  &lt;li&gt;&lt;font size="3" face="Calibri"&gt;The next step is to Mock the Service call(redefine behaviour using delegates) and add Asserts as displayed in code snippets below. The main points are&lt;/font&gt;&lt;/li&gt;

  &lt;ol&gt;
    &lt;li&gt;&lt;font size="3" face="Calibri"&gt;I have used Shims to isolate calls to non-virtual functions in unit test methods. &lt;a href="http://msdn.microsoft.com/en-us/library/hh549175(VS.110).aspx" target="_blank"&gt;Read more&lt;/a&gt; about Shim and Stub types.&lt;/font&gt;&lt;/li&gt;

    &lt;li&gt;&lt;font size="3" face="Calibri"&gt;When using shim types in a unit test framework, you must wrap the test code in a ShimsContext to control the lifetime of your shims.&lt;/font&gt;&lt;/li&gt;
  &lt;/ol&gt;

  &lt;div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 200px; background-color: rgb(244, 244, 244);"&gt;
    &lt;div id="codeSnippet" style="padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;
      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;[TestMethod]&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt; TestSearch()&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;using&lt;/span&gt; (ShimsContext.Create())&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;        ShimWCFService&amp;lt;IDemoService&amp;gt;();&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;        ShimDemoServiceClient.Constructor = (var1) =&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;        {&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;            &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; ShimDemoServiceClient { };&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;        };&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;        &lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;        ShimDemoServiceClient.AllInstances.SearchString = (var1, var2) =&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;        {&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;            &lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt; &lt;span style="color: rgb(0, 96, 128);"&gt;&amp;quot;Result&amp;quot;&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;        };&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;        &lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;        Search search = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; Search();&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; result = search.GetResults(&lt;span style="color: rgb(0, 96, 128);"&gt;&amp;quot;test&amp;quot;&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;        Assert.IsNotNull(result);&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;        Assert.AreEqual(result, &lt;span style="color: rgb(0, 96, 128);"&gt;&amp;quot;Result&amp;quot;&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;    }&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;/// Mocks the WCF service.&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;private&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt; ShimWCFService&amp;lt;TService&amp;gt;() &lt;span style="color: rgb(0, 0, 255);"&gt;where&lt;/span&gt; TService : &lt;span style="color: rgb(0, 0, 255);"&gt;class&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;{            &lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;    ShimClientCredentials.Constructor = (var1) =&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; ShimClientCredentials();&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;    };&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;    ShimClientCredentials.AllInstances.WindowsGet = (var1) =&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; ShimWindowsClientCredential();&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;    };&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;    ShimWindowsClientCredential.AllInstances.ClientCredentialGet = (var1) =&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; System.Net.NetworkCredential();&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;    };&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;    ShimWindowsClientCredential.AllInstances.ClientCredentialSetNetworkCredential = (var1, var2) =&amp;gt; { };&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;    ShimWindowsClientCredential.AllInstances.AllowNtlmGet = (var1) =&amp;gt; { &lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;true&lt;/span&gt;; };&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;    ShimWindowsClientCredential.AllInstances.AllowNtlmSetBoolean = (var1, var2) =&amp;gt; { };&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;    ShimWindowsClientCredential.AllInstances.AllowedImpersonationLevelGet = (var1) =&amp;gt; { &lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt; System.Security.Principal.TokenImpersonationLevel.Impersonation; };&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;    ShimWindowsClientCredential.AllInstances.AllowedImpersonationLevelSetTokenImpersonationLevel = (var1, var2) =&amp;gt; { };&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;    ShimChannelFactory.AllInstances.CredentialsGet = (var1) =&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;    { &lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; ShimClientCredentials(); };&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;    ShimClientBase&amp;lt;TService&amp;gt;.AllInstances.ClientCredentialsGet = (var1) =&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; System.ServiceModel.Description.ClientCredentials();&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;    };&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;    ShimClientBase&amp;lt;TService&amp;gt;.AllInstances.ChannelFactoryGet = (var1) =&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; ShimChannelFactory&amp;lt;TService&amp;gt;();&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;    };&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;    ShimClientBase&amp;lt;TService&amp;gt;.AllInstances.StateGet = (var1) =&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt; CommunicationState.Opened;&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;    };&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;    ShimClientBase&amp;lt;TService&amp;gt;.AllInstances.Close = (var1) =&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;    { };&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;    ShimClientBase&amp;lt;TService&amp;gt;.AllInstances.Abort = (var1) =&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"&gt;    { };&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
  &lt;/div&gt;

  &lt;li&gt;&lt;font size="3" face="Calibri"&gt;Go to Unit Test explorer and run the tests&lt;/font&gt;

    &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-37-36-metablogapi/2577.image15_5F00_5DCCC0C9.png"&gt;&lt;img title="image" style="display: inline;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-37-36-metablogapi/6443.image15_5F00_thumb_5F00_48DDCF07.png" width="412" height="312" /&gt;&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;

  &lt;li&gt;&lt;font size="3" face="Calibri"&gt;You can also Analyze the code coverage. The code coverage results are displayed below &lt;/font&gt;

    &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-37-36-metablogapi/1663.image_5F00_7A6BCD4D.png"&gt;&lt;img title="image" style="display: inline;" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-37-36-metablogapi/4760.image_5F00_thumb_5F00_4E51610D.png" width="508" height="491" /&gt;&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;&lt;font size="3" face="Calibri"&gt;The sample is available for download @ &lt;/font&gt;&lt;a href="http://code.msdn.microsoft.com/vstudio/Unit-Test-a-having-404c2a18" target="_blank"&gt;&lt;strong&gt;&lt;font size="3" face="Calibri"&gt;Download Source code&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;ol&gt;&lt;/ol&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10300339" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/atverma/archive/tags/WCF/">WCF</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/Unit+Test/">Unit Test</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/-NET+Framework+4-0/">.NET Framework 4.0</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/Visual+Studio+11/">Visual Studio 11</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/Microsoft+Fakes/">Microsoft Fakes</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/-NET+Framework+4-5/">.NET Framework 4.5</category></item><item><title>Visual Studio 11 database projects and Unit Testing SQL Server database</title><link>http://blogs.msdn.com/b/atverma/archive/2012/02/19/visual-studio-11-database-projects-and-unit-testing-sql-server-database.aspx</link><pubDate>Sat, 18 Feb 2012 19:02:39 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10269364</guid><dc:creator>Atul.Verma</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/atverma/rsscomments.aspx?WeblogPostID=10269364</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/atverma/commentapi.aspx?WeblogPostID=10269364</wfw:comment><comments>http://blogs.msdn.com/b/atverma/archive/2012/02/19/visual-studio-11-database-projects-and-unit-testing-sql-server-database.aspx#comments</comments><description>&lt;p&gt;&lt;font size="2"&gt;Please find the slides and demos for the session I presented at Microsoft User Group Hyderabad(MUGH). The agenda of the session was&lt;/font&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;font size="2"&gt;Overview about Database Projects &lt;/font&gt;&lt;/li&gt;    &lt;li&gt;&lt;font size="2"&gt;Database development with SQL Server Data Tools(Code-named Juneau) &lt;/font&gt;&lt;/li&gt;    &lt;li&gt;&lt;font size="2"&gt;DEMO – Database development using SQL Server Data Tools and Visual Studio 11 &lt;/font&gt;&lt;/li&gt;    &lt;li&gt;&lt;font size="2"&gt;Basics of Database Unit Testing &lt;/font&gt;&lt;/li&gt;    &lt;li&gt;&lt;font size="2"&gt;DEMO – Unit Testing Visual Studio 2010 Database projects &lt;/font&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;font size="2"&gt;Download from&lt;/font&gt; &lt;iframe style="padding-bottom: 0px; background-color: #fcfcfc; padding-left: 0px; padding-right: 0px; padding-top: 0px" title="Preview" height="128" marginheight="0" src="https://skydrive.live.com/embed?cid=8AA5F5C7517D4722&amp;amp;resid=8AA5F5C7517D4722%21220&amp;amp;authkey=ANOazWK0D419MFU" frameborder="0" width="165" marginwidth="0" scrolling="no"&gt;&lt;/iframe&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10269364" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/atverma/archive/tags/Azure/">Azure</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/SQL+Server+2008/">SQL Server 2008</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/Database/">Database</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/Visual+Studio+2010+Ultimate/">Visual Studio 2010 Ultimate</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/SQL+Azure/">SQL Azure</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/Denali/">Denali</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/SQL+Server+Data+Tools/">SQL Server Data Tools</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/Juneau/">Juneau</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/SQL+Server+2012/">SQL Server 2012</category></item><item><title>Visual Studio 11 Developer Day – Hyderabad(18th Feb 2012)</title><link>http://blogs.msdn.com/b/atverma/archive/2012/02/14/visual-studio-11-developer-day-hyderabad-18th-feb-2012.aspx</link><pubDate>Mon, 13 Feb 2012 18:51:50 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10267405</guid><dc:creator>Atul.Verma</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/atverma/rsscomments.aspx?WeblogPostID=10267405</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/atverma/commentapi.aspx?WeblogPostID=10267405</wfw:comment><comments>http://blogs.msdn.com/b/atverma/archive/2012/02/14/visual-studio-11-developer-day-hyderabad-18th-feb-2012.aspx#comments</comments><description>&lt;p&gt;&lt;a href="http://www.mugh.net/"&gt;Microsoft User Group Hyderabad (MUGH )&lt;/a&gt; invites you to &lt;a href="http://mugh.net/vs11devday/Default.html"&gt;Developer Day&lt;/a&gt; on 18th Feb 2012 ( 9:30 A.M to 1.30 PM ) at &lt;em&gt;Microsoft Campus, Building 3 MPR Halls&lt;/em&gt;, &lt;em&gt;Gachibowli&lt;/em&gt;, &lt;em&gt;Hyderabad&lt;/em&gt;. Join us to meet Charles Sterling, Senior Program Manager, Visual Studio Team. Charles will deliver 90 min session on “Application Lifecycle Management with Visual Studio 11”.&amp;#160; Additionally, we have two sessions on “Debug production hosted application with Intellitrace and Visual Studio 11” and “Visual Studio 11 database projects and Unit Testing SQL Server database”.&lt;/p&gt;  &lt;p&gt;Check out the Complete Agenda from here : &lt;a href="http://mugh.net/vs11devday/agenda.html"&gt;http://mugh.net/vs11devday/agenda.html&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Register for the event from &lt;a href="http://mughvs11devday.eventbrite.com/"&gt;http://mughvs11devday.eventbrite.com/&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://mugh.net/vs11devday/Default.html"&gt;&lt;img alt="image" src="http://abhijitjana.files.wordpress.com/2012/02/image.png?w=388&amp;amp;h=159" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10267405" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/atverma/archive/tags/Visual+Studio+11/">Visual Studio 11</category></item><item><title>Utility to generate Word documents from templates using Visual Studio 2010 and Open Xml 2.0 SDK - Part 4</title><link>http://blogs.msdn.com/b/atverma/archive/2012/01/24/utility-to-generate-word-documents-from-templates-using-visual-studio-2010-and-open-xml-2-0-sdk-part-4.aspx</link><pubDate>Tue, 24 Jan 2012 12:31:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10259901</guid><dc:creator>Atul.Verma</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/atverma/rsscomments.aspx?WeblogPostID=10259901</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/atverma/commentapi.aspx?WeblogPostID=10259901</wfw:comment><comments>http://blogs.msdn.com/b/atverma/archive/2012/01/24/utility-to-generate-word-documents-from-templates-using-visual-studio-2010-and-open-xml-2-0-sdk-part-4.aspx#comments</comments><description>&lt;p&gt;&lt;font size="2"&gt;This is the fourth part of this series. The code is available for download at &lt;/font&gt;&lt;a href="http://worddocgenerator.codeplex.com/"&gt;&lt;font size="2"&gt;http://worddocgenerator.codeplex.com/&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt;.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2"&gt;In &lt;/font&gt;&lt;a href="http://blogs.msdn.com/b/atverma/archive/2011/12/31/utility-to-generate-word-documents-from-templates-using-visual-studio-2010-and-open-xml-2-0-sdk.aspx"&gt;&lt;font size="2"&gt;Part 1&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt; I discussed about&lt;/font&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;font size="2"&gt;Document generation using Content Controls and Open XML 2.0 SDK &lt;/font&gt;&lt;/li&gt;    &lt;li&gt;&lt;font size="2"&gt;Creating Word templates &lt;/font&gt;&lt;/li&gt;    &lt;li&gt;&lt;font size="2"&gt;Implementation and Samples&lt;/font&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;font size="2"&gt;In &lt;/font&gt;&lt;a href="http://blogs.msdn.com/b/atverma/archive/2012/01/08/utility-to-generate-word-documents-from-templates-using-visual-studio-2010-and-open-xml-2-0-sdk-part-2-samples-updated.aspx"&gt;&lt;font size="2"&gt;Part 2&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt; I discussed about&lt;/font&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;font size="2"&gt;List of functionalities that can be achieved using the utility/source code &lt;/font&gt;&lt;/li&gt;    &lt;li&gt;&lt;font size="2"&gt;Description regarding Samples provided with utility &lt;/font&gt;&lt;/li&gt;    &lt;li&gt;&lt;font size="2"&gt;New samples added in this update&lt;/font&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;font size="2"&gt;In &lt;/font&gt;&lt;a href="http://blogs.msdn.com/b/atverma/archive/2012/01/11/utility-to-generate-word-documents-from-templates-using-visual-studio-2010-and-open-xml-2-0-sdk-part-3.aspx"&gt;&lt;font size="2"&gt;Part 3&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt; I discussed about&lt;/font&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;font size="2"&gt;Document-level customizations for Word 2007 and Word 2010&lt;/font&gt;&lt;/li&gt;    &lt;li&gt;&lt;font size="2"&gt;One of the ways to “Refresh the document from within the Word(e.g. right click on document and click Refresh) using document-level customizations for Word 2007 and Word 2010“&lt;/font&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;font size="2"&gt;This post will focus on Charts. I’ve added the samples to generate/refresh charts using OpenXML. The screenshot below displays the template having Scatter chart and Line chart and the document generated out of this template using this utility.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: x-small" size="2"&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h3&gt;Word 2010 Template having Charts –&amp;gt; Generated documents with Charts refreshed:&lt;/h3&gt;    &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-37-36-metablogapi/7026.image_5F00_2DAA9497.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-37-36-metablogapi/7024.image_5F00_thumb_5F00_267B3252.png" width="481" height="266" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-37-36-metablogapi/2046.image_5F00_15B387A4.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-37-36-metablogapi/5736.image_5F00_thumb_5F00_27AFA564.png" width="485" height="258" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;h3&gt;Code Changes:&lt;/h3&gt;  &lt;p&gt;&lt;span style="font-size: x-small" size="2"&gt;&lt;font size="2"&gt;Class diagram for Chart specific classes is displayed below &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: x-small" size="2"&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-37-36-metablogapi/2781.image_5F00_24BA40B1.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-37-36-metablogapi/1682.image_5F00_thumb_5F00_4D75A5FA.png" width="540" height="151" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2"&gt;“SampleDocumentWithTableAndChartsGenerator” is the sample that shows how to refresh template having Scatter and Line charts. The code snippets are displayed below&lt;/font&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;font size="2"&gt;“RefreshCharts” method is added to DocumentGenerator class &lt;/font&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;   &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;     &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;/// Refreshes the charts.&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;/// &amp;lt;param name=&amp;quot;mainDocumentPart&amp;quot;&amp;gt;The main document part.&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;protected virtual void RefreshCharts(MainDocumentPart mainDocumentPart)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;font size="2"&gt;“SampleDocumentWithTableAndChartsGenerator” class overrides “RefreshCharts” method &lt;/font&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;/// Refreshes the charts.&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;/// &amp;lt;param name=&amp;quot;mainDocumentPart&amp;quot;&amp;gt;The main document part.&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;protected override void RefreshCharts(MainDocumentPart mainDocumentPart)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;    if (mainDocumentPart != null)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;        foreach (ChartPart chartPart in mainDocumentPart&lt;span style="color: #cc6633"&gt;.ChartParts&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;        {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;            Chart chart = chartPart&lt;span style="color: #cc6633"&gt;.ChartSpace&lt;/span&gt;&lt;span style="color: #cc6633"&gt;.Elements&lt;/span&gt;&lt;span style="color: #006080"&gt;&amp;lt;&lt;/span&gt;Chart&lt;span style="color: #006080"&gt;&amp;gt;&lt;/span&gt;()&lt;span style="color: #cc6633"&gt;.FirstOrDefault&lt;/span&gt;();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;            if (chart != null)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;            {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;                DocumentFormat&lt;span style="color: #cc6633"&gt;.OpenXml&lt;/span&gt;&lt;span style="color: #cc6633"&gt;.Drawing&lt;/span&gt;&lt;span style="color: #cc6633"&gt;.Charts&lt;/span&gt;&lt;span style="color: #cc6633"&gt;.ScatterChart&lt;/span&gt; scatterChart = chart&lt;span style="color: #cc6633"&gt;.Descendants&lt;/span&gt;&lt;span style="color: #006080"&gt;&amp;lt;&lt;/span&gt;DocumentFormat&lt;span style="color: #cc6633"&gt;.OpenXml&lt;/span&gt;&lt;span style="color: #cc6633"&gt;.Drawing&lt;/span&gt;&lt;span style="color: #cc6633"&gt;.Charts&lt;/span&gt;&lt;span style="color: #cc6633"&gt;.ScatterChart&lt;/span&gt;&lt;span style="color: #006080"&gt;&amp;gt;&lt;/span&gt;()&lt;span style="color: #cc6633"&gt;.FirstOrDefault&lt;/span&gt;();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;                DocumentFormat&lt;span style="color: #cc6633"&gt;.OpenXml&lt;/span&gt;&lt;span style="color: #cc6633"&gt;.Drawing&lt;/span&gt;&lt;span style="color: #cc6633"&gt;.Charts&lt;/span&gt;&lt;span style="color: #cc6633"&gt;.Line3DChart&lt;/span&gt; lineChart = chart&lt;span style="color: #cc6633"&gt;.Descendants&lt;/span&gt;&lt;span style="color: #006080"&gt;&amp;lt;&lt;/span&gt;DocumentFormat&lt;span style="color: #cc6633"&gt;.OpenXml&lt;/span&gt;&lt;span style="color: #cc6633"&gt;.Drawing&lt;/span&gt;&lt;span style="color: #cc6633"&gt;.Charts&lt;/span&gt;&lt;span style="color: #cc6633"&gt;.Line3DChart&lt;/span&gt;&lt;span style="color: #006080"&gt;&amp;gt;&lt;/span&gt;()&lt;span style="color: #cc6633"&gt;.FirstOrDefault&lt;/span&gt;();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;                if (scatterChart != null)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;                {                            &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;                    ScatterChartEx chartEx = new ScatterChartEx(chartPart, this&lt;span style="color: #cc6633"&gt;.scatterChartData&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;                    chartEx&lt;span style="color: #cc6633"&gt;.Refresh&lt;/span&gt;();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;                }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;                if (lineChart != null)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;                {                            &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;                    Line3DChartEx chartEx = new Line3DChartEx(chartPart, this&lt;span style="color: #cc6633"&gt;.lineChartData&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;                    chartEx&lt;span style="color: #cc6633"&gt;.Refresh&lt;/span&gt;();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;                }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;            }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;            chartPart&lt;span style="color: #cc6633"&gt;.ChartSpace&lt;/span&gt;&lt;span style="color: #cc6633"&gt;.Save&lt;/span&gt;();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;        }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;    }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;font size="2"&gt;Refresh method is defined in ChartEx&amp;lt;T&amp;gt;&lt;/font&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;/// Refreshes this instance.&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;public void Refresh()&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;    ChartData chartData = this&lt;span style="color: #cc6633"&gt;.GetChartData&lt;/span&gt;();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;    if (chartData != null &lt;span style="color: #006080"&gt;&amp;amp;&lt;/span&gt;&lt;span style="color: #006080"&gt;&amp;amp;&lt;/span&gt; chartData&lt;span style="color: #cc6633"&gt;.IsValid&lt;/span&gt;())&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;        string sheetName = this&lt;span style="color: #cc6633"&gt;.UpdateEmbeddedObject&lt;/span&gt;();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;        Chart chart = chartPart&lt;span style="color: #cc6633"&gt;.ChartSpace&lt;/span&gt;&lt;span style="color: #cc6633"&gt;.Elements&lt;/span&gt;&lt;span style="color: #006080"&gt;&amp;lt;&lt;/span&gt;Chart&lt;span style="color: #006080"&gt;&amp;gt;&lt;/span&gt;()&lt;span style="color: #cc6633"&gt;.FirstOrDefault&lt;/span&gt;();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;        if (chart != null)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;        {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;            this&lt;span style="color: #cc6633"&gt;.UpdateChart&lt;/span&gt;(chart&lt;span style="color: #cc6633"&gt;.Descendants&lt;/span&gt;&lt;span style="color: #006080"&gt;&amp;lt;&lt;/span&gt;T&lt;span style="color: #006080"&gt;&amp;gt;&lt;/span&gt;()&lt;span style="color: #cc6633"&gt;.FirstOrDefault&lt;/span&gt;(), sheetName);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;        }              &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;    }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;span style="font-size: x-small" size="2"&gt;&lt;font size="2"&gt;For complete code download the &lt;/font&gt;&lt;a href="http://worddocgenerator.codeplex.com/"&gt;&lt;font size="2"&gt;source code&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt;.&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;

&lt;h3&gt;Summary:&lt;/h3&gt;

&lt;p&gt;&lt;span style="font-size: x-small" size="2"&gt;&lt;font size="2"&gt;Please provide feedback/comments and I’ll try to incorporate most of them in new releases.&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10259901" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/atverma/archive/tags/-NET/">.NET</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/Visual+Studio+2010/">Visual Studio 2010</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/Visual+Studio+2010+Ultimate/">Visual Studio 2010 Ultimate</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/-NET+Framework+3-5/">.NET Framework 3.5</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/Word+2007/">Word 2007</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/Word+2010/">Word 2010</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/Open+Xml+2-0+SDK/">Open Xml 2.0 SDK</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/Content+Controls/">Content Controls</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/-NET+Framework+4-0/">.NET Framework 4.0</category></item><item><title>How to use Pex and Moles to generate unit tests for a project having external dependency(WCF Proxy) using Visual Studio 2010 SP1</title><link>http://blogs.msdn.com/b/atverma/archive/2012/01/18/how-to-use-pex-and-moles-to-generate-unit-tests-for-a-project-having-external-dependency-wcf-proxy-using-visual-studio-2010-sp1.aspx</link><pubDate>Wed, 18 Jan 2012 03:28:46 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10257887</guid><dc:creator>Atul.Verma</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/atverma/rsscomments.aspx?WeblogPostID=10257887</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/atverma/commentapi.aspx?WeblogPostID=10257887</wfw:comment><comments>http://blogs.msdn.com/b/atverma/archive/2012/01/18/how-to-use-pex-and-moles-to-generate-unit-tests-for-a-project-having-external-dependency-wcf-proxy-using-visual-studio-2010-sp1.aspx#comments</comments><description>&lt;p&gt;&lt;font size="2"&gt;Source Code: &lt;/font&gt;&lt;iframe style="padding-bottom: 0px; background-color: #fcfcfc; padding-left: 0px; padding-right: 0px; padding-top: 0px" title="Preview" height="120" marginheight="0" src="https://skydrive.live.com/embed?cid=8AA5F5C7517D4722&amp;amp;resid=8AA5F5C7517D4722%21218&amp;amp;authkey=AKfCLZt8yx5O3Kw" frameborder="0" width="98" marginwidth="0" scrolling="no"&gt;&lt;/iframe&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2"&gt;In this post I’ll discuss about writing unit tests using Pex and Moles. Pex and Moles are &lt;/font&gt;&lt;a href="http://msdn.microsoft.com/en-us/vstudio/bb980963.aspx"&gt;&lt;font size="2"&gt;Visual Studio 2010 Power Tools&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt; that help Unit Testing .NET applications.&lt;/font&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;font size="2"&gt;Pex automatically generates test suites with high code coverage. Right from the Visual Studio code editor, Pex finds interesting input-output values of your methods, which you can save as a small test suite with high code coverage. &lt;/font&gt;&lt;/li&gt;    &lt;li&gt;&lt;font size="2"&gt;Moles allows to replace any .NET method with a delegate. Moles supports unit testing by providing isolation by way of detours and stubs i.e. Generate a Mole type from the original type and redefine its behavior using delegates. &lt;/font&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;font size="2"&gt;Pex and Moles can be downloaded from &lt;/font&gt;&lt;a href="http://research.microsoft.com/en-us/projects/pex/"&gt;&lt;font size="2"&gt;http://research.microsoft.com/en-us/projects/pex/&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt;.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2"&gt;I’ll explain the steps to generate unit tests for a project which calls a WCF service. Pex will be used to generate unit tests. Moles will be generated to isolate the external dependency(WCF proxy) and behavior will be redefined using delegates.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2"&gt;The projects inside the sample solution are&lt;/font&gt;&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;&lt;font size="2"&gt;DemoService: This project is a WCF Service. &lt;/font&gt;&lt;/li&gt;    &lt;li&gt;&lt;font size="2"&gt;DemoLibrary: This project is a Class library and service reference to DemoService has been added. Unit tests will be generated for this project. &lt;/font&gt;&lt;/li&gt;    &lt;li&gt;&lt;font size="2"&gt;ConsoleApp: This project is a Console application. &lt;/font&gt;&lt;/li&gt;    &lt;li&gt;&lt;font size="2"&gt;DemoLibrary.Tests: This is a Test project and contains unit tests for DemoLibrary. &lt;/font&gt;&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;&lt;font size="2"&gt;The solution structure is displayed below&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-37-36-metablogapi/2364.image_5F00_2D405F5A.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-37-36-metablogapi/8508.image_5F00_thumb_5F00_2B5FE3C6.png" width="306" height="533" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2"&gt;DemoLibrary calls DemoService though proxy as displayed in the Layer diagram&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-37-36-metablogapi/2843.image_5F00_7EC68E12.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-37-36-metablogapi/0118.image_5F00_thumb_5F00_00B3DD1C.png" width="417" height="162" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2"&gt;I’ll now discuss in brief the code snippets of each project&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2"&gt;&lt;strong&gt;WCF Service(DemoService):&lt;/strong&gt; This service provided only a single operation&lt;/font&gt;&lt;/p&gt;  &lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;   &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;     &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;[ServiceContract]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;public interface IDemoService&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;    [OperationContract]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;    string Search(string criteria);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;font size="2"&gt;&lt;strong&gt;WCF Service Client(DemoLibrary):&lt;/strong&gt; It calls the Search method of DemoService through proxy as displayed below&lt;/font&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;public string GetResults(string &lt;span style="color: #0000ff"&gt;s&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;    DemoServiceReference&lt;span style="color: #cc6633"&gt;.DemoServiceClient&lt;/span&gt; client &lt;span style="color: #006080"&gt;= null;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;    try&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;        client = new DemoServiceReference&lt;span style="color: #cc6633"&gt;.DemoServiceClient&lt;/span&gt;();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;        client&lt;span style="color: #cc6633"&gt;.ClientCredentials&lt;/span&gt;&lt;span style="color: #cc6633"&gt;.Windows&lt;/span&gt;&lt;span style="color: #cc6633"&gt;.AllowedImpersonationLevel&lt;/span&gt; &lt;span style="color: #006080"&gt;= System.Security.Principal.TokenImpersonationLevel.Impersonation;&lt;/span&gt;                &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;        client&lt;span style="color: #cc6633"&gt;.ChannelFactory&lt;/span&gt;&lt;span style="color: #cc6633"&gt;.Credentials&lt;/span&gt;&lt;span style="color: #cc6633"&gt;.Windows&lt;/span&gt;&lt;span style="color: #cc6633"&gt;.ClientCredential&lt;/span&gt; &lt;span style="color: #006080"&gt;= System.Net.CredentialCache.DefaultNetworkCredentials;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;s&lt;/span&gt; = client&lt;span style="color: #cc6633"&gt;.Search&lt;/span&gt;(&lt;span style="color: #0000ff"&gt;s&lt;/span&gt;)&lt;span style="color: #006080"&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;        return s;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;    }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;    finally&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;        if (client != null)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;        {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;            if (client&lt;span style="color: #cc6633"&gt;.State&lt;/span&gt; == CommunicationState&lt;span style="color: #cc6633"&gt;.Opened&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;            {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;                client&lt;span style="color: #cc6633"&gt;.Close&lt;/span&gt;();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;            }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;            else if (client&lt;span style="color: #cc6633"&gt;.State&lt;/span&gt; == CommunicationState&lt;span style="color: #cc6633"&gt;.Faulted&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;            {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;                client&lt;span style="color: #cc6633"&gt;.Abort&lt;/span&gt;();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;            }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;        }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;    }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;font size="2"&gt;&lt;strong&gt;Unit Testing DemoLibrary using Pex and Moles:&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;&lt;font size="2"&gt;In order to generate unit tests for WCF Service Client(DemoLibrary) project the steps are&lt;/font&gt;&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;font size="2"&gt;Right click on the class for which unit tests needs to be generated and click “Create Parameterized Unit Tests” as displayed below&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-37-36-metablogapi/3683.image_5F00_736D5408.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-37-36-metablogapi/5344.image_5F00_thumb_5F00_032CE90D.png" width="461" height="82" /&gt;&lt;/a&gt;&lt;/font&gt; &lt;/li&gt;

  &lt;li&gt;&lt;font size="2"&gt;A popup will be displayed where Filters and Output can be modified. Click Ok to go to next step.&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-37-36-metablogapi/7433.image_5F00_6088AA91.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-37-36-metablogapi/4721.image_5F00_thumb_5F00_16AA22E1.png" width="468" height="228" /&gt;&lt;/a&gt;&lt;/font&gt; &lt;/li&gt;

  &lt;li&gt;&lt;font size="2"&gt;A new test project will be created. Test Class and Test stub will be be added to this project as displayed below 
      &lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
        &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;/// &amp;lt;summary&amp;gt;This class contains parameterized unit tests for Search&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;[PexClass(typeof(Search))]&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;[PexAllowedExceptionFromTypeUnderTest(typeof(InvalidOperationException))]&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;[PexAllowedExceptionFromTypeUnderTest(typeof(ArgumentException), AcceptExceptionSubtypes = true)]&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;[TestClass]&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;public partial class SearchTest&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #008000"&gt;/// &amp;lt;summary&amp;gt;Test stub for GetResults(String)&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;    [PexMethod]&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;    public string GetResults([PexAssumeUnderTest]Search target, string &lt;span style="color: #0000ff"&gt;s&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;        string result = target&lt;span style="color: #cc6633"&gt;.GetResults1&lt;/span&gt;(&lt;span style="color: #0000ff"&gt;s&lt;/span&gt;)&lt;span style="color: #006080"&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;        return result;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #008000"&gt;// TODO: add assertions to method SearchTest.GetResults(Search, String)&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;    }&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
      &lt;/div&gt;
    &lt;/font&gt;&lt;/li&gt;

  &lt;li&gt;&lt;font size="2"&gt;There is an external dependency(&lt;font size="2"&gt;GetResults makes a service call though the WCF Proxy&lt;/font&gt;) so “Run Pex Explorations” will not generate unit tests as displayed below&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-37-36-metablogapi/2514.image_5F00_7399B170.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-37-36-metablogapi/6646.image_5F00_thumb_5F00_5161A5EA.png" width="467" height="112" /&gt;&lt;/a&gt;&lt;/font&gt;&lt;/li&gt;

  &lt;li&gt;&lt;font size="2"&gt;In order to isolate the external dependency we need to generate Moles before running Pex Explorations. Moles will be generated for DemoLibrary and System.ServiceModel assemblies and behavior will be redefined using delegates. There are two ways to generate a mole for an assembly. I’ll show you both the approaches&lt;/font&gt; 

    &lt;ol&gt;
      &lt;li&gt;&lt;font size="2"&gt;&lt;strong&gt;Visual Studio:&lt;/strong&gt; This is the easiest way. &lt;/font&gt;

        &lt;ol&gt;
          &lt;li&gt;&lt;font size="2"&gt;Right click on the reference and generate Moles for that assembly as displayed below.&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-37-36-metablogapi/6232.image_5F00_1C74A0AD.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-37-36-metablogapi/8838.image_5F00_thumb_5F00_6BFE1C36.png" width="345" height="346" /&gt;&lt;/a&gt;&lt;/font&gt; &lt;/li&gt;

          &lt;li&gt;&lt;font size="2"&gt;A .Moles file will be added to the project. Build the project and Moles.dll will be added to MolesAssemblies folder as displayed below&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; .&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-37-36-metablogapi/1030.image_5F00_29CA8DE6.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-37-36-metablogapi/1854.image_5F00_thumb_5F00_7954096F.png" width="407" height="71" /&gt;&lt;/a&gt;&lt;/font&gt; &lt;/li&gt;
        &lt;/ol&gt;
      &lt;/li&gt;

      &lt;li&gt;&lt;font size="2"&gt;&lt;strong&gt;Command Prompt:&lt;/strong&gt; Moles can be generated from the command prompt.&lt;/font&gt; 

        &lt;ol&gt;
          &lt;li&gt;&lt;font size="2"&gt;Run the moles.exe and specify the assembly path for which Moles needs to be created.&lt;/font&gt;&lt;font size="2"&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-37-36-metablogapi/3718.image_5F00_thumb21_5F00_5DCF076C.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image_thumb2[1]" border="0" alt="image_thumb2[1]" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-37-36-metablogapi/5811.image_5F00_thumb21_5F00_thumb_5F00_615CFC7C.png" width="412" height="233" /&gt;&lt;/a&gt;&lt;/font&gt; &lt;/li&gt;

          &lt;li&gt;&lt;font size="2"&gt;Copy the generated assembly to the Project and add reference to it. &lt;/font&gt;&lt;/li&gt;
        &lt;/ol&gt;
      &lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;

  &lt;li&gt;&lt;font size="2"&gt;Similarly as explained above we need to generate Moles for System.ServiceModel assembly. For Visual Studio 2010 SP1 this may fail with error message “The type or namespace name 'IHttpCookieContainerManager' does not exist in the namespace 'ssm::System.ServiceModel.Channels' (are you missing an assembly reference?)”. This step however works fine for Visual Studio 2010. The fix is to exclude the type i.e. 'IHttpCookieContainerManager' from StubGeneration as displayed below&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-37-36-metablogapi/2100.image_5F00_3BC3594E.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-37-36-metablogapi/7827.image_5F00_thumb_5F00_7970410A.png" width="457" height="98" /&gt;&lt;/a&gt;&lt;/font&gt; &lt;/li&gt;

  &lt;li&gt;&lt;font size="2"&gt;The next step is to Mock the Service call(redefine behavior using delegates) and add Asserts as displayed in code snippets below 
      &lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
        &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;/// &amp;lt;summary&amp;gt;Test stub for GetResults(String)&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;[PexMethod]&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;public string GetResults([PexAssumeUnderTest]Search target, string &lt;span style="color: #0000ff"&gt;s&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;    MockWCFService&lt;span style="color: #006080"&gt;&amp;lt;&lt;/span&gt;IDemoService&lt;span style="color: #006080"&gt;&amp;gt;&lt;/span&gt;();&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;    MDemoServiceClient&lt;span style="color: #cc6633"&gt;.Constructor&lt;/span&gt; = (var1) =&lt;span style="color: #006080"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;       new MDemoServiceClient { };&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;    MDemoServiceClient&lt;span style="color: #cc6633"&gt;.AllInstances&lt;/span&gt;&lt;span style="color: #cc6633"&gt;.SearchString&lt;/span&gt; = (var1, var2) =&lt;span style="color: #006080"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #006080"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;        return &amp;quot;Result&amp;quot;;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;    };&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;    string result = target&lt;span style="color: #cc6633"&gt;.GetResults&lt;/span&gt;(&lt;span style="color: #0000ff"&gt;s&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;    PexAssert&lt;span style="color: #cc6633"&gt;.IsNotNullOrEmpty&lt;/span&gt;(result);&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;    PexAssert&lt;span style="color: #cc6633"&gt;.AreEqual&lt;/span&gt;(result, &amp;quot;Result&amp;quot;)&lt;span style="color: #006080"&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;    return result;&lt;/span&gt;            &lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;/// Mocks the WCF service.&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;private void MockWCFService&lt;span style="color: #006080"&gt;&amp;lt;&lt;/span&gt;TService&lt;span style="color: #006080"&gt;&amp;gt;&lt;/span&gt;() where TService : class&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;    MClientCredentials&lt;span style="color: #cc6633"&gt;.Constructor&lt;/span&gt; = (var1) =&lt;span style="color: #006080"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;        new MClientCredentials()&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;        {&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;            WindowsGet = () =&lt;span style="color: #006080"&gt;&amp;gt;&lt;/span&gt; { return new MWindowsClientCredential(); }&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;        };&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;    MClientCredentials&lt;span style="color: #cc6633"&gt;.AllInstances&lt;/span&gt;&lt;span style="color: #cc6633"&gt;.WindowsGet&lt;/span&gt; = (var1) =&lt;span style="color: #006080"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;        return new MWindowsClientCredential();&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;    };&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;    MWindowsClientCredential&lt;span style="color: #cc6633"&gt;.AllInstances&lt;/span&gt;&lt;span style="color: #cc6633"&gt;.ClientCredentialGet&lt;/span&gt; = (var1) =&lt;span style="color: #006080"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;        return new System&lt;span style="color: #cc6633"&gt;.Net&lt;/span&gt;&lt;span style="color: #cc6633"&gt;.NetworkCredential&lt;/span&gt;();&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;    };&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;    MWindowsClientCredential&lt;span style="color: #cc6633"&gt;.AllInstances&lt;/span&gt;&lt;span style="color: #cc6633"&gt;.ClientCredentialSetNetworkCredential&lt;/span&gt; = (var1, var2) =&lt;span style="color: #006080"&gt;&amp;gt;&lt;/span&gt; { };&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;    MWindowsClientCredential&lt;span style="color: #cc6633"&gt;.AllInstances&lt;/span&gt;&lt;span style="color: #cc6633"&gt;.AllowNtlmGet&lt;/span&gt; = (var1) =&lt;span style="color: #006080"&gt;&amp;gt;&lt;/span&gt; &lt;span style="color: #006080"&gt;{ return true;&lt;/span&gt; };&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;    MWindowsClientCredential&lt;span style="color: #cc6633"&gt;.AllInstances&lt;/span&gt;&lt;span style="color: #cc6633"&gt;.AllowNtlmSetBoolean&lt;/span&gt; = (var1, var2) =&lt;span style="color: #006080"&gt;&amp;gt;&lt;/span&gt; { };&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;    MWindowsClientCredential&lt;span style="color: #cc6633"&gt;.AllInstances&lt;/span&gt;&lt;span style="color: #cc6633"&gt;.AllowedImpersonationLevelGet&lt;/span&gt; = (var1) =&lt;span style="color: #006080"&gt;&amp;gt;&lt;/span&gt; &lt;span style="color: #006080"&gt;{ return System.Security.Principal.TokenImpersonationLevel.Impersonation;&lt;/span&gt; };&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;    MWindowsClientCredential&lt;span style="color: #cc6633"&gt;.AllInstances&lt;/span&gt;&lt;span style="color: #cc6633"&gt;.AllowedImpersonationLevelSetTokenImpersonationLevel&lt;/span&gt; = (var1, var2) =&lt;span style="color: #006080"&gt;&amp;gt;&lt;/span&gt; { };&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;    MChannelFactory&lt;span style="color: #cc6633"&gt;.AllInstances&lt;/span&gt;&lt;span style="color: #cc6633"&gt;.CredentialsGet&lt;/span&gt; = (var1) =&lt;span style="color: #006080"&gt;&amp;gt;&lt;/span&gt; { return new MClientCredentials(); };&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;    MClientBase&lt;span style="color: #006080"&gt;&amp;lt;&lt;/span&gt;TService&lt;span style="color: #006080"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #cc6633"&gt;.AllInstances&lt;/span&gt;&lt;span style="color: #cc6633"&gt;.ClientCredentialsGet&lt;/span&gt; = (var1) =&lt;span style="color: #006080"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;        return new System&lt;span style="color: #cc6633"&gt;.ServiceModel&lt;/span&gt;&lt;span style="color: #cc6633"&gt;.Description&lt;/span&gt;&lt;span style="color: #cc6633"&gt;.ClientCredentials&lt;/span&gt;();&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;    };&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;    MClientBase&lt;span style="color: #006080"&gt;&amp;lt;&lt;/span&gt;TService&lt;span style="color: #006080"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #cc6633"&gt;.AllInstances&lt;/span&gt;&lt;span style="color: #cc6633"&gt;.ChannelFactoryGet&lt;/span&gt; = (var1) =&lt;span style="color: #006080"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;        return new MChannelFactory01&lt;span style="color: #006080"&gt;&amp;lt;&lt;/span&gt;TService&lt;span style="color: #006080"&gt;&amp;gt;&lt;/span&gt;();&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;    };&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;    MClientBase&lt;span style="color: #006080"&gt;&amp;lt;&lt;/span&gt;TService&lt;span style="color: #006080"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #cc6633"&gt;.AllInstances&lt;/span&gt;&lt;span style="color: #cc6633"&gt;.StateGet&lt;/span&gt; = (var1) =&lt;span style="color: #006080"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;        return PexChoose&lt;span style="color: #cc6633"&gt;.EnumValue&lt;/span&gt;&lt;span style="color: #006080"&gt;&amp;lt;&lt;/span&gt;CommunicationState&lt;span style="color: #006080"&gt;&amp;gt;&lt;/span&gt;(&amp;quot;CommunicationState&amp;quot;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;    };&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;    MClientBase&lt;span style="color: #006080"&gt;&amp;lt;&lt;/span&gt;TService&lt;span style="color: #006080"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #cc6633"&gt;.AllInstances&lt;/span&gt;&lt;span style="color: #cc6633"&gt;.Close&lt;/span&gt; = (var1) =&lt;span style="color: #006080"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;    { };&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;    MClientBase&lt;span style="color: #006080"&gt;&amp;lt;&lt;/span&gt;TService&lt;span style="color: #006080"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #cc6633"&gt;.AllInstances&lt;/span&gt;&lt;span style="color: #cc6633"&gt;.Abort&lt;/span&gt; = (var1) =&lt;span style="color: #006080"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;    { };              &lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
      &lt;/div&gt;
    &lt;/font&gt;&lt;/li&gt;

  &lt;li&gt;&lt;font size="2"&gt;Run Pex Explorations to generate unit tests for GetResults method as displayed below &lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-37-36-metablogapi/6765.image_5F00_4BA27845.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-37-36-metablogapi/8053.image_5F00_thumb_5F00_7B10E711.png" width="454" height="240" /&gt;&lt;/a&gt;&lt;/font&gt; &lt;/li&gt;

  &lt;li&gt;&lt;font size="2"&gt;Unit tests will be added to the Test Class as displayed below&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-37-36-metablogapi/5241.image_5F00_377935EF.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-37-36-metablogapi/7725.image_5F00_thumb_5F00_75261DAB.png" width="430" height="104" /&gt;&lt;/a&gt;&lt;/font&gt; &lt;/li&gt;

  &lt;li&gt;&lt;font size="2"&gt;Go to Test View and Run the unit tests as displayed below&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-37-36-metablogapi/4113.image_5F00_273D4829.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-37-36-metablogapi/5125.image_5F00_thumb_5F00_36FCDD2D.png" width="460" height="133" /&gt;&lt;/a&gt;&lt;/font&gt; &lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;&amp;#160;&lt;/h2&gt;

&lt;h2&gt;Summary:&lt;/h2&gt;

&lt;p&gt;&lt;font size="2"&gt;In a similar way we can extract out external dependencies using Moles and then run Pex Explorations. A few examples of external dependencies can be data layer, UI layer, server calls etc. You can read more about Pex and Moles at &lt;/font&gt;&lt;a title="http://research.microsoft.com/en-us/projects/pex/" href="http://research.microsoft.com/en-us/projects/pex/"&gt;&lt;font size="2"&gt;http://research.microsoft.com/en-us/projects/pex/&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt;.&lt;/font&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10257887" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/atverma/archive/tags/-NET+Framework/">.NET Framework</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/-NET/">.NET</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/Visual+Studio+2010/">Visual Studio 2010</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/WCF/">WCF</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/Unit+Test/">Unit Test</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/Visual+Studio+2010+Ultimate/">Visual Studio 2010 Ultimate</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/Pex+and+Moles/">Pex and Moles</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/Pex/">Pex</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/Moles/">Moles</category></item><item><title>Utility to generate Word documents from templates using Visual Studio 2010 and Open Xml 2.0 SDK - Part 3</title><link>http://blogs.msdn.com/b/atverma/archive/2012/01/11/utility-to-generate-word-documents-from-templates-using-visual-studio-2010-and-open-xml-2-0-sdk-part-3.aspx</link><pubDate>Wed, 11 Jan 2012 17:10:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10255354</guid><dc:creator>Atul.Verma</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/atverma/rsscomments.aspx?WeblogPostID=10255354</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/atverma/commentapi.aspx?WeblogPostID=10255354</wfw:comment><comments>http://blogs.msdn.com/b/atverma/archive/2012/01/11/utility-to-generate-word-documents-from-templates-using-visual-studio-2010-and-open-xml-2-0-sdk-part-3.aspx#comments</comments><description>&lt;p&gt;&lt;span style="font-size: x-small" size="2"&gt;&lt;font size="2"&gt;This is the third post of this series. The earlier posts can be read at &lt;/font&gt;&lt;/span&gt;&lt;a href="http://blogs.msdn.com/b/atverma/archive/2011/12/31/utility-to-generate-word-documents-from-templates-using-visual-studio-2010-and-open-xml-2-0-sdk.aspx" target="_blank"&gt;&lt;span style="font-size: x-small" size="2"&gt;&lt;font size="2"&gt;Part 1&lt;/font&gt;&lt;/span&gt;&lt;/a&gt;&lt;span style="font-size: x-small" size="2"&gt;&lt;font size="2"&gt; and &lt;/font&gt;&lt;/span&gt;&lt;a href="http://blogs.msdn.com/b/atverma/archive/2012/01/08/utility-to-generate-word-documents-from-templates-using-visual-studio-2010-and-open-xml-2-0-sdk-part-2-samples-updated.aspx" target="_blank"&gt;&lt;span style="font-size: x-small" size="2"&gt;&lt;font size="2"&gt;Part 2&lt;/font&gt;&lt;/span&gt;&lt;/a&gt;&lt;span style="font-size: x-small" size="2"&gt;&lt;font size="2"&gt;. The code is available for download at &lt;/font&gt;&lt;/span&gt;&lt;a href="http://worddocgenerator.codeplex.com/" target="_blank"&gt;&lt;span style="font-size: x-small" size="2"&gt;&lt;font size="2"&gt;Utility Source Code&lt;/font&gt;&lt;/span&gt;&lt;/a&gt;&lt;span style="font-size: x-small" size="2"&gt;&lt;font size="2"&gt;. &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: x-small" size="2"&gt;&lt;font size="2"&gt;In &lt;/font&gt;&lt;/span&gt;&lt;a href="http://blogs.msdn.com/b/atverma/archive/2011/12/31/utility-to-generate-word-documents-from-templates-using-visual-studio-2010-and-open-xml-2-0-sdk.aspx" target="_blank"&gt;&lt;span style="font-size: x-small" size="2"&gt;&lt;font size="2"&gt;Part 1&lt;/font&gt;&lt;/span&gt;&lt;/a&gt;&lt;span style="font-size: x-small" size="2"&gt;&lt;font size="2"&gt; I discussed about&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;span style="font-size: x-small" size="2"&gt;&lt;font size="2"&gt;Document generation using Content Controls and Open XML 2.0 SDK &lt;/font&gt;&lt;/span&gt;&lt;/li&gt;    &lt;li&gt;&lt;span style="font-size: x-small" size="2"&gt;&lt;font size="2"&gt;Creating Word templates &lt;/font&gt;&lt;/span&gt;&lt;/li&gt;    &lt;li&gt;&lt;span style="font-size: x-small" size="2"&gt;&lt;font size="2"&gt;Implementation and Samples &lt;/font&gt;&lt;/span&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;span style="font-size: x-small" size="2"&gt;&lt;font size="2"&gt;In &lt;/font&gt;&lt;/span&gt;&lt;a href="http://blogs.msdn.com/b/atverma/archive/2012/01/08/utility-to-generate-word-documents-from-templates-using-visual-studio-2010-and-open-xml-2-0-sdk-part-2-samples-updated.aspx" target="_blank"&gt;&lt;span style="font-size: x-small" size="2"&gt;&lt;font size="2"&gt;Part 2&lt;/font&gt;&lt;/span&gt;&lt;/a&gt;&lt;span style="font-size: x-small" size="2"&gt;&lt;font size="2"&gt; I discussed about&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;span style="font-size: x-small" size="2"&gt;&lt;font size="2"&gt;List of functionalities that can be achieved using the utility/source code &lt;/font&gt;&lt;/span&gt;&lt;/li&gt;    &lt;li&gt;&lt;span style="font-size: x-small" size="2"&gt;&lt;font size="2"&gt;Description regarding Samples provided with utility &lt;/font&gt;&lt;/span&gt;&lt;/li&gt;    &lt;li&gt;&lt;span style="font-size: x-small" size="2"&gt;&lt;font size="2"&gt;New samples added in this update &lt;/font&gt;&lt;/span&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;span style="font-size: x-small" size="2"&gt;&lt;font size="2"&gt;In this part I’ll discuss about the sample that shows one of the ways to “Refresh the document from within the Word(e.g. right click on document and click Refresh) using document-level customizations for Word 2007 and Word 2010“. On click of Refresh Document the content of the document is refreshed as displayed below&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-37-36-metablogapi/5428.image_5F00_298833A9.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-37-36-metablogapi/5148.image_5F00_thumb_5F00_1A90DEC2.png" width="587" height="412" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: x-small" size="2"&gt;&lt;font size="2"&gt;Project “WordDocumentGenerator.WordRefreshableDocumentAddin” has been added to the utility for this sample. The steps followed for creating this sample are listed below&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;&lt;span style="font-size: x-small" size="2"&gt;&lt;font size="2"&gt;Added a new Word 2010 Document project as displayed below &lt;/font&gt;&lt;/span&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-37-36-metablogapi/1586.image_5F00_63C35DF0.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-37-36-metablogapi/8030.image_5F00_thumb_5F00_1A046033.png" width="604" height="376" /&gt;&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;span style="font-size: x-small" size="2"&gt;&lt;font size="2"&gt;Updated the document by adding the content controls as displayed below &lt;/font&gt;&lt;/span&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-37-36-metablogapi/1108.image_5F00_5AD30A0A.png"&gt;&lt;font size="2"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-37-36-metablogapi/3343.image_5F00_thumb_5F00_657015C5.png" width="598" height="400" /&gt;&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;/li&gt;    &lt;li&gt;&lt;span style="font-size: x-small" size="2"&gt;&lt;font size="2"&gt;Added a new Command bar button i.e. “Refresh Data” to the Command bar. On click of this button the document will be refreshed. The common scenario will be to refresh data from the Service. “WordDocumentGenerator.WordRefreshableDocumentAddin” is the document level customization project. This project references “WordDocumentGenerator.Library” and “WordDocumentGenerator.Client” projects. &lt;/font&gt;&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;span style="font-size: x-small" size="2"&gt;&lt;font size="2"&gt;The code snippet to add a new Command bar button is&lt;/font&gt; &lt;/span&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;     &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;       &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;/// Adds the command bar.&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;/// &amp;lt;param name=&amp;quot;cmdBr&amp;quot;&amp;gt;The CMD br.&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;/// &amp;lt;param name=&amp;quot;handler&amp;quot;&amp;gt;The handler.&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;/// &amp;lt;param name=&amp;quot;index&amp;quot;&amp;gt;The index.&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;/// &amp;lt;param name=&amp;quot;tag&amp;quot;&amp;gt;The tag.&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;/// &amp;lt;param name=&amp;quot;caption&amp;quot;&amp;gt;The caption.&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;/// &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;private CommandBarButton AddCommandBar(CommandBar cmdBr, _CommandBarButtonEvents_ClickEventHandler handler, int index, string tag, string &lt;span style="color: #0000ff"&gt;caption&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;    CommandBarButton cmdBtn = (CommandBarButton)cmdBr&lt;span style="color: #cc6633"&gt;.FindControl&lt;/span&gt;(MsoControlType&lt;span style="color: #cc6633"&gt;.msoControlButton&lt;/span&gt;, 0, tag, missing, missing);&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;    if ((cmdBtn != null))&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;        cmdBtn&lt;span style="color: #cc6633"&gt;.Delete&lt;/span&gt;(true);&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;    }&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;    cmdBtn = (CommandBarButton)cmdBr&lt;span style="color: #cc6633"&gt;.Controls&lt;/span&gt;&lt;span style="color: #cc6633"&gt;.Add&lt;/span&gt;(MsoControlType&lt;span style="color: #cc6633"&gt;.msoControlButton&lt;/span&gt;, missing, missing, index, true);&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;    cmdBtn&lt;span style="color: #cc6633"&gt;.Style&lt;/span&gt; &lt;span style="color: #006080"&gt;= MsoButtonStyle.msoButtonCaption;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;    cmdBtn&lt;span style="color: #cc6633"&gt;.Caption&lt;/span&gt; &lt;span style="color: #006080"&gt;= caption;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;    cmdBtn&lt;span style="color: #cc6633"&gt;.Tag&lt;/span&gt; &lt;span style="color: #006080"&gt;= tag;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;    cmdBtn&lt;span style="color: #cc6633"&gt;.Visible&lt;/span&gt; &lt;span style="color: #006080"&gt;= true;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;    cmdBtn&lt;span style="color: #cc6633"&gt;.Click&lt;/span&gt; -&lt;span style="color: #006080"&gt;= handler;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;    cmdBtn&lt;span style="color: #cc6633"&gt;.Click&lt;/span&gt; +&lt;span style="color: #006080"&gt;= handler;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;    if (!commandBarsTags&lt;span style="color: #cc6633"&gt;.Contains&lt;/span&gt;(tag))&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;        commandBarsTags&lt;span style="color: #cc6633"&gt;.Add&lt;/span&gt;(tag);&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #006080"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;    return cmdBtn;&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
  &lt;/div&gt;
&lt;/blockquote&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;span style="font-size: x-small" size="2"&gt;&lt;font size="2"&gt;On click of refresh data the main steps are&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;

  &lt;p&gt;&lt;span style="font-size: x-small" size="2"&gt;&lt;font size="2"&gt;1. Get package steam from the document&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;

  &lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
    &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
      &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;Microsoft&lt;span style="color: #cc6633"&gt;.Office&lt;/span&gt;&lt;span style="color: #cc6633"&gt;.Interop&lt;/span&gt;&lt;span style="color: #cc6633"&gt;.Word&lt;/span&gt;&lt;span style="color: #cc6633"&gt;.Document&lt;/span&gt; doc &lt;span style="color: #006080"&gt;= app.ActiveDocument;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;// Get the active documents as stream of bytes&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;byte[] &lt;span style="color: #0000ff"&gt;input&lt;/span&gt; = doc&lt;span style="color: #cc6633"&gt;.GetPackageStream&lt;/span&gt;(); &lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
  &lt;/div&gt;

  &lt;p&gt;&lt;span style="font-size: x-small" size="2"&gt;&lt;font size="2"&gt;2. Call the Service/Client method that generates/refreshes the document. This can be a Server or a direct call. In this method it’s a direct call.&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;

  &lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
    &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
      &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;// Generate document on the Server. AddInService can be a proxy to service, however here it's direct call&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;byte[] output = AddInService&lt;span style="color: #cc6633"&gt;.GenerateDocument&lt;/span&gt;(&lt;span style="color: #0000ff"&gt;input&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
  &lt;/div&gt;
&lt;/blockquote&gt;

&lt;blockquote&gt;
  &lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
    &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
      &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;/// Generates the document.&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;/// &amp;lt;param name=&amp;quot;documentStream&amp;quot;&amp;gt;The document stream.&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;/// &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;public static byte[] GenerateDocument(byte[] documentStream)&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;{}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
  &lt;/div&gt;

  &lt;p&gt;&lt;span style="font-size: x-small" size="2"&gt;&lt;font size="2"&gt;3. Update the document contents&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;

  &lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
    &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
      &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;XDocument xDoc = OPCHelper&lt;span style="color: #cc6633"&gt;.OpcToFlatOpc&lt;/span&gt;(wordDocument&lt;span style="color: #cc6633"&gt;.Package&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;string openxml = xDoc&lt;span style="color: #cc6633"&gt;.ToString&lt;/span&gt;();                        &lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;doc&lt;span style="color: #cc6633"&gt;.Range&lt;/span&gt;()&lt;span style="color: #cc6633"&gt;.InsertXML&lt;/span&gt;(openxml);&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
  &lt;/div&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;span style="font-size: x-small" size="2"&gt;&lt;font size="2"&gt;These are partial code snippets to show the code flow. For complete sample please download the source code. &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span style="font-size: x-small" size="2"&gt;&lt;font size="2"&gt;References:&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;span style="font-size: x-small" size="2"&gt;&lt;font size="2"&gt;For more information about &lt;/font&gt;&lt;/span&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/bb386206.aspx" target="_blank"&gt;&lt;span style="font-size: x-small" size="2"&gt;&lt;font size="2"&gt;Programming Document level customizations&lt;/font&gt;&lt;/span&gt;&lt;/a&gt;&lt;span style="font-size: x-small" size="2"&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;/span&gt;&lt;/li&gt;

  &lt;li&gt;&lt;span style="font-size: x-small" size="2"&gt;&lt;font size="2"&gt;For more information about methods of OPCHelper class please visit &lt;/font&gt;&lt;/span&gt;&lt;a title="http://msdn.microsoft.com/en-us/library/ff191178.aspx" href="http://msdn.microsoft.com/en-us/library/ff191178.aspx"&gt;&lt;span style="font-size: x-small" size="2"&gt;&lt;font size="2"&gt;http://msdn.microsoft.com/en-us/library/ff191178.aspx&lt;/font&gt;&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10255354" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/atverma/archive/tags/-NET/">.NET</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/Visual+Studio+2010/">Visual Studio 2010</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/Visual+Studio+2010+Ultimate/">Visual Studio 2010 Ultimate</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/Word+2007/">Word 2007</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/Word+2010/">Word 2010</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/Open+Xml+2-0+SDK/">Open Xml 2.0 SDK</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/Content+Controls/">Content Controls</category></item><item><title>Utility to generate Word documents from templates using Visual Studio 2010 and Open Xml 2.0 SDK – Part 2 (Samples Updated)</title><link>http://blogs.msdn.com/b/atverma/archive/2012/01/08/utility-to-generate-word-documents-from-templates-using-visual-studio-2010-and-open-xml-2-0-sdk-part-2-samples-updated.aspx</link><pubDate>Sun, 08 Jan 2012 04:40:36 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10254325</guid><dc:creator>Atul.Verma</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/atverma/rsscomments.aspx?WeblogPostID=10254325</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/atverma/commentapi.aspx?WeblogPostID=10254325</wfw:comment><comments>http://blogs.msdn.com/b/atverma/archive/2012/01/08/utility-to-generate-word-documents-from-templates-using-visual-studio-2010-and-open-xml-2-0-sdk-part-2-samples-updated.aspx#comments</comments><description>&lt;p&gt;&lt;font size="2"&gt;This is the second post of this series. The previous post can be read at &lt;/font&gt;&lt;a href="http://blogs.msdn.com/b/atverma/archive/2011/12/31/utility-to-generate-word-documents-from-templates-using-visual-studio-2010-and-open-xml-2-0-sdk.aspx" target="_blank"&gt;&lt;font size="2"&gt;Part 1&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt;. The next post can be read at &lt;a href="http://blogs.msdn.com/b/atverma/archive/2012/01/11/utility-to-generate-word-documents-from-templates-using-visual-studio-2010-and-open-xml-2-0-sdk-part-3.aspx" target="_blank"&gt;Part 3&lt;/a&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;font size="2"&gt;.&lt;/font&gt; The code is available for download at &lt;/font&gt;&lt;a href="http://worddocgenerator.codeplex.com/" target="_blank"&gt;&lt;font size="2"&gt;Utility Source Code&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt;.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2"&gt;In &lt;font size="2"&gt;&lt;/font&gt;&lt;a href="http://blogs.msdn.com/b/atverma/archive/2011/12/31/utility-to-generate-word-documents-from-templates-using-visual-studio-2010-and-open-xml-2-0-sdk.aspx" target="_blank"&gt;&lt;font size="2"&gt;Part 1&lt;/font&gt;&lt;/a&gt; I discussed about&lt;/font&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;font size="2"&gt;Document generation using Content Controls and Open XML 2.0 SDK&lt;/font&gt; &lt;/li&gt;    &lt;li&gt;&lt;font size="2"&gt;Creating Word templates&lt;/font&gt; &lt;/li&gt;    &lt;li&gt;&lt;font size="2"&gt;Implementation and Samples&lt;/font&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;font size="2"&gt;In &lt;a href="http://blogs.msdn.com/b/atverma/archive/2012/01/11/utility-to-generate-word-documents-from-templates-using-visual-studio-2010-and-open-xml-2-0-sdk-part-3.aspx" target="_blank"&gt;Part 3&lt;/a&gt; I have explained one of the way to “Refresh the document from within the document(e.g. right click on document and click Refresh) using document-level projects for Word 2007 and Word 2010“&lt;/font&gt; &lt;/p&gt;  &lt;p&gt;&lt;font size="2"&gt;In this post I’ll discuss&lt;/font&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;font size="2"&gt;List of functionalities that can be achieved using the utility/source code&lt;/font&gt; &lt;/li&gt;    &lt;li&gt;&lt;font size="2"&gt;Description regarding Samples provided with utility &lt;/font&gt;&lt;/li&gt;    &lt;li&gt;&lt;font size="2"&gt;New samples added in this update&lt;/font&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;font size="2"&gt;The sample document generators are discussed later. The functionalities that can be achieved using the utility/source code are:&lt;/font&gt;&lt;font size="2"&gt;      &lt;br /&gt;&lt;b&gt;Document Generation&lt;/b&gt;&lt;/font&gt;&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;&lt;font size="2"&gt;Generate document from a Word template using content controls as place holders and populate controls with data(Object)[&lt;font size="2"&gt;SampleDocumentGenerator, &lt;font size="2"&gt;SampleRefreshableDocumentGenerator, &lt;font size="2"&gt;SampleDocumentWithTableGenerator]&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt; &lt;/li&gt;    &lt;li&gt;&lt;font size="2"&gt;Generate document from a Word template using content controls as place holders(data bound content controls) and populate controls with data(Object is serialized to Xml). [&lt;font size="2"&gt;SampleDocumentGeneratorUsingDatabinding, &lt;font size="2"&gt;SampleDocumentWithTableGeneratorUsingDatabinding, &lt;font size="2"&gt;SampleDocumentGeneratorUsingXmlAndDatabinding]&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt; &lt;/li&gt;    &lt;li&gt;&lt;font size="2"&gt;Generate document from a Word template using content controls as place holders and populate controls with data(XmlNode)&lt;font size="2"&gt;[&lt;font size="2"&gt;SampleDocumentGeneratorUsingXml]&lt;/font&gt;&lt;/font&gt;&lt;/font&gt; &lt;/li&gt;    &lt;li&gt;&lt;font size="2"&gt;Generate document from a Word template using content controls as place holders(data bound content controls) and populate controls with data(XmlNode) [&lt;font size="2"&gt;SampleDocumentGeneratorUsingXmlAndDatabinding]&lt;/font&gt;&lt;/font&gt; &lt;/li&gt;    &lt;li&gt;&lt;font size="2"&gt;Refresh the document from within the document(e.g. right click on document and click Refresh) using document-level projects for Word 2007 and Word 2010 [Explained in next post i.e. &lt;/font&gt;&lt;a href="http://blogs.msdn.com/b/atverma/archive/2012/01/11/utility-to-generate-word-documents-from-templates-using-visual-studio-2010-and-open-xml-2-0-sdk-part-3.aspx" target="_blank"&gt;&lt;font size="2"&gt;Part 3&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt;]&lt;/font&gt; &lt;/li&gt;    &lt;li&gt;&lt;font size="2"&gt;Generate document that can be &lt;/font&gt;      &lt;ol&gt;       &lt;li&gt;&lt;font size="2"&gt;Standalone: Once generated document cannot be refreshed. &lt;/font&gt;&lt;/li&gt;        &lt;li&gt;&lt;font size="2"&gt;Refreshable: Once generated document can be refreshed. Content controls will be added/updated/deleted and content control's content will be refreshed as per data.&lt;/font&gt; &lt;/li&gt;     &lt;/ol&gt;   &lt;/li&gt;    &lt;li&gt;&lt;font size="2"&gt;Append documents using AltChunk &lt;/font&gt;&lt;/li&gt;    &lt;li&gt;&lt;font size="2"&gt;Protect Document &lt;/font&gt;&lt;/li&gt;    &lt;li&gt;&lt;font size="2"&gt;UnProtect Document &lt;/font&gt;&lt;/li&gt;    &lt;li&gt;&lt;font size="2"&gt;Removal of Content Controls from a document while keeping contents &lt;/font&gt;&lt;/li&gt;    &lt;li&gt;&lt;font size="2"&gt;Removal of Foot notes &lt;/font&gt;&lt;/li&gt;    &lt;li&gt;&lt;font size="2"&gt;Ensuring the each content control has unique Id's by fixing the duplicate Id's if any for a document &lt;/font&gt;&lt;/li&gt;    &lt;li&gt;&lt;font size="2"&gt;Serializing an Object to Xml using XmlSerializer(Used for document generation using data bound content controls as serialized object is written to CustomXmlPart)&lt;/font&gt; &lt;/li&gt; &lt;/ol&gt;  &lt;br /&gt;&lt;b&gt;&lt;font size="2"&gt;Content Controls&lt;/font&gt;&lt;/b&gt;   &lt;ol&gt;   &lt;li&gt;&lt;font size="2"&gt;Set text of a content control(not applicable for data bound content controls) &lt;/font&gt;&lt;/li&gt;    &lt;li&gt;&lt;font size="2"&gt;Get text from a content control(not applicable for data bound content controls) &lt;/font&gt;&lt;/li&gt;    &lt;li&gt;&lt;font size="2"&gt;Set text of content control while keeping PermStart and PermEnd elements(not applicable for data bound content controls) &lt;/font&gt;&lt;/li&gt;    &lt;li&gt;&lt;font size="2"&gt;Set Tag of a content control &lt;/font&gt;&lt;/li&gt;    &lt;li&gt;&lt;font size="2"&gt;Get Tag of a content control &lt;/font&gt;&lt;/li&gt;    &lt;li&gt;&lt;font size="2"&gt;Set data binding of a content control &lt;/font&gt;&lt;/li&gt;    &lt;li&gt;&lt;font size="2"&gt;Set text of a data bound content control from CustomXmlPart manually. This is helpful in cases when CustomXmlPart needs to be removed and this copies the text from the CustomXmlPart node using XPath.&lt;/font&gt; &lt;/li&gt; &lt;/ol&gt;  &lt;br /&gt;&lt;b&gt;&lt;font size="2"&gt;CustomXmlPart&lt;/font&gt;&lt;/b&gt;   &lt;ol&gt;   &lt;li&gt;&lt;font size="2"&gt;Adding a CustomXmlPart to a document &lt;/font&gt;&lt;/li&gt;    &lt;li&gt;&lt;font size="2"&gt;Removing CustomXmlPart from a document &lt;/font&gt;&lt;/li&gt;    &lt;li&gt;&lt;font size="2"&gt;Getting CustomXmlPart from a document &lt;/font&gt;&lt;/li&gt;    &lt;li&gt;&lt;font size="2"&gt;Add/Update a Xml element node inside CustomXmlPart. This is required &lt;/font&gt;      &lt;ol&gt;       &lt;li&gt;&lt;font size="2"&gt;To keep Document related metadata e.g. Document type, version etc. &lt;/font&gt;&lt;/li&gt;        &lt;li&gt;&lt;font size="2"&gt;To make the Document self-refreshable. In this case the container content control is persisted inside a Placeholder node, the first time document is generated from template. Onwards when refreshing document we fetch the container content control from CustomXmlPart &lt;/font&gt;&lt;/li&gt;        &lt;li&gt;&lt;font size="2"&gt;Saving the Xml e.g. serialized object which will be the data store for data bound content controls&lt;/font&gt; &lt;/li&gt;     &lt;/ol&gt;   &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;&lt;font size="2"&gt;&lt;em&gt;&lt;strong&gt;Sample Generators:&lt;/strong&gt;&lt;/em&gt;&lt;/font&gt;&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;&lt;font size="2"&gt;&lt;strong&gt;SampleDocumentGenerator:&lt;/strong&gt; This sample shows how to generate a non-refreshable document from a template. The content controls are populated using C# code i.e. not using data bound content controls. It covers both direct assignment as well as recursive controls. The screenshot is &lt;/font&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-37-36-metablogapi/0876.image_5F00_1003202C.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-37-36-metablogapi/2845.image_5F00_thumb_5F00_78F49EEF.png" width="444" height="272" /&gt;&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;font size="2"&gt;&lt;strong&gt;SampleRefreshableDocumentGenerator:&lt;/strong&gt; This sample shows how to generate a refreshable document from a template. The content controls are populated using C# code i.e. not using data bound content controls. This is similar to SampleDocumentGenerator in implementation. Only difference is the generated document can be refreshed in this case. The screenshot is &lt;/font&gt;&lt;a&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/a&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-37-36-metablogapi/5483.image_5F00_4F9D56F1.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-37-36-metablogapi/0602.image_5F00_thumb_5F00_7309D589.png" width="493" height="251" /&gt;&lt;/a&gt;&lt;/a&gt;&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;font size="2"&gt;&lt;strong&gt;SampleDocumentWithTableGenerator:&lt;/strong&gt; This sample shows how to generate a refreshable document from a template having Table. The content controls are populated using C# code i.e. not using data bound controls. This is similar to to SampleRefreshableDocumentGenerator in implementation. Only difference is the template has an additional table. The screenshot is &lt;/font&gt;&lt;a&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/a&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-37-36-metablogapi/6644.image_5F00_5065970E.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-37-36-metablogapi/8713.image_5F00_thumb_5F00_08C3981A.png" width="497" height="257" /&gt;&lt;/a&gt;&lt;/a&gt;&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;font size="2"&gt;&lt;strong&gt;SampleDocumentGeneratorUsingDatabinding:&lt;/strong&gt; This sample shows how to generate a refreshable document from a template using data bound content controls. This requires that each of the placeholder(template’s content control) has a predefined XPath. The generated document is similar to SampleRefreshableDocumentGenerator.&lt;/font&gt; &lt;/li&gt;    &lt;li&gt;&lt;font size="2"&gt;&lt;strong&gt;SampleDocumentWithTableGeneratorUsingDatabinding:&lt;/strong&gt; This sample shows how to generate a refreshable document from a template having table using data bound content controls. This requires that each of the placeholder(template’s content control) has a predefined XPath. The generated document is similar to SampleDocumentWithTableGenerator.&lt;/font&gt; &lt;/li&gt;    &lt;li&gt;&lt;font size="2"&gt;&lt;strong&gt;SampleDocumentGeneratorUsingXml&lt;/strong&gt; (New): This sample shows how to generate a document from a template using XmlNode as data. This approach shows that a generic generator can be created which requires Xml as data. This requires that XPath for Tag as well as content needs to be provided. The content controls are populated using C# code i.e. not using data bound controls. It covers both direct assignment as well as recursive controls. The generated document is similar to SampleDocumentGenerator.&lt;/font&gt; &lt;/li&gt;    &lt;li&gt;&lt;font size="2"&gt;&lt;strong&gt;SampleDocumentGeneratorUsingXmlAndDatabinding&lt;/strong&gt; (New): This sample shows how to generate a document from a template using XmlNode as data and data bound content controls. This approach shows that a generic generator can be created which requires Xml as data. This requires that XPath for Tag as well as content needs to be provided. It covers both direct assignment as well as recursive controls. The generated document is similar to SampleDocumentGenerator.&lt;/font&gt; &lt;/li&gt; &lt;/ol&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10254325" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/atverma/archive/tags/-NET/">.NET</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/Visual+Studio+2010/">Visual Studio 2010</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/Word+2007/">Word 2007</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/Word+2010/">Word 2010</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/Open+Xml+2-0+SDK/">Open Xml 2.0 SDK</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/Content+Controls/">Content Controls</category></item><item><title>Utility to generate Word documents from templates using Visual Studio 2010 and Open Xml 2.0 SDK</title><link>http://blogs.msdn.com/b/atverma/archive/2011/12/31/utility-to-generate-word-documents-from-templates-using-visual-studio-2010-and-open-xml-2-0-sdk.aspx</link><pubDate>Sat, 31 Dec 2011 18:10:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10252264</guid><dc:creator>Atul.Verma</dc:creator><slash:comments>18</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/atverma/rsscomments.aspx?WeblogPostID=10252264</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/atverma/commentapi.aspx?WeblogPostID=10252264</wfw:comment><comments>http://blogs.msdn.com/b/atverma/archive/2011/12/31/utility-to-generate-word-documents-from-templates-using-visual-studio-2010-and-open-xml-2-0-sdk.aspx#comments</comments><description>&lt;p&gt;&lt;font size="2"&gt;&lt;span style="font-size: x-small" size="2"&gt;&lt;font size="2"&gt;This utility generates Word documents from templates using Content controls. &lt;/font&gt;&lt;/span&gt;&lt;span style="font-size: x-small" size="2"&gt;&lt;font size="2"&gt;The utility source code is available for download at &lt;/font&gt;&lt;a title="http://worddocgenerator.codeplex.com/" href="http://worddocgenerator.codeplex.com/"&gt;&lt;font size="2"&gt;http://worddocgenerator.codeplex.com/&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt;&lt;span style="font-size: x-small" size="2"&gt;. &lt;font size="2"&gt;It has been created in Visual Studio 2010 and uses Open Xml 2.0 SDK which can be downloaded from &lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;a href="http://www.microsoft.com/download/en/details.aspx?id=5124"&gt;&lt;span style="font-size: x-small" size="2"&gt;&lt;font size="2"&gt;http://www.microsoft.com/download/en/details.aspx?id=5124&lt;/font&gt;&lt;/span&gt;&lt;/a&gt;&lt;span style="font-size: x-small" size="2"&gt;&lt;font size="2"&gt;. &lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: x-small" size="2"&gt;&lt;span style="font-size: x-small" size="2"&gt;&lt;font size="2"&gt;The next parts in this series are&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;font size="2"&gt;In &lt;/font&gt;&lt;a href="http://blogs.msdn.com/b/atverma/archive/2012/01/08/utility-to-generate-word-documents-from-templates-using-visual-studio-2010-and-open-xml-2-0-sdk-part-2-samples-updated.aspx" target="_blank"&gt;&lt;font size="2"&gt;Part 2&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt; I have discussed about&lt;/font&gt;       &lt;ul&gt;       &lt;li&gt;&lt;font size="2"&gt;List of functionalities that can be achieved using the utility/source code &lt;/font&gt;&lt;/li&gt;        &lt;li&gt;&lt;font size="2"&gt;Description regarding Samples provided with utility &lt;/font&gt;&lt;/li&gt;        &lt;li&gt;&lt;font size="2"&gt;New samples added in this update &lt;/font&gt;&lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt;    &lt;li&gt;&lt;font size="2"&gt;In &lt;/font&gt;&lt;a href="http://blogs.msdn.com/b/atverma/archive/2012/01/11/utility-to-generate-word-documents-from-templates-using-visual-studio-2010-and-open-xml-2-0-sdk-part-3.aspx" target="_blank"&gt;&lt;font size="2"&gt;Part 3&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt; I have explained one of the way to “Refresh the document from within the document(e.g. right click on document and click Refresh) using document-level projects for Word 2007 and Word 2010“ &lt;/font&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;span style="font-size: x-small" size="2"&gt;&lt;font size="2"&gt;The purpose of creating this utility was to use the Open Xml 2.0 SDK to generate Word documents based on predefined templates using minimum code changes. These documents can either be refreshable or non- refreshable. I’ll explain this difference later. Also there is no dependency that Word should be installed.&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: x-small" size="2"&gt;&lt;font size="2"&gt;A few samples for generating Word 2010 documents have been provided. The screenshots below display the sample template and the document generated out of this template using this utility.&lt;/font&gt;&lt;/span&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;Word 2010 Template –&amp;gt; Generated Document:&lt;/h3&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-37-36-metablogapi/2313.3_5F00_4403E92E.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="3" border="0" alt="3" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-37-36-metablogapi/5047.3_5F00_thumb_5F00_59FA2EF3.png" width="607" height="313" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;h3&gt;&amp;#160;&lt;/h3&gt;  &lt;h3&gt;Word 2010 Template –&amp;gt; Generated Document –&amp;gt; Refreshed Document:&lt;/h3&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-37-36-metablogapi/2804.1_5F00_540F658D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="1" border="0" alt="1" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-37-36-metablogapi/1212.1_5F00_thumb_5F00_1B24E5F3.png" width="614" height="311" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;&lt;b&gt;Document Refresh from within Word &lt;/b&gt;–&amp;gt; Refreshed Document:&lt;/h3&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-37-36-metablogapi/8640.2_5F00_7AF9B368.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="2" border="0" alt="2" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-37-36-metablogapi/6082.2_5F00_thumb_5F00_3E813EBE.png" width="617" height="433" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;h3&gt;&amp;#160;&lt;/h3&gt;  &lt;h3&gt;Template Design:&lt;/h3&gt;  &lt;p&gt;&lt;span style="font-size: x-small" size="2"&gt;&lt;font size="2"&gt;The sample templates are inside “WordDocumentGenerator.Client\Sample Templates” folder. A content control as displayed below can have Title and Tag properties.&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-37-36-metablogapi/1856.clip_5F00_image003_5F00_02C696C9.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="clip_image003" border="0" alt="clip_image003" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-37-36-metablogapi/7711.clip_5F00_image003_5F00_thumb_5F00_1BE1F101.png" width="397" height="435" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: x-small" size="2"&gt;&lt;font size="2"&gt;The logic is to have a tag property of a content control and then populate data using that placeholder. This means every content control inside a Word template will have a different Tag. &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: x-small" size="2"&gt;&lt;font size="2"&gt;As per image above the tag of the content control is “PlaceholderNonRecursiveB”. During document generation we can assign (not mandatory) a unique Id e.g. Guid of a record to make the tag unique e.g. “PlaceholderNonRecursiveB:Guid”. Let’s say that we have an Id and Name field. Thus the Name will be the content of the control and tag will be “PlaceholderNonRecursiveB:Id”. As per Word 2010 the Tag maximum length is 64.&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-size: x-small" size="2"&gt;&lt;font size="2"&gt;In code we map the tag to the PlaceHolderType enum. &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;   &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;     &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;public enum PlaceHolderType&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;        None = 0,&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;        Recursive = 1,&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;        NonRecursive = 2,&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;        Ignore = 3,&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;        Container = 4    &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;pre&gt;&lt;font size="2" face="Segoe UI"&gt;There can be multiple types of PlaceHolders&lt;/font&gt;&lt;/pre&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;font size="2"&gt;Recursive: This type corresponds to controls where there is 1:N relation between template and data i.e. one example will be repeating a list of Items.&lt;/font&gt; &lt;/li&gt;

  &lt;li&gt;&lt;font size="2"&gt;Non-Recursive: This type corresponds to controls where there is 1:1 relation between template and data i.e. one example will be showing a User name.&lt;/font&gt; &lt;/li&gt;

  &lt;li&gt;&lt;font size="2"&gt;Ignore: No action is required for these controls.&lt;/font&gt; &lt;/li&gt;

  &lt;li&gt;&lt;font size="2"&gt;Container: This type is required only for refreshable documents. We save the container region in CustomXmlPart the first time document is generated from template. Next time onwards we retrieve the container region that was saved and refresh the document. This makes the document self-refreshable.&lt;/font&gt; &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;font size="2"&gt;I’ve named the tags in “Test_Template – 1.docx” as per their PlaceHolder type to make it more clear.&lt;/font&gt;&lt;/p&gt;

&lt;h3&gt;Implementation:&lt;/h3&gt;

&lt;p&gt;&lt;font size="2"&gt;As explained above the Tag property will used to bind data to this content control. The project “WordDocumentGenerator.Library” is the utility library. The project “WordDocumentGenerator.Client” shows how this library can be used to generate documents.&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;&lt;font size="2"&gt;“DocumentGenerator” is the base class that needs to be inherited by the document generators. The sample generators location is “WordDocumentGenerator.Client\Sample Document Generators”.&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;&lt;font size="2"&gt;In order to protect the document I’ve used already created salt and hash. For an implementation where one needs to have document protection enabled for custom passwords one can view &lt;/font&gt;&lt;a href="http://blogs.msdn.com/b/vsod/archive/2010/04/05/how-to-set-the-editing-restrictions-in-word-using-open-xml-sdk-2-0.aspx"&gt;&lt;font size="2"&gt;http://blogs.msdn.com/b/vsod/archive/2010/04/05/how-to-set-the-editing-restrictions-in-word-using-open-xml-sdk-2-0.aspx&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;Summary:&lt;/h3&gt;

&lt;p&gt;&lt;font size="2"&gt;The purpose of creating this utility was to use the Open Xml 2.0 SDK to generate Word documents based on predefined templates using minimum code changes. These documents can either be refreshable or non- refreshable. New samples will be added as per feedback.&lt;/font&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10252264" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/atverma/archive/tags/-NET/">.NET</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/Visual+Studio+2010/">Visual Studio 2010</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/Word+2007/">Word 2007</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/Word+2010/">Word 2010</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/Open+Xml+2-0+SDK/">Open Xml 2.0 SDK</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/Content+Controls/">Content Controls</category></item><item><title>How to upload/download a document in SharePoint 2010 using Client Context Object Model</title><link>http://blogs.msdn.com/b/atverma/archive/2010/10/27/how-to-upload-download-a-document-in-sharepoint-2010-using-client-context-object-model.aspx</link><pubDate>Wed, 27 Oct 2010 08:47:20 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10081397</guid><dc:creator>Atul.Verma</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/atverma/rsscomments.aspx?WeblogPostID=10081397</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/atverma/commentapi.aspx?WeblogPostID=10081397</wfw:comment><comments>http://blogs.msdn.com/b/atverma/archive/2010/10/27/how-to-upload-download-a-document-in-sharepoint-2010-using-client-context-object-model.aspx#comments</comments><description>&lt;div id="codeSnippetWrapper"&gt;&lt;/div&gt; In order to use ClientContext I need to add reference to two dll’s to my project i.e. Microsoft.SharePoint.Client.dll and Microsoft.SharePoint.Client.Runtime.dll.   &lt;br /&gt;In this blog I’ll display how to   &lt;br /&gt;  &lt;ul&gt;   &lt;li&gt;Get ListItemCollection from SharePoint document list using CAML &lt;/li&gt;    &lt;li&gt;Upload a document to SharePoint Document list &lt;/li&gt;    &lt;li&gt;Download a document from SharePoint Document list      &lt;br /&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;h3&gt;&lt;/h3&gt;  &lt;h3&gt;Get ListItemCollection from SharePoint Document list using CAML:&lt;/h3&gt;  &lt;p&gt;I can get the ListItemCollection as displayed in code snippets below&lt;/p&gt;  &lt;div&gt;   &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;ListItemCollection listItems = GetListItemCollectionFromSP(&lt;span style="color: #006080"&gt;&amp;quot;FileLeafRef&amp;quot;&lt;/span&gt;,&lt;br /&gt;                                                            documentName, &lt;br /&gt;                                                            &lt;span style="color: #006080"&gt;&amp;quot;Text&amp;quot;&lt;/span&gt;,&lt;br /&gt;                                                            1);&lt;/pre&gt;
&lt;/div&gt;

&lt;div&gt;&amp;#160;&lt;/div&gt;

&lt;div&gt;The GetListItemCollectionFromSP returns the List item and the parameters to method are 
  &lt;br /&gt;name –&amp;gt; Name of the FieldRef,&lt;/div&gt;

&lt;div&gt;value –&amp;gt; value to match for that FieldRef,&lt;/div&gt;

&lt;div&gt;type –&amp;gt; Type of the value&lt;/div&gt;

&lt;div&gt;rowLimit –&amp;gt; Maximum number of rows to fetch&lt;/div&gt;

&lt;div&gt;&amp;#160;&lt;/div&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; ListItemCollection GetListItemCollectionFromSP(&lt;span style="color: #0000ff"&gt;string&lt;/span&gt; name, &lt;br /&gt;                                                              &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; &lt;span style="color: #0000ff"&gt;&lt;font color="#000000"&gt;value&lt;/font&gt;&lt;/span&gt;,&lt;br /&gt;                                                              &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; type,&lt;br /&gt;                                                              &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; rowLimit)&lt;br /&gt;{&lt;br /&gt;&lt;span style="color: #008000"&gt;//Replace siteURL and documentListName with &lt;/span&gt;&lt;br /&gt;&lt;span style="color: #008000"&gt;//your SharePoint site URL and DocumentList&lt;/span&gt;&lt;br /&gt;ListItemCollection listItems = &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;string&lt;/span&gt; siteURL = &lt;span style="color: #006080"&gt;&amp;quot;site URL&amp;quot;&lt;/span&gt;;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;string&lt;/span&gt; documentListName = &lt;span style="color: #006080"&gt;&amp;quot;document list&amp;quot;&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;using&lt;/span&gt; (ClientContext clientContext = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; ClientContext(siteURL))&lt;br /&gt;{&lt;br /&gt;List documentsList = clientContext.Web.Lists.GetByTitle(documentListName);&lt;br /&gt; &lt;br /&gt;CamlQuery camlQuery = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; CamlQuery(); ;&lt;br /&gt;camlQuery.ViewXml =&lt;br /&gt;&lt;span style="color: #006080"&gt;@&amp;quot;&amp;lt;View&amp;gt;&lt;br /&gt;&amp;lt;Query&amp;gt;&lt;br /&gt;&amp;lt;Where&amp;gt;&lt;br /&gt;&amp;lt;Eq&amp;gt;&lt;br /&gt;&amp;lt;FieldRef Name='&amp;quot;&lt;/span&gt; + name + &lt;span style="color: #006080"&gt;@&amp;quot;'/&amp;gt;&lt;br /&gt;&amp;lt;Value Type='&amp;quot;&lt;/span&gt; + type + &lt;span style="color: #006080"&gt;&amp;quot;'&amp;gt;&amp;quot;&lt;/span&gt; + &lt;span style="color: #0000ff"&gt;value&lt;/span&gt; + &lt;span style="color: #006080"&gt;@&amp;quot;&amp;lt;/Value&amp;gt;&lt;br /&gt;&amp;lt;/Eq&amp;gt;&lt;br /&gt;&amp;lt;/Where&amp;gt;                    &lt;br /&gt;&amp;lt;RowLimit&amp;gt;&amp;quot;&lt;/span&gt; + rowLimit.ToString() + &lt;span style="color: #006080"&gt;@&amp;quot;&amp;lt;/RowLimit&amp;gt;&lt;br /&gt;&amp;lt;/Query&amp;gt;&lt;br /&gt;&amp;lt;/View&amp;gt;&amp;quot;&lt;/span&gt;;&lt;br /&gt; &lt;br /&gt;listItems = documentsList.GetItems(camlQuery);&lt;br /&gt;clientContext.Load(documentsList);&lt;br /&gt;clientContext.Load(listItems);&lt;br /&gt;clientContext.ExecuteQuery();&lt;br /&gt;}&lt;br /&gt; &lt;br /&gt;&lt;span style="color: #0000ff"&gt;return&lt;/span&gt; listItems;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;h3&gt;Upload a document to SharePoint Document List:&lt;/h3&gt;

&lt;p&gt;In this case I want to upload a document to SharePoint document list and also update the field metadata i.e. for field “DocType” to “Favourites” as in this example using ClientContext. The code snippet is displayed below&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; UploadDocument(&lt;span style="color: #0000ff"&gt;string&lt;/span&gt; siteURL, &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; documentListName,&lt;br /&gt;&lt;span style="color: #0000ff"&gt;string&lt;/span&gt; documentListURL, &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; documentName,&lt;br /&gt;&lt;span style="color: #0000ff"&gt;byte&lt;/span&gt;[] documentStream)&lt;br /&gt;{&lt;br /&gt;&lt;span style="color: #0000ff"&gt;using&lt;/span&gt; (ClientContext clientContext = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; ClientContext(siteURL))&lt;br /&gt;{        &lt;br /&gt;&lt;span style="color: #008000"&gt;//Get Document List&lt;/span&gt;&lt;br /&gt;List documentsList = clientContext.Web.Lists.GetByTitle(documentListName);&lt;br /&gt;var fileCreationInformation = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; FileCreationInformation();&lt;br /&gt;&lt;span style="color: #008000"&gt;//Assign to content byte[] i.e. documentStream&lt;/span&gt;&lt;br /&gt;fileCreationInformation.Content = documentStream;&lt;br /&gt;&lt;span style="color: #008000"&gt;//Allow owerwrite of document&lt;/span&gt;&lt;br /&gt;fileCreationInformation.Overwrite = &lt;span style="color: #0000ff"&gt;true&lt;/span&gt;;&lt;br /&gt;&lt;span style="color: #008000"&gt;//Upload URL&lt;/span&gt;&lt;br /&gt;fileCreationInformation.Url = siteURL + documentListURL + documentName;&lt;br /&gt;Microsoft.SharePoint.Client.File uploadFile = &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;;&lt;br /&gt;uploadFile = documentsList.RootFolder.Files.Add(fileCreationInformation);&lt;br /&gt;&lt;span style="color: #008000"&gt;//Update the metadata for a field having name &amp;quot;DocType&amp;quot;&lt;/span&gt;&lt;br /&gt;uploadFile.ListItemAllFields[&lt;span style="color: #006080"&gt;&amp;quot;DocType&amp;quot;&lt;/span&gt;] = &lt;span style="color: #006080"&gt;&amp;quot;Favourites&amp;quot;&lt;/span&gt;;&lt;br /&gt;uploadFile.ListItemAllFields.Update();&lt;br /&gt;clientContext.ExecuteQuery();&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;h3&gt;&lt;/h3&gt;

&lt;h3&gt;Download a document from SharePoint Document List:&lt;/h3&gt;
I can download the document using the code snippets displayed below 

&lt;br /&gt;

&lt;div id="codeSnippetWrapper"&gt;&amp;#160;&lt;/div&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; Stream DownloadDocument(&lt;span style="color: #0000ff"&gt;string&lt;/span&gt; siteURL, &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; documentName)&lt;br /&gt;{&lt;br /&gt;ListItem item = GetDocumentFromSP(documentName);&lt;br /&gt;&lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (item != &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;)&lt;br /&gt;{&lt;br /&gt;&lt;span style="color: #0000ff"&gt;using&lt;/span&gt; (ClientContext clientContext = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; ClientContext(siteURL))&lt;br /&gt;{&lt;br /&gt;FileInformation fInfo = Microsoft.SharePoint.Client.File.OpenBinaryDirect(&lt;br /&gt;clientContext, item [&lt;span style="color: #006080"&gt;&amp;quot;FileRef&amp;quot;&lt;/span&gt;].ToString()); &lt;br /&gt;&lt;span style="color: #0000ff"&gt;return&lt;/span&gt; fInfo.Stream;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;span style="color: #0000ff"&gt;return&lt;/span&gt; &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;;&lt;br /&gt;}&lt;br /&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; ListItem GetDocumentFromSP(&lt;span style="color: #0000ff"&gt;string&lt;/span&gt; documentName)&lt;br /&gt;{&lt;br /&gt;&lt;span style="color: #008000"&gt;// This method is discussed above i.e. &lt;/span&gt;&lt;br /&gt;&lt;span style="color: #008000"&gt;// Get List Item Collection from SharePoint Document List&lt;/span&gt;&lt;br /&gt;ListItemCollection listItems = &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;;&lt;br /&gt;listItems = GetListItemCollectionFromSP(&lt;span style="color: #006080"&gt;&amp;quot;FileLeafRef&amp;quot;&lt;/span&gt;, &lt;br /&gt;                                        documentName, &lt;br /&gt;                                        &lt;span style="color: #006080"&gt;&amp;quot;Text&amp;quot;&lt;/span&gt;, 1);&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;return&lt;/span&gt; (listItems != &lt;span style="color: #0000ff"&gt;null&lt;/span&gt; &amp;amp;&amp;amp; listItems.Count == 1) ? listItems[0] : &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;div&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10081397" width="1" height="1"&gt;</description></item><item><title>How to test a class member that is not public using Visual Studio 2010</title><link>http://blogs.msdn.com/b/atverma/archive/2010/09/17/how-to-test-a-class-member-that-is-not-public-using-visual-studio-2010.aspx</link><pubDate>Thu, 16 Sep 2010 23:31:38 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10063612</guid><dc:creator>Atul.Verma</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/atverma/rsscomments.aspx?WeblogPostID=10063612</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/atverma/commentapi.aspx?WeblogPostID=10063612</wfw:comment><comments>http://blogs.msdn.com/b/atverma/archive/2010/09/17/how-to-test-a-class-member-that-is-not-public-using-visual-studio-2010.aspx#comments</comments><description>&lt;p&gt;There are various ways to test a Class member which is not public&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;By making the private members public of a class under test      &lt;ul&gt;       &lt;li&gt;Breaks the encapsulation principle &lt;/li&gt;        &lt;li&gt;API is modified just for the sake of testing &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt;    &lt;li&gt;By making the private members internal of a class under test and annotate the assembly with internalsVisibleTo attribute and you can read more about it at &lt;a href="http://msdn.microsoft.com/en-us/library/0tke9fxk.aspx" target="_blank"&gt;http://msdn.microsoft.com/en-us/library/0tke9fxk.aspx&lt;/a&gt;       &lt;ul&gt;       &lt;li&gt;Breaks the encapsulation principle &lt;/li&gt;        &lt;li&gt;API is modified just for the sake of testing &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt;    &lt;li&gt;Make the private members reachable through a public member of a class under test and test these public members      &lt;ul&gt;       &lt;li&gt;Breaks the encapsulation principle &lt;/li&gt;        &lt;li&gt;API is modified just for the sake of testing &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt;    &lt;li&gt;Use reflection to invoke the non public members of a class under test &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Using reflection is abstracted in Visual Studio so we can use&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;PrivateObject to access non public Instance members of a class under test &lt;/li&gt;    &lt;li&gt;PrivateType to access static members of a class under test &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;These classes are inside Microsoft.VisualStudio.TestTools.UnitTesting namespace. I have created code snippets in Visual Studio 2010.&lt;/p&gt;  &lt;h3&gt;PrivateObject:&lt;/h3&gt;  &lt;p&gt;PrivateObject class is used to access instance based members of&amp;#160; a class under test. The methods and properties of this class are displayed below&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/6574.image_5F00_1214EB49.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/8255.image_5F00_thumb_5F00_723661C0.png" width="264" height="358" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;e.g. We have a BankAccount class that contains a private method i.e. VerifyAmount as displayed below&lt;/p&gt;  &lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;   &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;     &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; BankAccount&lt;/pre&gt;
&lt;!--crlf--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--crlf--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #008000"&gt;//Private method to test&lt;/span&gt;&lt;/pre&gt;
&lt;!--crlf--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; VerifyAmount(&lt;span style="color: #0000ff"&gt;double&lt;/span&gt; amount)&lt;/pre&gt;
&lt;!--crlf--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    {&lt;/pre&gt;
&lt;!--crlf--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; (amount &amp;lt;= 1000);&lt;/pre&gt;
&lt;!--crlf--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    }&lt;/pre&gt;
&lt;!--crlf--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--crlf--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;In order to unit test VerifyAmount method using PrivateObject class the code is displayed below&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;[TestMethod()]        &lt;/pre&gt;
&lt;!--crlf--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; VerifyAmountTest()&lt;/pre&gt;
&lt;!--crlf--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--crlf--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #008000"&gt;//Using PrivateObject class&lt;/span&gt;&lt;/pre&gt;
&lt;!--crlf--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    PrivateObject privateHelperObject = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; PrivateObject(&lt;span style="color: #0000ff"&gt;typeof&lt;/span&gt;(BankAccount));                             &lt;/pre&gt;
&lt;!--crlf--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;double&lt;/span&gt; amount = 500F;&lt;/pre&gt;
&lt;!--crlf--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; expected = &lt;span style="color: #0000ff"&gt;true&lt;/span&gt;;&lt;/pre&gt;
&lt;!--crlf--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; actual;&lt;/pre&gt;
&lt;!--crlf--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    actual = (&lt;span style="color: #0000ff"&gt;bool&lt;/span&gt;)privateHelperObject.Invoke(&lt;span style="color: #006080"&gt;&amp;quot;VerifyAmount&amp;quot;&lt;/span&gt;, amount);            &lt;/pre&gt;
&lt;!--crlf--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    Assert.AreEqual(expected, actual);            &lt;/pre&gt;
&lt;!--crlf--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;h3&gt;&amp;#160;&lt;/h3&gt;

&lt;h3&gt;PrivateType:&lt;/h3&gt;

&lt;p&gt;PrivateType class is used to access the static non public members of a class under test. The methods and properties of this class are displayed below&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/2313.image_5F00_714DD609.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/7674.image_5F00_thumb_5F00_5C0FAA94.png" width="274" height="285" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;e.g. We have a BankAccount class that contains a private static method i.e. VerifyAmount as displayed below&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; BankAccount&lt;/pre&gt;
&lt;!--crlf--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--crlf--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #008000"&gt;//Private static method under test&lt;/span&gt;&lt;/pre&gt;
&lt;!--crlf--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; &lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; VerifyAmount(&lt;span style="color: #0000ff"&gt;double&lt;/span&gt; amount)&lt;/pre&gt;
&lt;!--crlf--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    {&lt;/pre&gt;
&lt;!--crlf--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; (amount &amp;lt;= 2000);&lt;/pre&gt;
&lt;!--crlf--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    }&lt;/pre&gt;
&lt;!--crlf--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;In order to unit test VerifyAmount method using PrivateType class the code is displayed below&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;[TestMethod()]        &lt;/pre&gt;
&lt;!--crlf--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; VerifyAmountTest()&lt;/pre&gt;
&lt;!--crlf--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--crlf--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    PrivateType privateHelperType = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; PrivateType(&lt;span style="color: #0000ff"&gt;typeof&lt;/span&gt;(BankAccount));                             &lt;/pre&gt;
&lt;!--crlf--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;double&lt;/span&gt; amount = 1000F;&lt;/pre&gt;
&lt;!--crlf--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; expected = &lt;span style="color: #0000ff"&gt;true&lt;/span&gt;;&lt;/pre&gt;
&lt;!--crlf--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; actual;&lt;/pre&gt;
&lt;!--crlf--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    actual = (&lt;span style="color: #0000ff"&gt;bool&lt;/span&gt;)privateHelperType.InvokeStatic(&lt;span style="color: #006080"&gt;&amp;quot;VerifyAmount&amp;quot;&lt;/span&gt;, amount);            &lt;/pre&gt;
&lt;!--crlf--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    Assert.AreEqual(expected, actual);            &lt;/pre&gt;
&lt;!--crlf--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;h3&gt;&amp;#160;&lt;/h3&gt;

&lt;p&gt;In both the cases displayed above i.e. PrivateObject and PrivateType the method names are hardcoded. In order to avoid hard coding Visual Studio provides an option to create private accessor as displayed below where PrivateBanking is the name of the project.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/2728.image_5F00_3893062F.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/5554.image_5F00_thumb_5F00_614E6B78.png" width="534" height="208" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Private Accessor automatically gets created when creating unit tests as displayed below&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/8203.image_5F00_650C1048.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/6567.image_5F00_thumb_5F00_6282DE8A.png" width="598" height="291" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;In the test project under Test References you can now see PrivateBanking.accessor as displayed below&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/2843.image_5F00_3CE93B5C.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/0020.image_5F00_thumb_5F00_48324F99.png" width="282" height="149" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;The unit tests using the private accesser for class BankAccount as displayed below where BankAccount_Accessor is the class publicizes the BankAccount class and it derives from BaseShadow class.&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;//To test non public Instance member&lt;/span&gt;&lt;/pre&gt;
&lt;!--crlf--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;[TestMethod()]&lt;/pre&gt;
&lt;!--crlf--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;[DeploymentItem(&lt;span style="color: #006080"&gt;&amp;quot;PrivateBanking.dll&amp;quot;&lt;/span&gt;)]&lt;/pre&gt;
&lt;!--crlf--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; VerifyAmountTest1()&lt;/pre&gt;
&lt;!--crlf--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--crlf--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    BankAccount_Accessor target = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; BankAccount_Accessor(); &lt;span style="color: #008000"&gt;// TODO: Initialize to an appropriate value&lt;/span&gt;&lt;/pre&gt;
&lt;!--crlf--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; amount = 10; &lt;span style="color: #008000"&gt;// TODO: Initialize to an appropriate value&lt;/span&gt;&lt;/pre&gt;
&lt;!--crlf--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; expected = &lt;span style="color: #0000ff"&gt;true&lt;/span&gt;; &lt;span style="color: #008000"&gt;// TODO: Initialize to an appropriate value&lt;/span&gt;&lt;/pre&gt;
&lt;!--crlf--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; actual;&lt;/pre&gt;
&lt;!--crlf--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    actual = target.VerifyAmount(amount);&lt;/pre&gt;
&lt;!--crlf--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    Assert.AreEqual(expected, actual);            &lt;/pre&gt;
&lt;!--crlf--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--crlf--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--crlf--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;//To test non public static member&lt;/span&gt;&lt;/pre&gt;
&lt;!--crlf--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;[TestMethod()]&lt;/pre&gt;
&lt;!--crlf--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;[DeploymentItem(&lt;span style="color: #006080"&gt;&amp;quot;PrivateBanking.dll&amp;quot;&lt;/span&gt;)]&lt;/pre&gt;
&lt;!--crlf--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; VerifyAmountTest()&lt;/pre&gt;
&lt;!--crlf--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--crlf--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;double&lt;/span&gt; amount = 10F; &lt;span style="color: #008000"&gt;// TODO: Initialize to an appropriate value&lt;/span&gt;&lt;/pre&gt;
&lt;!--crlf--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; expected = &lt;span style="color: #0000ff"&gt;true&lt;/span&gt;; &lt;span style="color: #008000"&gt;// TODO: Initialize to an appropriate value&lt;/span&gt;&lt;/pre&gt;
&lt;!--crlf--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; actual;&lt;/pre&gt;
&lt;!--crlf--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    actual = BankAccount_Accessor.VerifyAmount(amount);&lt;/pre&gt;
&lt;!--crlf--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    Assert.AreEqual(expected, actual);           &lt;/pre&gt;
&lt;!--crlf--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;As we are using the accessor now no hard coding is required for method names as displayed in code snippet above. The BankAccount_Accessor class is displayed below&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/3240.image_5F00_6557F7A3.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/6404.image_5F00_thumb_5F00_0930A931.png" width="457" height="509" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;The BaseShadow class is used by the publicize method to help test private types and is displayed below&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/2625.image_5F00_1873E573.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/6825.image_5F00_thumb_5F00_436BD378.png" width="327" height="427" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;This concludes the article on how to unit test non public members using Visual Studio 2010.&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:f23857e5-1ed0-4232-aa1d-d523c6245719" class="wlWriterEditableSmartContent"&gt;del.icio.us Tags: &lt;a href="http://del.icio.us/popular/visual+Studio+2010" rel="tag"&gt;visual Studio 2010&lt;/a&gt;,&lt;a href="http://del.icio.us/popular/unit+Test" rel="tag"&gt;unit Test&lt;/a&gt;,&lt;a href="http://del.icio.us/popular/Non+public+member" rel="tag"&gt;Non public member&lt;/a&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10063612" width="1" height="1"&gt;</description></item><item><title>How to unit test SQL Server 2008 database using Visual Studio 2010 – Part 3</title><link>http://blogs.msdn.com/b/atverma/archive/2010/08/22/how-to-unit-test-sql-server-2008-database-using-visual-studio-2010-part-3.aspx</link><pubDate>Sun, 22 Aug 2010 22:37:28 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10052974</guid><dc:creator>Atul.Verma</dc:creator><slash:comments>6</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/atverma/rsscomments.aspx?WeblogPostID=10052974</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/atverma/commentapi.aspx?WeblogPostID=10052974</wfw:comment><comments>http://blogs.msdn.com/b/atverma/archive/2010/08/22/how-to-unit-test-sql-server-2008-database-using-visual-studio-2010-part-3.aspx#comments</comments><description>&lt;p&gt;This is the last article of the series “How to unit test SQL Server 2008 database using Visual Studio 2010”. The previous articles are&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/b/atverma/archive/2010/07/28/how-to-unit-test-sql-server-2008-database-using-visual-studio-2010.aspx" target="_blank"&gt;Unit test SQL Server 2008 - Part 1&lt;/a&gt; – Focused on setting up environment, creating database project and executing simple unit tests&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/b/atverma/archive/2010/08/22/how-to-unit-test-sql-server-2008-database-using-visual-studio-2010-part-2.aspx" target="_blank"&gt;Unit test SQL Server 2008 - Part 2&lt;/a&gt; – Focused on internals of database unit testing i.e. assemblies&lt;/p&gt; &lt;p&gt;I’ll divide this article into two logical parts&lt;/p&gt; &lt;ul&gt; &lt;li&gt; &lt;p&gt;Tools that are useful for creation of test data as well as ensuring that database schemas are synchronized&lt;/p&gt; &lt;ul&gt; &lt;li&gt; &lt;p&gt;Data generation&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;Schema comparison&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;Data comparison&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;More about unit testing a database which include &lt;/p&gt; &lt;ul&gt; &lt;li&gt; &lt;p&gt;Data driven unit tests&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;Pre, test and post scripts&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;Test conditions&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;Transactions&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt; &lt;h3&gt;Data Generation Plan:&lt;/h3&gt; &lt;p&gt;Test data is created for verifying the behaviour of database objects in a database project. Generating data that is appropriate for the schema of the database but unrelated to the production data helps protect the privacy or security of the production data. Data generation plan can be added to the database project as displayed below&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/6888.image_5F00_3853CFE5.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/8561.image_5F00_thumb_5F00_5C98B467.png" width="627" height="396" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;When data generation plan is created for a database project, the plan is based on the schema of the project. If after creation of the plan schema changes, Visual Studio prompts to update the plan.&lt;/p&gt; &lt;p&gt;There are two types of templates available for creating data generation plan&lt;/p&gt; &lt;ul&gt; &lt;li&gt; &lt;p&gt;Data Generation Plan: This template creates an empty data generation plan&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;Data Transform Plan: This template creates an data generation plan reusing data from another data source&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/3683.image_5F00_354E4565.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/5758.image_5F00_thumb_5F00_59FF5CDC.png" width="633" height="208" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;h4&gt;Data generation plan Template:&lt;/h4&gt; &lt;p&gt;Select the template i.e. Data Generation Plan and specify name and Add as displayed below&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/3683.image_5F00_354E4565.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/5758.image_5F00_thumb_5F00_59FF5CDC.png" width="633" height="208" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;After you click Add you can customize various aspects of data generation plan in the Data generation plan designer as displayed below&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/5861.image_5F00_01298045.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/8400.image_5F00_thumb_5F00_5EF174BE.png" width="634" height="266" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;Here three tables are displayed as I had three tables Event, EventPass and Student in my database project. The Related Table shows a dropdown only for EventPass table because EventPass has foreign key relation to Event and Student table. Please refer to first article for details.&lt;/p&gt; &lt;p&gt;You can choose Table and Rows to Insert in each table for all the tables provided for table that has related tables e.g. EventPass Related Table is set to None. If Related Table is chosen then you can specify the Ratio to Related Table and depending upon this ratio the Rows to Insert column will be populated.&lt;/p&gt; &lt;p&gt;You can preview as well as change the generator as displayed below&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/2158.image_5F00_2DA28A5E.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/5282.image_5F00_thumb_5F00_47D2CDB5.png" width="644" height="278" /&gt;&lt;/a&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Once you are done configuring this plan go to Data –&amp;gt; Data Generator –&amp;gt; Generate Data as displayed below&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/2577.image_5F00_53C4981C.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/6403.image_5F00_thumb_5F00_312059A1.png" width="478" height="223" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;Specify a new or an existing connection in the Connect to Database dialog that will appear next. Please note that you need to have the same schema in the database that you have specified for this else Data generation will fail. In this example my database is SampleDBTestData and it contains tables only. Once data generation is completed you can see the generate data in the database that you specified.&lt;/p&gt; &lt;h4&gt;Data transform plan Template:&lt;/h4&gt; &lt;p&gt;Select the Data transform plan template, specify name and Add as displayed below&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/8468.image_5F00_51977386.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/1033.image_5F00_thumb_5F00_3CC57B06.png" width="559" height="399" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;I have highlighted the sections that can be configured in this dialog. Rest of the steps are same as discussed above i.e. once you are done&amp;nbsp; configuring this plan go to Data –&amp;gt; Data Genarator –&amp;gt; Generate Data.&lt;/p&gt; &lt;h3&gt;Schema Comparison:&lt;/h3&gt; &lt;p&gt;Schema comparison is a powerful tool that is used to compare database schemas as displayed below&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/5165.image_5F00_3F7B0A2C.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/7823.image_5F00_thumb_5F00_2AA911AC.png" width="696" height="503" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;The result when source and target schema are same is displayed below&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/1057.image_5F00_39801AF9.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/8233.image_5F00_thumb_5F00_5711F5F8.png" width="703" height="277" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;The result when source and target schema were somewhat different is displayed below&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/6201.image_5F00_08ACC7B4.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/5224.image_5F00_thumb_5F00_6A7F09FF.png" width="707" height="282" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;h3&gt;Data Comparison:&lt;/h3&gt; &lt;p&gt;The data from two databases can be compared as display below&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/5224.image_5F00_44E566D1.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/0777.image_5F00_thumb_5F00_7E1BCDC6.png" width="713" height="484" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;This concludes the first logical part.&lt;/p&gt; &lt;h3&gt;Data driven unit tests&lt;/h3&gt; &lt;p&gt;In order to write a data driven unit test two important characteristics that we use are&lt;/p&gt; &lt;ul&gt; &lt;li&gt; &lt;p&gt;DataSourceAttribute: This attribute provides data source specific information for data driven testing and is available in assembly Microsoft.VisualStudio.QualityTools.UnitTestFramework&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;TestContext: This class is used to store information that is provided to unit tests and is available in assembly Microsoft.VisualStudio.QualityTools.UnitTestFramework&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;As displayed in code snippet I have marked the dbo_AddStudentTest with DataSource and TestMethod attributes and specified the provider type, connection string, table name and data access method as displayed below&lt;/p&gt; &lt;div id="codeSnippetWrapper"&gt; &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;[DataSource(&lt;span style="color: #006080"&gt;"System.Data.SqlClient"&lt;/span&gt;, &lt;span style="color: #006080"&gt;@"Data Source=SQLSERVER2008;Initial Catalog=TestData;Persist Security Info=True;User ID=sa;Password=*****;Pooling=False"&lt;/span&gt;, &lt;span style="color: #006080"&gt;"EmployeeData"&lt;/span&gt;, DataAccessMethod.Sequential), TestMethod()]&lt;/pre&gt;&lt;!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Inside the test method I can retrieve that parameter value that I am expecting from Test Data from the TestContext as displayed below&lt;/p&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;object&lt;/span&gt; parameterValue = TestContext.DataRow.ItemArray.GetValue(0);&lt;/pre&gt;&lt;!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;The unit test script is expects the parameter “StudentName” which I’ll populate from the test data. The same example I provided in first article of this series I had declared the parameter in the script and hard coded value for that parameter inside the script. Now you can drive unit tests from the test data. The unit test script for this test is displayed below. &lt;/p&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;-- unit test for dbo.uspAddStudent&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;DECLARE&lt;/span&gt; @RC &lt;span style="color: #0000ff"&gt;AS&lt;/span&gt; &lt;span style="color: #0000ff"&gt;INT&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;SELECT&lt;/span&gt; @RC = 0&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;EXECUTE&lt;/span&gt; @RC = [dbo].[uspAddStudent] @StudentName;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;SELECT&lt;/span&gt; * &lt;span style="color: #0000ff"&gt;FROM&lt;/span&gt; [dbo].[Student];&lt;/pre&gt;&lt;!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;The code snippet is displayed below&lt;/p&gt;
&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'Courier New', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
&lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;[DataSource(&lt;span style="color: #006080"&gt;"System.Data.SqlClient"&lt;/span&gt;, &lt;span style="color: #006080"&gt;@"Data Source=SQLSERVER2008;Initial Catalog=TestData;Persist Security Info=True;User ID=sa;Password=*******;Pooling=False"&lt;/span&gt;, &lt;span style="color: #006080"&gt;"EmployeeData"&lt;/span&gt;, DataAccessMethod.Sequential), TestMethod()]&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; dbo_uspAddStudentTest()&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;DatabaseTestActions testActions = &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.dbo_uspAddStudentTestData;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;// Execute the pre-test script&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;// &lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;System.Diagnostics.Trace.WriteLineIf((testActions.PretestAction != &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;), &lt;span style="color: #006080"&gt;"Executing pre-test script..."&lt;/span&gt;);&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;ExecutionResult[] pretestResults = TestService.Execute(&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.PrivilegedContext, &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.PrivilegedContext, testActions.PretestAction);&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;//Specifying the value of parameter from TestContext&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;object&lt;/span&gt; parameterValue = TestContext.DataRow.ItemArray.GetValue(0);&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;DbParameter parameter= CreateDBParameter(&lt;span style="color: #006080"&gt;"StudentName"&lt;/span&gt;, ParameterDirection.Input, DbType.String, 100, parameterValue);   &lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;// Execute the test script&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;// &lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;System.Diagnostics.Trace.WriteLineIf((testActions.TestAction != &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;), &lt;span style="color: #006080"&gt;"Executing test script..."&lt;/span&gt;);&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;ExecutionResult[] testResults = TestService.Execute(&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.ExecutionContext, &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.PrivilegedContext, testActions.TestAction, parameter);&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;// Execute the post-test script&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;// &lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;System.Diagnostics.Trace.WriteLineIf((testActions.PosttestAction != &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;), &lt;span style="color: #006080"&gt;"Executing post-test script..."&lt;/span&gt;);&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;ExecutionResult[] posttestResults = TestService.Execute(&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.PrivilegedContext, &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.PrivilegedContext, testActions.PosttestAction);&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; DbParameter CreateDBParameter(&lt;span style="color: #0000ff"&gt;string&lt;/span&gt; name, ParameterDirection direction, DbType dbType, &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; size, &lt;span style="color: #0000ff"&gt;object&lt;/span&gt; &lt;span style="color: #0000ff"&gt;value&lt;/span&gt;)&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;DbParameter parameter = &lt;span style="color: #0000ff"&gt;base&lt;/span&gt;.ExecutionContext.Provider.CreateParameter();&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;parameter.Direction = direction;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;parameter.DbType = DbType.String;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;parameter.ParameterName = name;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;parameter.Size = size;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;parameter.Value = &lt;span style="color: #0000ff"&gt;value&lt;/span&gt;;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;return&lt;/span&gt; parameter;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;&lt;!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/div&gt;&lt;/div&gt;&lt;pre&gt;One improvement that I can make is instead of hard coding the provider, connection string etc. by adding them to the App.Config as displayed below&lt;/pre&gt;
&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'Courier New', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
&lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;lt;configSections&amp;gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &amp;lt;section name=&lt;span style="color: #006080"&gt;"microsoft.visualstudio.testtools"&lt;/span&gt; type=&lt;span style="color: #006080"&gt;"Microsoft.VisualStudio.TestTools.UnitTesting.TestConfigurationSection, Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"&lt;/span&gt;/&amp;gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;lt;/configSections&amp;gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;lt;connectionStrings&amp;gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &amp;lt;add name=&lt;span style="color: #006080"&gt;"sqlDataCon"&lt;/span&gt; connectionString=&lt;span style="color: #006080"&gt;"Data Source=SQLSERVER2008;Initial Catalog=TestData;Persist Security Info=True;User ID=sa;Password=*********;Pooling=False"&lt;/span&gt; providerName =&lt;span style="color: #006080"&gt;"System.Data.SqlClient"&lt;/span&gt;/&amp;gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;lt;/connectionStrings&amp;gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;lt;microsoft.visualstudio.testtools&amp;gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &amp;lt;dataSources&amp;gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &amp;lt;add name =&lt;span style="color: #006080"&gt;"sqlDataSource"&lt;/span&gt; connectionString=&lt;span style="color: #006080"&gt;"sqlDataCon"&lt;/span&gt; dataTableName=&lt;span style="color: #006080"&gt;"EmployeeData"&lt;/span&gt; dataAccessMethod=&lt;span style="color: #006080"&gt;"Sequential"&lt;/span&gt;/&amp;gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &amp;lt;/dataSources&amp;gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;lt;/microsoft.visualstudio.testtools&amp;gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/div&gt;&lt;/div&gt;&lt;pre&gt;and mark the Test method as displayed below&lt;/pre&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;[DataSource(&lt;span style="color: #006080"&gt;"sqlDataSource"&lt;/span&gt;)]&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;[TestMethod]&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; dbo_uspAddStudentTest()&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;&lt;!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/div&gt;&lt;/div&gt;
&lt;h3&gt;Common, Pre, Test and Post scripts:&lt;/h3&gt;
&lt;p&gt;You can specify Common scripts(common to all tests), Pre and Post scripts to a test in test editor. By default these are optional. The order of execution of these scripts is &lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/3482.image_5F00_6E88962A.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/2018.image_5F00_thumb_5F00_7DDBF839.png" width="690" height="109" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;The context of these are also different i.e. TestInitializion, Pre Test script, Post Test script, TestCleanup execute having PrivelegedContext whereas Test script executes having&amp;nbsp; ExecutionContext.&lt;/p&gt;
&lt;h3&gt;Test Conditions:&lt;/h3&gt;
&lt;p&gt;I have discussed the test conditions in previous articles. In this article I’ll show two properties i.e. Configuration and Enabled. Enabled exist across all test conditions. You can enable/disable a test condition using this. Configuration property exists for Expected Schema and Data Checksum test conditions. For these conditions you need to configure the result you are expecting by clicking the button as highlighted below&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/6237.image_5F00_7784FBDE.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/7144.image_5F00_thumb_5F00_69D23FD6.png" width="326" height="214" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;You can define a custom test condition to verify the behaviour of a database object in ways that the built-in conditions do not support. Please read this msdn article for more details &lt;a href="http://msdn.microsoft.com/en-us/library/dd193282.aspx" target="_blank"&gt;Define Custom Conditions for Database Unit Tests&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;Transactions:&lt;/h3&gt;
&lt;p&gt;There are three ways through which we can specify transactions as listed below&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Inside Transact-SQL&lt;/p&gt;
&lt;/li&gt;&lt;li&gt;
&lt;p&gt;ADO.NET Transactions: Transactions can be implemented by adding code snippet to the test method as displayed below&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;blockquote&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;base&lt;/span&gt;.ExecutionContext.Connection.BeginTransaction()&lt;/pre&gt;&lt;!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/div&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div&gt;This only works if there are no pre and post test scripts for an unit test. This is because Pre and Post scripts are executed having PrivelegedContext where as Test script is executed having ExecutionContext&lt;/div&gt;&lt;/blockquote&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;System.Transactions: Transactions can be implemented by adding code snippet to the test method as displayed below&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;/p&gt;
&lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 93.81%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; height: 126px; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;using&lt;/span&gt; (TransactionScope scope = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; System.Transactions.TransactionScope(TransactionScopeOption.Required))&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;(&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;base&lt;/span&gt;.PrivilegedContext.Connection.EnlistTransaction(Transaction.Current);    &lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;base&lt;/span&gt;.ExecutionContext.Connection.EnlistTransaction(Transaction.Current);    &lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;//Rest of the test method code&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;&lt;!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/div&gt;
&lt;p&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;In this case we have to enlist the transaction as we have two different contexts i.e. PrivelegedContext and ExecutionContext.&amp;nbsp; This means if these we need to have distributed transaction coordinator service running as we are having transaction across two different connections.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;This completes the series “How to unit test SQL Server database using Visual Studio 2010”. Please share the feedback so that I can improve/rectify the series.&lt;/p&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:7955517d-aef7-4232-a293-d65a150d3089" class="wlWriterEditableSmartContent"&gt;del.icio.us Tags: &lt;a href="http://del.icio.us/popular/Visual+Studio+2010" rel="tag"&gt;Visual Studio 2010&lt;/a&gt;,&lt;a href="http://del.icio.us/popular/SQL+Server+2008" rel="tag"&gt;SQL Server 2008&lt;/a&gt;,&lt;a href="http://del.icio.us/popular/Unit+Test" rel="tag"&gt;Unit Test&lt;/a&gt;,&lt;a href="http://del.icio.us/popular/Schema+Comparer" rel="tag"&gt;Schema Comparer&lt;/a&gt;,&lt;a href="http://del.icio.us/popular/Data+Comparer" rel="tag"&gt;Data Comparer&lt;/a&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10052974" width="1" height="1"&gt;</description></item><item><title>How to unit test SQL Server 2008 database using Visual Studio 2010 – Part 2</title><link>http://blogs.msdn.com/b/atverma/archive/2010/08/22/how-to-unit-test-sql-server-2008-database-using-visual-studio-2010-part-2.aspx</link><pubDate>Sun, 22 Aug 2010 22:33:05 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10052972</guid><dc:creator>Atul.Verma</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/atverma/rsscomments.aspx?WeblogPostID=10052972</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/atverma/commentapi.aspx?WeblogPostID=10052972</wfw:comment><comments>http://blogs.msdn.com/b/atverma/archive/2010/08/22/how-to-unit-test-sql-server-2008-database-using-visual-studio-2010-part-2.aspx#comments</comments><description>&lt;p&gt;This is the second article I am writing on unit testing SQL Server 2008 database using Visual Studio 2010. The other articles are&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/b/atverma/archive/2010/07/28/how-to-unit-test-sql-server-2008-database-using-visual-studio-2010.aspx" target="_blank"&gt;Unit test SQL Server 2008 - Part 1&lt;/a&gt; – Focused on setting up environment, creating database project and executing simple unit tests&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/b/atverma/archive/2010/08/22/how-to-unit-test-sql-server-2008-database-using-visual-studio-2010-part-3.aspx" target="_blank"&gt;Unit test SQL Server 2008 - Part 3&lt;/a&gt; – Focused on data generation, schema comparison, data comparison and data driven unit tests&lt;/p&gt;  &lt;p&gt;In this article I will explore the important features that can be configured to build comprehensive database unit tests. The two assemblies that are the backbone for database unit testing are&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;p&gt;Microsoft.VisualStudio.QualityTools.UnitTestFramework: This assembly is the testing framework assembly the test engine depends on when executing the unit tests. I won’t get into details of the parts of this assembly and focus on some the the important attributes that are required to execute an database unit test.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Microsoft.Data.Schema.UnitTesting: This assembly provides the classes required to create and execute database unit test. In this blog I’ll focus on this assembly.&lt;/p&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;In this article I’ll dig deep into these two assemblies and explore the various components of these assemblies that are used to execute unit test for a database.&lt;/p&gt;  &lt;p&gt;I’ll start with the Database Unit Test Designer and then move on to explaining various components.&lt;/p&gt; &lt;a name="more"&gt;&lt;/a&gt;  &lt;h2&gt;Database Unit Test Designer:&lt;/h2&gt;  &lt;p&gt;I have highlighted the various options available in Database Unit Test Designer and added short description as displayed below&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/0564.image_5F00_5429E347.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/3225.image_5F00_thumb_5F00_166CD5BE.png" width="830" height="417" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;The scripts that are created are stored in the resource file.&lt;/p&gt;  &lt;p&gt;I’ll now discuss the important components of the Unit Testing Ecosystem which reside inside the assemblies&lt;/p&gt;  &lt;h3&gt;Microsoft.VisualStudio.QualityTools.UnitTestFramework:&lt;/h3&gt;  &lt;p&gt;This assembly is the testing framework assembly that the unit test engine depends upon while executing unit tests.&lt;/p&gt;  &lt;h4&gt;Microsoft.VisualStudio.QualityTools.UnitTestFramework:&lt;/h4&gt;  &lt;p&gt;This namespace supplies classes that provide unit testing support. This namespace contains many attributes that identify test information to the test engine regarding data sources, order of method execution, program management, agent/host information, and deployment data.&lt;/p&gt;  &lt;p&gt;I will touch upon the important attributes and classes that are required by the test engine to execute unit tests.&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;p&gt;TestClassAttribute: The class containing test methods should be marked with this attribute else the tests won’t execute. This attribute can only be applied to a class.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;AssemblyInitializeAttribute: Method marked with this attribute will be run prior to methods marked with &lt;font color="#000000"&gt;ClassInitializeAttribute&lt;/font&gt;, &lt;font color="#000000"&gt;TestInitializeAttribute&lt;/font&gt;, and &lt;font color="#000000"&gt;TestMethodAttribute&lt;/font&gt; attributes. This attribute can only be applied to a method. Only one method in an assembly may be decorated with this attribute. An example of usage of this attribute is setting up database based upon setting from a configuration file i.e. deploying database, generating data.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;AssemblyCleanupAttribute: Method marked with this attribute will be run after all the test methods&amp;#160; in that assembly will execute i.e. after methods marked with &lt;font color="#000000"&gt;TestMethodAttribute,&lt;/font&gt; &lt;font color="#000000"&gt;TestCleanupAttribute&lt;/font&gt; and &lt;font color="#000000"&gt;ClassCleanupAttribute&lt;/font&gt; attributes. This attribute can only be applied to a method. Only one method in an assembly may be decorated with this attribute. This method won’t execute&amp;#160; if there is any exception in the method marked with AssemblyInitialize attribute.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;ClassInitializeAttribute: Method marked with this attribute will run only once in the entire test. This attribute can only be applied to a method. This method runs before the method marked with TestInitialize attribute and after the method marked with AssemblyInitialze attribute. A class can have only one method marked with this attribute.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;ClassCleanupAttribute: Method marked with this attribute will run only once in the entire test. This attribute can only be applied to a method. This method runs before the method marked with AssemblyCleanup attribute and after the method marked with TestCleanup attribute. A class can have only one method marked with this attribute. This method won’t execute&amp;#160; if there is any exception in the method marked with ClassInitialize attribute.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;TestMethodAttribute: Test method should be marked with this attribute else method won’t execute. This attribute can only be applied to a method.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;TestInitializeAttribute: The method that is marked with this attribute runs before each test is executed. This method runs before methods marked with TestMethod attribute and after method marked with ClassInitialize attribute. This attribute can only be applied to a method. A class can have only one method marked with this attribute.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;TestCleanupAttribute: The method that is marked with this attribute runs after each test is executed. This method runs before method marked with ClassCleanup attribute and after methods marked with TestMethod attribute. This attribute can only be applied to a method. A class can have only one method marked with this attribute. This method won’t execute&amp;#160; if there is any exception in the method marked with TestInitialize attribute.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;DataSourceAttribute: This attribute provides data-source specific information for data-driven testing.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;PriortyAttribute: This attribute is used to specify the priorty of an unit test.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;IgnoreAttribute: This attribute is used to ignore the unit test i.e. specific test should not run.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;ExpectedExceptionAttribute: This is used in case exception is expected during execution of unit test.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Assert: This class verifies conditions in unit test.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;TestContext: This class is used to store information that is provided to unit tests.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;TestConfigurationSection: This class provides access to data source configuration data.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;TestConfiguration: This class provides access to a TestConfigurationSection that represents the &lt;tt&gt;microsoft.visualstudio.testtools&lt;/tt&gt; section in an app.config file.&lt;/p&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;The order in which methods marked with these attributes will run by the test engine is displayed below assuming we have one assembly, one class marked with TestClassAttribute, one method marked with TestMethodAttribute. I have provided this example as &lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;     &lt;p&gt;Methods marked with AssemblyInitialize and AssemblyCleanUp attributes will execute only once for an assembly.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Methods marked with ClassInitialize and ClassCleanUp attributes will execute only once for each class in an assembly.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Methods marked with TestInitialize and TestCleanUp attributes will execute before and after respectively for each test method(i.e. method marked with TestMethod attribute).&lt;/p&gt;   &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/2086.image_5F00_6DAE1E1C.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/0435.image_5F00_thumb_5F00_52954F0E.png" width="757" height="390" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;I have discussed the common attributes required by the test engine to execute unit test. For more information about this assembly please read this link &lt;a href="http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.testtools.unittesting.aspx" target="_blank"&gt;microsoft.visualstudio.testtools.unittesting&lt;/a&gt;. I’ll now move on to the next assembly i.e. Microsoft.Data.Schema.UnitTesting.&lt;/p&gt;  &lt;h3&gt;Microsoft.Data.Schema.UnitTesting:&lt;/h3&gt;  &lt;p&gt;This assembly provides the classes to run and execute unit tests. The classes grouped by namespace for this assembly are displayed below&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/7382.image_5F00_5D723056.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/5353.image_5F00_thumb_5F00_15344EAD.png" width="827" height="496" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;h4&gt;Microsoft.Data.Schema.UnitTesting:&lt;/h4&gt;  &lt;p&gt;This namespace provides classes that you can use to create and execute database unit tests. The classes are listed below&lt;/p&gt;  &lt;ul&gt;   &lt;ul&gt;&lt;/ul&gt;    &lt;li&gt;     &lt;p&gt;DatabaseTestClass: This is the base calss for a database unit test. This class derives from Component. For more information about choosing between IComponent, Component, IDisposable, MarshalByValueComponent and Control while implementing a class please read my blog &lt;a href="http://blogs.msdn.com/b/atverma/archive/2010/08/01/how-to-choose-between-idisposable-icomponent-component-marshalbyvaluecomponent-and-control-while-implementing-a-class.aspx" target="_blank"&gt;How to Choose Component, IComponent ...&lt;/a&gt;. &lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;ConnectionContext: This class encapsulated the database connection associated with the database unit test. In the DatabaseTestClass we have two properties of this type i.e. ExecutionContext and PrivilegedContext. The ExecutionContext and PrivelegedContext differ only if SQL Server authentication is used. If Windows authentication is used same credentials will be used for both. There is a reason behind having two separate contexts inside a DatabaseTestClass      &lt;ul&gt;       &lt;li&gt;         &lt;p&gt;ExecutionContext: This defines the context used to execute the Transact-Sql script associated with an unit test. Ideally connection string should have same credentials as that of end user. This is the ExecutionContext element in the App.config.&lt;/p&gt;       &lt;/li&gt;        &lt;li&gt;         &lt;p&gt;PrivilegedContext: This is optional and defines the context used for running the pre-test action, post-test action, TestInitialize, and TestCleanup scripts. This connection string is also used to deploy database changes and generate data. This is the PrivilegedContext element in the App.config. If unit tests run the test script only, then there is no need to specify a privileged context.&lt;/p&gt;       &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;DatabaseTestAction: This class contains Transact-Sql test script and test actions.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;DatabaseTestActions: This class is the design time equivalent of test and contains PostTestAction, PreTestAction and TestAction that are of type DatabaseTestAction.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;DatabaseTestService: This class provides methods to Deploy database project, Execute test, Generate data and opening of Execution context and privileged execution contexts.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;ExecutionResult: This is the result for and unit test and contains Dataset, execution time and rows affected.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;ExpectedSqlExceptionAttribute: This attribute specifies that unit test is expecting a SQL exception and optionally specify the error number, severity, and state of the expected error.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;TestScript: This class represents a generated SQL test&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;UnitTestingDesignService: Provides the base class for database schema providers to generate scripts for objects in their project system.&lt;/p&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;h4&gt;Microsoft.Data.Schema.UnitTesting.Configuration:&lt;/h4&gt;  &lt;p&gt;This namespace provides classes used to read or write configuration information to the DatabaseUnitTesting section of the app.config. The classes are listed below&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;p&gt;ConnectionContextElement: This class represents the ExecutionContext or PrivilegedContext configuration element in the DatabaseUnitTesting section of the app.config file&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;DatabaseDeploymentElement: This class represents the DatabaseDeployment configuration element in the DatabaseUnitTesting section of the app.config file.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;DatabaseUnitTestingSection: This class represents the DatabaseUnitTesting configuration section in the app.config file.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;DatabaseGenerationElement: This class represents the DataGeneration configuration element in the DatabaseUnitTesting section of the app.config file.&lt;/p&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;h4&gt;Microsoft.Data.Schema.UnitTesting.Conditions:&lt;/h4&gt;  &lt;p&gt;This namespace provides classes that you can use to create and manage test conditions. The classes are listed below&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;p&gt;TestCondition: Base class of all test conditions.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;ChecksumCondition: This condition verifies the checksum of the result set in a database unit test.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;DataSetTestCondition: This is the base class for test conditions that operate on a DataSet and are configured by the user during test &amp;quot;design time&amp;quot;.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;EmptyResultSetCondition: For this test conditon to succeed Execution.DataSet property must be empty.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;ExecutionTimeCondition: If test takes more time to execute than specified by this condition test fails.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;ExpectedSchemaCondition: Specifies that result set of a database unit test must match a specific schema.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;InconclusiveCondition: Represents a default condition where nothing is required or expected of a test result.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;NotEmptyResultSetCondition: For this test conditon to succeed Execution.DataSet property should not be empty.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;ResultSetCondition: Represents the base class for all test conditions that operate on one &lt;a href="http://msdn.microsoft.com/en-us/library/microsoft.data.schema.unittesting.conditions.resultsetcondition.resultset.aspx"&gt;&lt;/a&gt;ResultSet.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;RowCountCondition: Defines a test condition that verifies the number of rows in the ResultSet that is returned by a database unit test.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;ScalarValueCondition: Verifies that a particular value in a specific row and column was expected.&lt;/p&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;This concludes the part-2 of the series “How to unit test SQL Server 2008 using Visual Studio 2010”.&lt;/p&gt;  &lt;p&gt;In the next article I’ll show how to unit test a database using the components discussed in this article.&lt;/p&gt;  &lt;p&gt;The link to next article of this series is &lt;a href="http://blogs.msdn.com/b/atverma/archive/2010/08/22/how-to-unit-test-sql-server-2008-database-using-visual-studio-2010-part-3.aspx"&gt;Unit test database - Part 3&lt;/a&gt;&lt;/p&gt;  &lt;br /&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:a1fe9d94-f804-4161-8c9b-4f0fd4ee7153" class="wlWriterEditableSmartContent"&gt;del.icio.us Tags: &lt;a href="http://del.icio.us/popular/Unit+Test" rel="tag"&gt;Unit Test&lt;/a&gt;,&lt;a href="http://del.icio.us/popular/SqL+Server+2008" rel="tag"&gt;SqL Server 2008&lt;/a&gt;,&lt;a href="http://del.icio.us/popular/Visual+Studio+2010" rel="tag"&gt;Visual Studio 2010&lt;/a&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10052972" width="1" height="1"&gt;</description></item><item><title>How to choose between IDisposable, IComponent, Component, MarshalByValueComponent and Control while implementing a Class</title><link>http://blogs.msdn.com/b/atverma/archive/2010/08/01/how-to-choose-between-idisposable-icomponent-component-marshalbyvaluecomponent-and-control-while-implementing-a-class.aspx</link><pubDate>Sat, 31 Jul 2010 23:15:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10044599</guid><dc:creator>Atul.Verma</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/atverma/rsscomments.aspx?WeblogPostID=10044599</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/atverma/commentapi.aspx?WeblogPostID=10044599</wfw:comment><comments>http://blogs.msdn.com/b/atverma/archive/2010/08/01/how-to-choose-between-idisposable-icomponent-component-marshalbyvaluecomponent-and-control-while-implementing-a-class.aspx#comments</comments><description>&lt;p&gt;In this article I&amp;rsquo;ll discuss about the criteria behind choosing IDisposable, IComponent, Component, MarshalByValueComponent and base Control classes(System.Windows.Form.Control and System.Web.UI.Control) while implementing a Class.&lt;/p&gt;
&lt;p&gt;Prior to discussing further I&amp;rsquo;d like to share the reason behind this article. I ran code analysis in a project code and got a warning that Dispose was not called for a DataSet in the project&amp;rsquo;s code. I than called the Dispose method for that particular DataSet and this time code analysis executed with zero errors/warnings. Out of curiosity I thought of verifying the use of calling Dispose on DataSet as even though when Dispose was not being called everything was fine. I found that calling Dispose method did nothing as DataSet is a managed object and does not contain unmanaged resources(if I&amp;rsquo;m wrong please correct me on this). I could verify this as I was able to access/update the DataSet even after Dispose had been called without any &amp;ldquo;Object Disposed Exception&amp;rdquo;. FeatureSchema&amp;nbsp; is a typed DataSet as displayed in code snippet below&lt;/p&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;div id="codeSnippet" style="text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;FeatureSchema fs = Proxy.GetFeatureSchema();&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;fs.Dispose(); &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;&lt;span style="color: #0000ff;"&gt;foreach&lt;/span&gt; (FeatureSchema.FeatureRow featureRow &lt;span style="color: #0000ff;"&gt;in&lt;/span&gt; fs.Feature.Rows)&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;//Do procesing on dataset&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;div id="codeSnippetWrapper"&gt;I went one step further to find the reason behind having Dispose method in DataSet/DataTable and the reason was inheritance as DataSet/DataTable inherits from System.ComponentModel.MarshalByValueComponent class. The reason DataSet/DataTable inherits MarshalByValueComponent class so that it can be designable i.e. used on a design surface. Thus DataSet/DataTable has dispose method even though it doesn&amp;rsquo;t clean up the resources. DataSet/DataTable call GC.SuppressFinalize in the constructor to prevent the Garbage Collector from calling Object.Finalize on an object that does not require it.&lt;/div&gt;
&lt;div&gt;This can be proved by the code snippet displayed below&lt;/div&gt;
&lt;div&gt;I have a typed dataset FeatureSchema and I have added a destructor to it. I have excluded the code that was auto generated as I am focusing on finalizers only&lt;/div&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;div id="codeSnippet" style="text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;&lt;span style="color: #0000ff;"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff;"&gt;partial&lt;/span&gt; &lt;span style="color: #0000ff;"&gt;class&lt;/span&gt; FeatureSchema : global::System.Data.DataSet&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;//Added only a destructor to this types dataset. I have excluded all other code&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;// as I am focusing on finalizers&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;~FeatureSchema ()&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;As displayed below I am loading data to this typed dataset from an .xml file&lt;/div&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;div id="codeSnippet" style="text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;&lt;span style="color: #008000;"&gt;//I am just loading the data into this typed dataset&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;FeatureSchema schema = &lt;span style="color: #0000ff;"&gt;new&lt;/span&gt; FeatureSchema();&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;schema.ReadXml(featureSchemaFile, XmlReadMode.Auto);&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;As DataSet calls GC.SuppressFinalize in the constructor Object.Finalize will not be called by the Garbage Collector. This can be verified by placing a break point on the destructor and you will find that it is not getting called.&lt;/div&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;Now I will call GC.ReRegisterForFinalize as displayed in the code snippet below&lt;/div&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;div id="codeSnippet" style="text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;FeatureSchema schema = &lt;span style="color: #0000ff;"&gt;new&lt;/span&gt; FeatureSchema();&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;GC.ReRegisterForFinalize(schema);&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;schema.ReadXml(featureSchemaFile, XmlReadMode.Auto);&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;Calling GC.ReRegisterForFinalize will register the object for finalization. I am doing this as I know that DataSet calls GC.SuppressFinalize in the constructor. Now the code will break on the break point which I placed on the destructor at some random time i.e. when GC will execute the &amp;ldquo;GC Finalizer Thread&amp;rdquo;.&lt;/div&gt;
&lt;div&gt;This verifies the need of calling GC.SuppressFinalize from the constructor of DataSet/DataTable to prevent the garbage collector from requesting finalization.&lt;/div&gt;
&lt;div&gt;Even though Dispose in DataSet/DataTable does nothing we should not ignore it and stick to the .Net coding practices otherwise in future versions of Framework things may break. Please do correct me if I am wrong. This concludes the reason behind this article.&lt;/div&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;I&amp;rsquo;ll continue with the main theme of article. The guidelines for implementers are&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;h4 align="left"&gt;IDisposable:&lt;/h4&gt;
&lt;p&gt;If a class uses external resources and will not be used on a design surface IDisposable interface has to be implemented directly or indirectly e.g. System.Drawing.Font class etc.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h4&gt;IComponent:&lt;/h4&gt;
&lt;p&gt;If a class will be used on a design surface IComponent interface has be implemented directly or indirectly. IComponent implements IDisposable e.g. System.Web.UI.Control class etc.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h4&gt;Component:&lt;/h4&gt;
&lt;p&gt;If a class will be used on a design surface and is Marshalled by reference then it has to derive from Component class e.g. System.Timers.Timer class etc.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h4&gt;MarshalByValueComponent:&lt;/h4&gt;
&lt;p&gt;If a class will be used on a design surface and is Marshalled by value then it has to derive from MarshalByValueComponent class e.g. DataSet, DataTable etc.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h4&gt;Control:&lt;/h4&gt;
&lt;p&gt;If a class will be used on a design surface and provides a user interface then this class is a control and has to derive from System.Windows.Form.Control or System.Web.UI.Control e.g. System.Windows.Forms.Button etc.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #000000;"&gt;The above discussion does not apply to WPF. The WPF Designer architecture is significantly different from the Windows Forms Designer architecture, which is characterized by the &lt;/span&gt;&lt;span style="color: #000000;"&gt;IComponent &lt;/span&gt;&lt;span style="color: #000000;"&gt;interface and the &lt;/span&gt;&lt;span style="color: #000000;"&gt;System.ComponentModel&lt;/span&gt;&lt;span style="color: #000000;"&gt; namespace. &lt;/span&gt;&lt;span style="color: #000000;"&gt;The WPF Designer architecture retains the &lt;/span&gt;&lt;span style="color: #000000;"&gt;TypeConverter&lt;/span&gt;&lt;span style="color: #000000;"&gt; and &lt;/span&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.typedescriptor.aspx"&gt;&lt;span style="color: #000000;"&gt;TypeDescriptor&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #000000;"&gt; classes from the Windows Forms Designer object model. Most other aspects of the WPF Designer architecture are different. For more information please read &lt;a href="http://msdn.microsoft.com/en-us/library/bb514704.aspx"&gt;Comparing the Windows Forms Designer Framework to the WPF Designer Framework&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #000000;"&gt;Refrences: &lt;a href="http://msdn.microsoft.com/en-us/library/0b1dk63b.aspx"&gt;http://msdn.microsoft.com/en-us/library/0b1dk63b.aspx&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:b1b40993-c086-47d0-9913-9705c06fee0e" style="margin: 0px; display: inline; float: none; padding: 0px;"&gt;del.icio.us Tags: &lt;a rel="tag" href="http://del.icio.us/popular/.NET"&gt;.NET&lt;/a&gt;,&lt;a rel="tag" href="http://del.icio.us/popular/.NET+Framework"&gt;.NET Framework&lt;/a&gt;,&lt;a rel="tag" href="http://del.icio.us/popular/IDisposable"&gt;IDisposable&lt;/a&gt;,&lt;a rel="tag" href="http://del.icio.us/popular/IComponent"&gt;IComponent&lt;/a&gt;,&lt;a rel="tag" href="http://del.icio.us/popular/Component"&gt;Component&lt;/a&gt;,&lt;a rel="tag" href="http://del.icio.us/popular/MarshalByValueComponent"&gt;MarshalByValueComponent&lt;/a&gt;,&lt;a rel="tag" href="http://del.icio.us/popular/Control"&gt;Control&lt;/a&gt;,&lt;a rel="tag" href="http://del.icio.us/popular/Windows+Forms"&gt;Windows Forms&lt;/a&gt;,&lt;a rel="tag" href="http://del.icio.us/popular/ASP.NET"&gt;ASP.NET&lt;/a&gt;,&lt;a rel="tag" href="http://del.icio.us/popular/DataSet"&gt;DataSet&lt;/a&gt;,&lt;a rel="tag" href="http://del.icio.us/popular/DataTable"&gt;DataTable&lt;/a&gt;,&lt;a rel="tag" href="http://del.icio.us/popular/Garbage+Collector"&gt;Garbage Collector&lt;/a&gt;,&lt;a rel="tag" href="http://del.icio.us/popular/GC"&gt;GC&lt;/a&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10044599" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/atverma/archive/tags/Component/">Component</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/DataSet/">DataSet</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/DataTable/">DataTable</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/Garbage+Collector/">Garbage Collector</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/Control/">Control</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/Dispose/">Dispose</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/-NET+Framework/">.NET Framework</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/IComponent/">IComponent</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/MarshalByValueComponent/">MarshalByValueComponent</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/-NET/">.NET</category></item><item><title>How to host a service in Azure and expose using WCF and Visual Studio 2010 : Issues Faced and Fixes</title><link>http://blogs.msdn.com/b/atverma/archive/2010/07/28/how-to-host-a-service-in-azure-and-expose-using-wcf-and-visual-studio-2010-issues-faced-and-fixes.aspx</link><pubDate>Wed, 28 Jul 2010 03:30:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10043261</guid><dc:creator>Atul.Verma</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/atverma/rsscomments.aspx?WeblogPostID=10043261</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/atverma/commentapi.aspx?WeblogPostID=10043261</wfw:comment><comments>http://blogs.msdn.com/b/atverma/archive/2010/07/28/how-to-host-a-service-in-azure-and-expose-using-wcf-and-visual-studio-2010-issues-faced-and-fixes.aspx#comments</comments><description>&lt;p&gt;This blog is regarding my first attempt to explore &amp;ldquo;Hosting a service in Azure using WCF and Visual Studio 2010&amp;rdquo;, the issue I faced and the quick fixes required to make it running. You can explore the Windows Azure Platform at &lt;a href="http://www.microsoft.com/windowsazure/" title="http://www.microsoft.com/windowsazure/"&gt;http://www.microsoft.com/windowsazure/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I faced a few issues and so sharing the workarounds. I won&amp;rsquo;t get into details in this post so keeping things simple and targeting the workarounds only.&lt;/p&gt;
&lt;p&gt;1. Run the Visual Studio 2010 with elevated permission e.g. &amp;ldquo;Run as Administrator&amp;rdquo; option otherwise you will get a prompt as displayed below when creating/opening the Windows Azure Cloud Service project.&lt;/p&gt;
&lt;p&gt;You may need to install Windows Azure Tools for Microsoft Visual Studio to enable the creation, configuration, building, debugging, running and packaging of scalable web applications and services on Windows Azure. The download link for Windows Azure Tools for MS Visual Studio 1.1 is &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=5664019e-6860-4c33-9843-4eb40b297ab6&amp;amp;displaylang=en" title="http://www.microsoft.com/downloads/details.aspx?FamilyID=5664019e-6860-4c33-9843-4eb40b297ab6&amp;amp;displaylang=en"&gt;http://www.microsoft.com/downloads/details.aspx?FamilyID=5664019e-6860-4c33-9843-4eb40b297ab6&amp;amp;displaylang=en&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/6825.image51_5F00_4391DAE9.png"&gt;&lt;img height="235" width="513" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/8507.image51_5F00_thumb_5F00_5998467B.png" alt="image" border="0" title="image" style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" /&gt;&lt;/a&gt;r&lt;/p&gt;
&lt;p&gt;&lt;a name="more"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;2. Create a New Project. Select Cloud from Installed Templates and then select Windows Azure Cloud Service and click Ok.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/8015.image_5F00_445A1B06.png"&gt;&lt;img height="335" width="511" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/6215.image_5F00_thumb_5F00_019ACFCE.png" alt="image" border="0" title="image" style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;3. Select the WCF Service Web Role as we are exposing service using WCF. I&amp;rsquo;ll go with the default code that gets generated and without making any change according to the context of this Blog. Build and Run the application&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/8877.image_5F00_3A35540E.png"&gt;&lt;img height="408" width="524" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/6232.image_5F00_thumb_5F00_7709D5E0.png" alt="image" border="0" title="image" style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;&amp;nbsp;4. In order to test the WCF services we will use Microsoft WCF Test Client. This can be opened as displayed below&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/4111.image_5F00_258FB8F6.png"&gt;&lt;img height="91" width="530" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/7356.image_5F00_thumb_5F00_378BD6B6.png" alt="image" border="0" title="image" style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;5. We need to Add the Service to test by right clicking on the My Service Projects and then clicking Add Service. Here we need to specify the end point address e.g. in my case it was &amp;ldquo;//127.0.0.1:81/Service1.svc?wsdl&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/7343.image_5F00_1FA4EF90.png"&gt;&lt;img height="346" width="535" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/7752.image_5F00_thumb_5F00_36178E17.png" alt="image" border="0" title="image" style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;6. In case you see the error &amp;ldquo;Service metadata may not be accessible&amp;rdquo; as displayed below we need to add a Service Behaviour in the Web.Config file as displayed in next step&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/1423.image_5F00_179D2761.png"&gt;&lt;img height="352" width="533" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/3404.image_5F00_thumb_5F00_0DF4B92B.png" alt="image" border="0" title="image" style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;7. The section displayed in green font is required to resolve the error in above step. This is a known issue and there is&amp;nbsp; a patch available for it at &lt;a title="http://code.msdn.microsoft.com/wcfazure/Wiki/View.aspx?title=KnownIssues" href="http://code.msdn.microsoft.com/wcfazure/Wiki/View.aspx?title=KnownIssues"&gt;http://code.msdn.microsoft.com/wcfazure/Wiki/View.aspx?title=KnownIssues&lt;/a&gt;. You may see that IDE doesn&amp;rsquo;t recognise it shows a Warning so ignore the warning&lt;/p&gt;
&lt;p&gt;&amp;lt;serviceBehaviors&amp;gt; &lt;br /&gt;&amp;nbsp; &amp;lt;behavior name="WCFServiceWebRole1.Service1Behavior"&amp;gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment --&amp;gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;serviceMetadata httpGetEnabled="true"/&amp;gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;!-- To receive exception details in faults for debugging purposes, set the value below to true.&amp;nbsp; Set to false before deployment to avoid disclosing exception information --&amp;gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;serviceDebug includeExceptionDetailInFaults="false"/&amp;gt; &lt;br /&gt;&lt;span style="color: #008000;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;useRequestHeadersForMetadataAddress&amp;gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;defaultPorts&amp;gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;add scheme="http" port="81" /&amp;gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;add scheme="https" port="444" /&amp;gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/defaultPorts&amp;gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/useRequestHeadersForMetadataAddress&amp;gt;&lt;/span&gt; &lt;br /&gt;&amp;nbsp; &amp;lt;/behavior&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;lt;/serviceBehaviors&amp;gt;&lt;/p&gt;
&lt;p&gt;8. Now when you run you may see the error displayed below in browser. This is a known issue and there is&amp;nbsp; a patch available for it at &lt;a title="http://code.msdn.microsoft.com/wcfazure/Wiki/View.aspx?title=KnownIssues" href="http://code.msdn.microsoft.com/wcfazure/Wiki/View.aspx?title=KnownIssues"&gt;http://code.msdn.microsoft.com/wcfazure/Wiki/View.aspx?title=KnownIssues&lt;/a&gt;. Install this patch and after installation restart your machine&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/0358.image1_5F00_43C98878.png"&gt;&lt;img height="206" width="556" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/5483.image1_5F00_thumb_5F00_53891D7C.png" alt="image" border="0" title="image" style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;9. Now when you run the application it will run fine so it&amp;rsquo;s time to test it using Microsoft Windows Test Client. In case WCF HTTP Activation is turned off you may now see this error while trying to Add the service to test as in Step 5&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/2746.image_5F00_093E62D7.png"&gt;&lt;img height="371" width="564" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/6177.image_5F00_thumb_5F00_1BA6B38C.png" alt="image" border="0" title="image" style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;10. In Order to resolve the error above just turn on the WCF HTTP activation in &amp;ldquo;Turn Windows Features on and off&amp;rdquo; which is turned off as in image displayed below&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/6683.image_5F00_63388CB3.png"&gt;&lt;img height="463" width="558" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/1323.image_5F00_thumb_5F00_07113E41.png" alt="image" border="0" title="image" style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;11. Now add the service to the WCF test client as in Step 5. Voila finally everything is working fine. In order to test your WCF service choose any of the Operation e.g. GetData() in this case, double click it, specify the Value in Request section e.g. I have specified 23 and click Invoke. In the Response you will see the results&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/4863.image_5F00_35972156.png"&gt;&lt;img height="366" width="562" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/4382.image_5F00_thumb_5F00_1A121F53.png" alt="image" border="0" title="image" style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;12. At runtime, WCF services may return the following error: The message with To 'http://127.0.0.1:81/Service.svc' cannot be processed at the receiver, due to an AddressFilter mismatch at the EndpointDispatcher. Check that the sender and receiver's EndpointAddresses agree. The error can be corrected by applying the following attribute to the service class. &lt;br /&gt;[ServiceBehavior(AddressFilterMode = AddressFilterMode.Any)]&lt;/p&gt;
&lt;p&gt;This concludes the article as we have Service hosted in Microsoft Azure platform and exposed using WCF and Visual Studio 2010. Time to explore the advanced features of Azure platform.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10043261" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/atverma/archive/tags/Azure/">Azure</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/WCF+Test+Client/">WCF Test Client</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/Visual+Studio+2010/">Visual Studio 2010</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/WCF+HTTP+Activation/">WCF HTTP Activation</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/WCF/">WCF</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/Host/">Host</category></item><item><title>INotifyPropertyChanging and INotifyPropertyChanged in Real Life using Expression Trees</title><link>http://blogs.msdn.com/b/atverma/archive/2010/07/28/inotifypropertychanging-and-inotifypropertychanged-in-real-life-using-expression-trees.aspx</link><pubDate>Wed, 28 Jul 2010 03:08:57 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10043257</guid><dc:creator>Atul.Verma</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/atverma/rsscomments.aspx?WeblogPostID=10043257</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/atverma/commentapi.aspx?WeblogPostID=10043257</wfw:comment><comments>http://blogs.msdn.com/b/atverma/archive/2010/07/28/inotifypropertychanging-and-inotifypropertychanged-in-real-life-using-expression-trees.aspx#comments</comments><description>&lt;h3&gt;Functional Requirements:&lt;/h3&gt;  &lt;br /&gt;Requirements when we need to achieve any or all of the functionalities listed below   &lt;br /&gt;  &lt;ul&gt;   &lt;li&gt;Undo/Redo functionality in an Application &lt;/li&gt;    &lt;li&gt;Any of user interface patterns e.g. MVC, MVP, MVVM etc &lt;/li&gt;    &lt;li&gt;Other patterns State Pattern, Events, Event handlers etc. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;In this blog I’ll discuss the points mentioned below&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Sample Scenario &lt;/li&gt;    &lt;li&gt;High level Solution &lt;/li&gt;    &lt;li&gt;Solution using .Net Framework 2 (and Drawbacks) &lt;/li&gt;    &lt;li&gt;Solution using .Net Framework 3.5 using Lambda Expressions &lt;/li&gt;    &lt;li&gt;Summary &lt;/li&gt; &lt;/ul&gt;  &lt;h3 style="display: none"&gt;&amp;#160;&lt;/h3&gt;  &lt;h3 style="display: none"&gt;Sample Scenario:&lt;/h3&gt;  &lt;div style="display: none"&gt;   &lt;br /&gt;We need to implement Undo/Redo feature in our application. I have a Barometer class that records pressure. We need to implement achieve Undo/Redo feature for this sample class.     &lt;br /&gt;    &lt;br /&gt;&lt;/div&gt;  &lt;div style="display: none" id="codeSnippetWrapper"&gt;   &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;class&lt;/span&gt; Barometer 
{ 
&lt;span style="color: blue"&gt;private&lt;/span&gt; &lt;span style="color: blue"&gt;double&lt;/span&gt; pressure; 

&lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;double&lt;/span&gt; Pressure 
{ 
get 
{ 
&lt;span style="color: blue"&gt;return&lt;/span&gt; pressure; 
} 
set 
{ 
pressure = &lt;span style="color: blue"&gt;value&lt;/span&gt;; 
} 
} 
}&lt;/pre&gt;
&lt;/div&gt;

&lt;h3 style="display: none"&gt;High Level Solution:&lt;/h3&gt;

&lt;p style="display: none"&gt;I can implement an Undo stack and Redo stack. Whenever the pressure will change I will maintain the state in the Undo/Redo stacks. For every Undoable/Redoable action there will be an entry in these stack. For this simple scenario one can assume a stack to be implemented as Stack&amp;lt;KeyValuePair&amp;lt;string, string&amp;gt;&amp;gt;, where key will correspond to action and value for the property value in KeyValuePair. On Undoing and Redoing the action I’ll load the state from the stacks and apply on the Barometer object using Stack’s Push and Pop operations. 
  &lt;br /&gt;

  &lt;br /&gt;In order to implement that I will be implementing interfaces listed below&lt;/p&gt;

&lt;div style="display: none"&gt;
  &lt;ul&gt;
    &lt;li&gt;INotifyPropertyChanging &lt;/li&gt;

    &lt;li&gt;INotifyPropertyChanged &lt;/li&gt;
  &lt;/ul&gt;
&lt;/div&gt;

&lt;p&gt;e.g. Pressure has to be updated from “0” to “60”. In this case we can save “0” as it is the previous state in the Undo stack. Redo stack will be empty as there is no action to Redo. The sequence of events for “Pressure” property will be [Before Update&amp;lt;”0”&amp;gt;] –&amp;gt; Write value to Undo Stack –&amp;gt; [Perform Update&amp;lt;”60”&amp;gt;] 
  &lt;br /&gt;

  &lt;br /&gt;Now if I have to to Undo the action that I performed I’ll copy the state from the Undo stack. Then write the state to the Redo stack so that I can Redo the action and then apply the state on the “Pressure” property. 

  &lt;br /&gt;

  &lt;br /&gt;I can use an Command pattern here and if an command implements IUndoable and IRedoable behavior we can have this framework in place. 

  &lt;br /&gt;

  &lt;br /&gt;In this blog I won’t be going into the details of Command pattern and Undo Redo implementation. I can extend this blog if the need arises as the main focus here is to discuss the high level implementation. I’ll focus on the interfaces INotifyPropertyChanging and INotifyPropertyChanged and their usage in this scenario. 

  &lt;br /&gt;&lt;/p&gt;

&lt;h3 style="display: none"&gt;&amp;#160;&lt;/h3&gt;

&lt;h3 style="display: none"&gt;Solution using .Net framework 2.0:&lt;/h3&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p style="display: none"&gt;To implement this prior to .Net Framework 2.0 the general way is displayed in code snippet below&lt;/p&gt;

&lt;p style="display: none" id="codeSnippetWrapper"&gt;&lt;/p&gt;

&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;class&lt;/span&gt; Barometer : INotifyPropertyChanged, INotifyPropertyChanging 
{ 
&lt;span style="color: blue"&gt;private&lt;/span&gt; &lt;span style="color: blue"&gt;double&lt;/span&gt; pressure; 

&lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;double&lt;/span&gt; Pressure 
{ 
get 
{ 
&lt;span style="color: blue"&gt;return&lt;/span&gt; pressure; 
} 
set 
{ 
&lt;span style="color: blue"&gt;if&lt;/span&gt; (&lt;span style="color: blue"&gt;value&lt;/span&gt; != pressure) 
{ 
&lt;span style="color: green"&gt;//Maintaining the temporary copy of event to avoid race condition &lt;/span&gt;
PropertyChangingEventHandler propertyChanging = PropertyChanging; 
&lt;span style="color: blue"&gt;if&lt;/span&gt; (propertyChanging != &lt;span style="color: blue"&gt;null&lt;/span&gt;) 
{ 
propertyChanging(&lt;span style="color: blue"&gt;this&lt;/span&gt;, &lt;span style="color: blue"&gt;new&lt;/span&gt; PropertyChangingEventArgs(&lt;span style="color: #006080"&gt;&amp;quot;&lt;span style="color: red"&gt;Pressure&lt;/span&gt;&amp;quot;&lt;/span&gt;)); 
} 

pressure = &lt;span style="color: blue"&gt;value&lt;/span&gt;;

&lt;span style="color: green"&gt;//Maintaining the temporary copy of event to avoid race condition &lt;/span&gt;
PropertyChangedEventHandler propertyChanged = PropertyChanged; 
&lt;span style="color: blue"&gt;if&lt;/span&gt; (propertyChanged != &lt;span style="color: blue"&gt;null&lt;/span&gt;) 
{ 
propertyChanged(&lt;span style="color: blue"&gt;this&lt;/span&gt;, &lt;span style="color: blue"&gt;new&lt;/span&gt; PropertyChangedEventArgs(&lt;span style="color: #006080"&gt;&amp;quot;&lt;span style="color: red"&gt;Pressure&lt;/span&gt;&amp;quot;&lt;/span&gt;)); 
} 
} 
} 
}

&lt;span style="color: #cc6633"&gt;#region&lt;/span&gt; INotifyPropertyChanged Members 
&lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;event&lt;/span&gt; PropertyChangedEventHandler PropertyChanged; 
&lt;span style="color: #cc6633"&gt;#endregion&lt;/span&gt; 

&lt;span style="color: #cc6633"&gt;#region&lt;/span&gt; INotifyPropertyChanging Members 
&lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;event&lt;/span&gt; PropertyChangingEventHandler PropertyChanging; 
&lt;span style="color: #cc6633"&gt;#endregion&lt;/span&gt; 
}&lt;/pre&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;In the code snippet above I am maintaining the temporary copy to avoid possibility of a race condition in case the last subscriber unsubscribe after the null check and before the event is raised. &lt;/p&gt;

&lt;p&gt;As displayed in Red text we are hard coding the name of the property. Here we have only one property but in real world we had to do the same across all the properties for which we needed to have the same behavior. &lt;/p&gt;

&lt;p&gt;The issues with this approach are&lt;/p&gt;

&lt;div style="display: none"&gt;Cumbersome as you have to do the same across the application &lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;Prone to typing mistakes &lt;/li&gt;

  &lt;li&gt;Any refactoring will break the code &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We can achieve the same without these drawbacks in .Net framework 3.5 and above using Lambda expressions.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;h3&gt;Solution using .Net framework 3.5:&lt;/h3&gt;

&lt;p&gt;The Barometer class updated to use Lambda Expression is displayed in code snippet below 
  &lt;br /&gt;

  &lt;br /&gt;&lt;/p&gt;

&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;class&lt;/span&gt; Barometer : INotifyPropertyChanged, INotifyPropertyChanging 
{ 
&lt;span style="color: blue"&gt;private&lt;/span&gt; &lt;span style="color: blue"&gt;double&lt;/span&gt; pressure; 

&lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;double&lt;/span&gt; Pressure 
{ 
get 
{ 
&lt;span style="color: blue"&gt;return&lt;/span&gt; pressure; 
} 
set 
{ 
&lt;span style="color: green"&gt;//Using Lambda Expressions, Anonymous methods and Extension methods&lt;/span&gt;
PropertyChanged.SetPropertyValue(PropertyChanging, &lt;span style="color: blue"&gt;value&lt;/span&gt;, () =&amp;gt; &lt;span style="color: blue"&gt;this&lt;/span&gt;.Pressure, &lt;span style="color: blue"&gt;new&lt;/span&gt;  Action&amp;lt;&lt;span style="color: blue"&gt;double&lt;/span&gt;&amp;gt;(&lt;span style="color: blue"&gt;delegate&lt;/span&gt;(&lt;span style="color: blue"&gt;double&lt;/span&gt; newValue) { pressure = newValue; })); 
} 
}

&lt;span style="color: #cc6633"&gt;#region&lt;/span&gt; INotifyPropertyChanged Members 
&lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;event&lt;/span&gt; PropertyChangedEventHandler PropertyChanged; 
&lt;span style="color: #cc6633"&gt;#endregion&lt;/span&gt;

&lt;span style="color: #cc6633"&gt;#region&lt;/span&gt; INotifyPropertyChanging Members 
&lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;event&lt;/span&gt; PropertyChangingEventHandler PropertyChanging; 
&lt;span style="color: #cc6633"&gt;#endregion&lt;/span&gt; 
}&lt;/pre&gt;

&lt;br /&gt;The difference with the code snippet in .Net 2.0 version is in the set block in code snippet displayed above. 

&lt;br /&gt;

&lt;br /&gt;Using the Lambda expressions i.e. (()=&amp;gt;this.Pressure) along with anonymous methods and Extension methods we can achieve the same in much better way. 

&lt;br /&gt;

&lt;br /&gt;I have created one more class in which the Extension method SetPropertyValue is defined. This is a generic class and the functionality of method is explained in the inline comments. This is displayed in code snippet below 

&lt;br /&gt;

&lt;br /&gt;

&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;static&lt;/span&gt; &lt;span style="color: blue"&gt;class&lt;/span&gt; PropertyChangeExtensions 
{ 
&lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;static&lt;/span&gt; T SetPropertyValue&amp;lt;T&amp;gt;(&lt;span style="color: blue"&gt;this&lt;/span&gt; PropertyChangedEventHandler postHandler, 
PropertyChangingEventHandler preHandler, T newValue, Expression&amp;lt;Func&amp;lt;T&amp;gt;&amp;gt; oldValueExpression, 
Action&amp;lt;T&amp;gt; setter)

{ 
&lt;span style="color: green"&gt;//Retrieve the old value &lt;/span&gt;
Func&amp;lt;T&amp;gt; getter = oldValueExpression.Compile(); 
T oldValue = getter(); 

&lt;span style="color: green"&gt;//In case new and old value both are equal to default &lt;/span&gt;
&lt;span style="color: green"&gt;//values for that type or are same return &lt;/span&gt;
&lt;span style="color: blue"&gt;if&lt;/span&gt; ((Equals(oldValue, &lt;span style="color: blue"&gt;default&lt;/span&gt;(T)) &amp;amp;&amp;amp; Equals(newValue, &lt;span style="color: blue"&gt;default&lt;/span&gt;(T))) 
|| Equals(oldValue, newValue)) 
{ 
&lt;span style="color: blue"&gt;return&lt;/span&gt; newValue; 
} 

&lt;span style="color: green"&gt;//Retrieve the property that has changed &lt;/span&gt;
var body = oldValueExpression.Body &lt;span style="color: blue"&gt;as&lt;/span&gt; System.Linq.Expressions.MemberExpression; 
var propInfo = body.Member &lt;span style="color: blue"&gt;as&lt;/span&gt; PropertyInfo; 
&lt;span style="color: blue"&gt;string&lt;/span&gt; propName = body.Member.Name; 
var targetExpression = body.Expression &lt;span style="color: blue"&gt;as&lt;/span&gt; ConstantExpression; 
&lt;span style="color: blue"&gt;object&lt;/span&gt; target = targetExpression.Value; 

&lt;span style="color: green"&gt;//Maintaining the temporary copy of event to avoid race condition &lt;/span&gt;
var preHandlerTemp = preHandler; 
&lt;span style="color: green"&gt;//Raise the event before property is changed &lt;/span&gt;
&lt;span style="color: blue"&gt;if&lt;/span&gt; (preHandlerTemp != &lt;span style="color: blue"&gt;null&lt;/span&gt;) 
{ 
preHandlerTemp(target, &lt;span style="color: blue"&gt;new&lt;/span&gt; PropertyChangingEventArgs(propName)); 
} 

&lt;span style="color: green"&gt;//Update the property value &lt;/span&gt;
setter(newValue); 

&lt;span style="color: green"&gt;//Maintaining the temporary copy of event to avoid race condition &lt;/span&gt;
var postHandlerTemp = postHandler; 
&lt;span style="color: green"&gt;//Raise the event after property is changed &lt;/span&gt;
&lt;span style="color: blue"&gt;if&lt;/span&gt; (postHandlerTemp != &lt;span style="color: blue"&gt;null&lt;/span&gt;) 
{ 
postHandlerTemp(target, &lt;span style="color: blue"&gt;new&lt;/span&gt; PropertyChangedEventArgs(propName)); 
}

&lt;span style="color: blue"&gt;return&lt;/span&gt; newValue;
} 
}&lt;/pre&gt;

&lt;p&gt;&lt;/p&gt;

&lt;h3&gt;Summary:&lt;/h3&gt;

&lt;p&gt;Thanks for your patience to read up to this. This can be optimized by avoiding the repeated resolution of the expression tree(happening for every property change event). Implementing some sort of caching strategy will do the trick. Well is this the best solution. I’ll say “Depends”. 
  &lt;br /&gt;

  &lt;br /&gt;Pros:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Code should be easily refactored &lt;/li&gt;

  &lt;li&gt;Performance issues if any in this approach are considered to be insignificant &lt;/li&gt;

  &lt;li&gt;Solution can be extendable by using interfaces like ISerializable and saving state in Undo/Redo stacks for only the event i.e. chunk and not the complete state &lt;/li&gt;

  &lt;li&gt;You can control the properties for which you want to implement this kind of behavior by applying custom attributes &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Cons:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Incase of a object tree in which you are having circular references this approach may or may not work. All depends how the application is designed &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For a complex object tree I think one approach is to start with the parent object and then iterate over the child nodes until you reach the leafs. For every command that can be Undoable/Redoable you need to have and unique ID (GUID) and then you can save the state of the application against that when performing push/pop operation to Stack.&lt;/p&gt;

&lt;h3&gt;References:&lt;/h3&gt;

&lt;p&gt;&lt;a href="http://my.safaribooksonline.com/9780321580481" target="_blank"&gt;More Effective C#: 50 Specific Ways to Improve Your C#&lt;/a&gt;&lt;/p&gt;

&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:050c2bcf-6a4e-4011-bd88-dd85cbd4ed57" class="wlWriterEditableSmartContent"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/.Net+Framework+3.5" rel="tag"&gt;.Net Framework 3.5&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Lambda+Expressions" rel="tag"&gt;Lambda Expressions&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Expression+Trees" rel="tag"&gt;Expression Trees&lt;/a&gt;,&lt;a href="http://technorati.com/tags/INotifyPropertyChanging" rel="tag"&gt;INotifyPropertyChanging&lt;/a&gt;,&lt;a href="http://technorati.com/tags/INotifyPropertyChanged" rel="tag"&gt;INotifyPropertyChanged&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Anonymous+Methods" rel="tag"&gt;Anonymous Methods&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Extension+Methods" rel="tag"&gt;Extension Methods&lt;/a&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10043257" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/atverma/archive/tags/Anonymous+Methods/">Anonymous Methods</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/INotifyPropertyChanged/">INotifyPropertyChanged</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/NET/">NET</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/Extension+Methods/">Extension Methods</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/INotifyPropertyChanging/">INotifyPropertyChanging</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/Expression+Trees/">Expression Trees</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/-NET+Framework+3-5/">.NET Framework 3.5</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/Lambda+Expressions/">Lambda Expressions</category></item><item><title>How to unit test SQL Server 2008 database using Visual Studio 2010</title><link>http://blogs.msdn.com/b/atverma/archive/2010/07/28/how-to-unit-test-sql-server-2008-database-using-visual-studio-2010.aspx</link><pubDate>Wed, 28 Jul 2010 03:05:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10043255</guid><dc:creator>Atul.Verma</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/atverma/rsscomments.aspx?WeblogPostID=10043255</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/atverma/commentapi.aspx?WeblogPostID=10043255</wfw:comment><comments>http://blogs.msdn.com/b/atverma/archive/2010/07/28/how-to-unit-test-sql-server-2008-database-using-visual-studio-2010.aspx#comments</comments><description>&lt;p&gt;In this article I’ll discuss about unit testing SQL Server 2008 Database project using Visual Studio 2010. As Unit tests test the part of the program integration testing becomes easier, moreover unit tests help enhancing, maintaining or extending a solution provided they are well written. This is first part of this series “How to unit test SQL Server 2008 database using Visual Studio 2010”. The next parts of this series are&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/b/atverma/archive/2010/08/22/how-to-unit-test-sql-server-2008-database-using-visual-studio-2010-part-2.aspx" target="_blank"&gt;Unit test SQL Server 2008 - Part 2&lt;/a&gt; – Focused on internals of database unit testing i.e. assemblies&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/b/atverma/archive/2010/08/22/how-to-unit-test-sql-server-2008-database-using-visual-studio-2010-part-3.aspx" target="_blank"&gt;Unit test SQL Server 2008 - Part 3&lt;/a&gt; – Focused on data generation, schema comparison, data comparison and data driven unit tests&lt;/p&gt; &lt;p&gt;There is no use to write an unit test badly as later on maintainability of the solution suffers. It either has to be a good unit test or no test at all. It’s better to eliminate bugs early rather than late and that is where unit tests wins. Secondly they can be fully automated and ideally should be.&lt;/p&gt; &lt;p&gt;Assuming a team is developing a solution and no unit testing is introduced. After 2 weeks they realize that some bugs have been introduced into the system. Now in order to find and fix these the team&lt;/p&gt; &lt;ol&gt; &lt;li&gt;needs to track all the changes to find when it got introduced  &lt;/li&gt;&lt;li&gt;check for the features that are dependent and fix them  &lt;/li&gt;&lt;li&gt;it may happen and to be true happens most of the time that the other features implemented though working fine may break with the fix that will be applied to close these bugs e.g. initial state of the code is S1. Developer A checks in that code and now state is S2. Developer B fixes some bug that was there in S1. As Developer B is working on codebase S2 so after he fixes the bug the state of code is S3. It was reported that there was an bug in changes Developer A made. Now as Developer B has checked in on state S2 and if those depend on Developer A changes that means after Developer A will fix his part, Developer B changes will break. See how much havoc it can create as here I considered only 2 check ins and 2 Developers. &lt;/li&gt;&lt;/ol&gt; &lt;p&gt;This is where the power of writing good unit tests kick in. This ripple effect of bugs had not happened if unit testing framework was incorporated into the system. This adds to the confidence of the team and confidence can have a positive effect beyond the boundaries of the team. The next point is “Is unit testing a overload” and the answer is “No” unless you write bad unit tests.&lt;/p&gt; &lt;p&gt;“With power comes great responsibility” quote from Spiderman movie seems to be the right answer. I can go deep into unit tests but in this article I’ll discuss how we can unit test SQL Server 2008 database using Visual Studio 2010. &lt;/p&gt; &lt;p&gt;&lt;span style="color: #c0c0c0"&gt;There are templates for SQL Server 2005 database project in Visual Studio 2008/2010 but those are out of scope of this article as I have not tried them. They may or may not have the same workflow as discussed later so I will restrict the scope of this article to only VS 2010 and SQL Server 2008.&lt;/span&gt;&lt;/p&gt; &lt;h3&gt;Software:&lt;/h3&gt; &lt;p&gt;VS 2010 Ultimate&lt;/p&gt; &lt;p&gt;SQL Server 2008&lt;/p&gt; &lt;h3&gt;Test Data:&lt;/h3&gt; &lt;p&gt;In this example as displayed below I will implement unit test for adding a Student i.e. uspAddStudent store procedure. If unit test has to be written for uspAddEventPass stored procedure then we need to set pre-test conditions as it has foreign key relation to Student and Event tables along with the test condition.&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/0247.image_5F00_2F65F894.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/3817.image_5F00_thumb_5F00_776404B0.png" width="711" height="400" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;Please find below the SQL script for creating the test database for unit testing. This script will be imported so please save this to file.&lt;/p&gt; &lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'Courier New', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt; &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;USE&lt;/span&gt; [SampleDB]&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;GO&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;/****** Object:  Table [dbo].[Event]    Script Date: 07/27/2010 06:20:36 ******/&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;SET&lt;/span&gt; ANSI_NULLS &lt;span style="color: #0000ff"&gt;ON&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;GO&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;SET&lt;/span&gt; QUOTED_IDENTIFIER &lt;span style="color: #0000ff"&gt;ON&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;GO&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;CREATE&lt;/span&gt; &lt;span style="color: #0000ff"&gt;TABLE&lt;/span&gt; [dbo].[Event](&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;[EventId] [bigint] &lt;span style="color: #0000ff"&gt;IDENTITY&lt;/span&gt;(1,1) &lt;span style="color: #0000ff"&gt;NOT&lt;/span&gt; &lt;span style="color: #0000ff"&gt;NULL&lt;/span&gt;,&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;[EventName] [&lt;span style="color: #0000ff"&gt;nchar&lt;/span&gt;](100) &lt;span style="color: #0000ff"&gt;NOT&lt;/span&gt; &lt;span style="color: #0000ff"&gt;NULL&lt;/span&gt;,&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;CONSTRAINT&lt;/span&gt; [PK_Event] &lt;span style="color: #0000ff"&gt;PRIMARY&lt;/span&gt; &lt;span style="color: #0000ff"&gt;KEY&lt;/span&gt; &lt;span style="color: #0000ff"&gt;CLUSTERED&lt;/span&gt; &lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;(&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;[EventId] &lt;span style="color: #0000ff"&gt;ASC&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;)&lt;span style="color: #0000ff"&gt;WITH&lt;/span&gt; (PAD_INDEX  = &lt;span style="color: #0000ff"&gt;OFF&lt;/span&gt;, STATISTICS_NORECOMPUTE  = &lt;span style="color: #0000ff"&gt;OFF&lt;/span&gt;, IGNORE_DUP_KEY = &lt;span style="color: #0000ff"&gt;OFF&lt;/span&gt;, ALLOW_ROW_LOCKS  = &lt;span style="color: #0000ff"&gt;ON&lt;/span&gt;, ALLOW_PAGE_LOCKS  = &lt;span style="color: #0000ff"&gt;ON&lt;/span&gt;) &lt;span style="color: #0000ff"&gt;ON&lt;/span&gt; [&lt;span style="color: #0000ff"&gt;PRIMARY&lt;/span&gt;]&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;) &lt;span style="color: #0000ff"&gt;ON&lt;/span&gt; [&lt;span style="color: #0000ff"&gt;PRIMARY&lt;/span&gt;]&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;GO&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;/****** Object:  Table [dbo].[Student]    Script Date: 07/27/2010 06:20:36 ******/&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;SET&lt;/span&gt; ANSI_NULLS &lt;span style="color: #0000ff"&gt;ON&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;GO&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;SET&lt;/span&gt; QUOTED_IDENTIFIER &lt;span style="color: #0000ff"&gt;ON&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;GO&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;CREATE&lt;/span&gt; &lt;span style="color: #0000ff"&gt;TABLE&lt;/span&gt; [dbo].[Student](&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;[StudentId] [bigint] &lt;span style="color: #0000ff"&gt;IDENTITY&lt;/span&gt;(1,1) &lt;span style="color: #0000ff"&gt;NOT&lt;/span&gt; &lt;span style="color: #0000ff"&gt;NULL&lt;/span&gt;,&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;[StudentName] [&lt;span style="color: #0000ff"&gt;nchar&lt;/span&gt;](100) &lt;span style="color: #0000ff"&gt;NOT&lt;/span&gt; &lt;span style="color: #0000ff"&gt;NULL&lt;/span&gt;,&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;CONSTRAINT&lt;/span&gt; [PK_Student] &lt;span style="color: #0000ff"&gt;PRIMARY&lt;/span&gt; &lt;span style="color: #0000ff"&gt;KEY&lt;/span&gt; &lt;span style="color: #0000ff"&gt;CLUSTERED&lt;/span&gt; &lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;(&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;[StudentId] &lt;span style="color: #0000ff"&gt;ASC&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;)&lt;span style="color: #0000ff"&gt;WITH&lt;/span&gt; (PAD_INDEX  = &lt;span style="color: #0000ff"&gt;OFF&lt;/span&gt;, STATISTICS_NORECOMPUTE  = &lt;span style="color: #0000ff"&gt;OFF&lt;/span&gt;, IGNORE_DUP_KEY = &lt;span style="color: #0000ff"&gt;OFF&lt;/span&gt;, ALLOW_ROW_LOCKS  = &lt;span style="color: #0000ff"&gt;ON&lt;/span&gt;, ALLOW_PAGE_LOCKS  = &lt;span style="color: #0000ff"&gt;ON&lt;/span&gt;) &lt;span style="color: #0000ff"&gt;ON&lt;/span&gt; [&lt;span style="color: #0000ff"&gt;PRIMARY&lt;/span&gt;]&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;) &lt;span style="color: #0000ff"&gt;ON&lt;/span&gt; [&lt;span style="color: #0000ff"&gt;PRIMARY&lt;/span&gt;]&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;GO&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;/****** Object:  Table [dbo].[EventPass]    Script Date: 07/27/2010 06:20:37 ******/&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;SET&lt;/span&gt; ANSI_NULLS &lt;span style="color: #0000ff"&gt;ON&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;GO&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;SET&lt;/span&gt; QUOTED_IDENTIFIER &lt;span style="color: #0000ff"&gt;ON&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;GO&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;CREATE&lt;/span&gt; &lt;span style="color: #0000ff"&gt;TABLE&lt;/span&gt; [dbo].[EventPass](&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;[EventPassId] [bigint] &lt;span style="color: #0000ff"&gt;IDENTITY&lt;/span&gt;(1,1) &lt;span style="color: #0000ff"&gt;NOT&lt;/span&gt; &lt;span style="color: #0000ff"&gt;NULL&lt;/span&gt;,&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;[EventId] [bigint] &lt;span style="color: #0000ff"&gt;NOT&lt;/span&gt; &lt;span style="color: #0000ff"&gt;NULL&lt;/span&gt;,&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;[StudentId] [bigint] &lt;span style="color: #0000ff"&gt;NOT&lt;/span&gt; &lt;span style="color: #0000ff"&gt;NULL&lt;/span&gt;,&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;CONSTRAINT&lt;/span&gt; [PK_EventPass] &lt;span style="color: #0000ff"&gt;PRIMARY&lt;/span&gt; &lt;span style="color: #0000ff"&gt;KEY&lt;/span&gt; &lt;span style="color: #0000ff"&gt;CLUSTERED&lt;/span&gt; &lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;(&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;[EventPassId] &lt;span style="color: #0000ff"&gt;ASC&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;)&lt;span style="color: #0000ff"&gt;WITH&lt;/span&gt; (PAD_INDEX  = &lt;span style="color: #0000ff"&gt;OFF&lt;/span&gt;, STATISTICS_NORECOMPUTE  = &lt;span style="color: #0000ff"&gt;OFF&lt;/span&gt;, IGNORE_DUP_KEY = &lt;span style="color: #0000ff"&gt;OFF&lt;/span&gt;, ALLOW_ROW_LOCKS  = &lt;span style="color: #0000ff"&gt;ON&lt;/span&gt;, ALLOW_PAGE_LOCKS  = &lt;span style="color: #0000ff"&gt;ON&lt;/span&gt;) &lt;span style="color: #0000ff"&gt;ON&lt;/span&gt; [&lt;span style="color: #0000ff"&gt;PRIMARY&lt;/span&gt;]&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;) &lt;span style="color: #0000ff"&gt;ON&lt;/span&gt; [&lt;span style="color: #0000ff"&gt;PRIMARY&lt;/span&gt;]&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;GO&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;/****** Object:  StoredProcedure [dbo].[uspAddStudent]    Script Date: 07/27/2010 06:20:38 ******/&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;SET&lt;/span&gt; ANSI_NULLS &lt;span style="color: #0000ff"&gt;ON&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;GO&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;SET&lt;/span&gt; QUOTED_IDENTIFIER &lt;span style="color: #0000ff"&gt;ON&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;GO&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;-- =============================================&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;-- Author:        &amp;lt;Author,,Name&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;-- Create date: &amp;lt;Create Date,,&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;-- Description:    &amp;lt;Description,,&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;-- =============================================&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;CREATE&lt;/span&gt; &lt;span style="color: #0000ff"&gt;PROCEDURE&lt;/span&gt; [dbo].[uspAddStudent]&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;-- Add the parameters for the stored procedure here&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;@StudentName &lt;span style="color: #0000ff"&gt;nchar&lt;/span&gt;(100)    &lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;AS&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;BEGIN&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;-- SET NOCOUNT ON added to prevent extra result sets from&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;-- interfering with SELECT statements.&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;SET&lt;/span&gt; NOCOUNT &lt;span style="color: #0000ff"&gt;ON&lt;/span&gt;;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;-- Insert statements for procedure here&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;INSERT &lt;span style="color: #0000ff"&gt;INTO&lt;/span&gt; [dbo].[Student]&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;([StudentName])&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;VALUES&lt;/span&gt;(@StudentName)&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;END&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;GO&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;/****** Object:  StoredProcedure [dbo].[uspAddEvent]    Script Date: 07/27/2010 06:20:38 ******/&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;SET&lt;/span&gt; ANSI_NULLS &lt;span style="color: #0000ff"&gt;ON&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;GO&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;SET&lt;/span&gt; QUOTED_IDENTIFIER &lt;span style="color: #0000ff"&gt;ON&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;GO&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;-- =============================================&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;-- Author:        &amp;lt;Author,,Name&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;-- Create date: &amp;lt;Create Date,,&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;-- Description:    &amp;lt;Description,,&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;-- =============================================&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;CREATE&lt;/span&gt; &lt;span style="color: #0000ff"&gt;PROCEDURE&lt;/span&gt; [dbo].[uspAddEvent]&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;-- Add the parameters for the stored procedure here&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;@EventName &lt;span style="color: #0000ff"&gt;nchar&lt;/span&gt;(100)    &lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;AS&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;BEGIN&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;-- SET NOCOUNT ON added to prevent extra result sets from&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;-- interfering with SELECT statements.&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;SET&lt;/span&gt; NOCOUNT &lt;span style="color: #0000ff"&gt;ON&lt;/span&gt;;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;-- Insert statements for procedure here&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;INSERT &lt;span style="color: #0000ff"&gt;INTO&lt;/span&gt; [dbo].[Event]&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;([EventName])&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;VALUES&lt;/span&gt;(@EventName)&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;END&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;GO&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;/****** Object:  StoredProcedure [dbo].[uspGetEventDetails]    Script Date: 07/27/2010 06:20:38 ******/&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;SET&lt;/span&gt; ANSI_NULLS &lt;span style="color: #0000ff"&gt;ON&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;GO&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;SET&lt;/span&gt; QUOTED_IDENTIFIER &lt;span style="color: #0000ff"&gt;ON&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;GO&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;-- =============================================&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;-- Author:        &amp;lt;Author,,Name&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;-- Create date: &amp;lt;Create Date,,&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;-- Description:    &amp;lt;Description,,&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;-- =============================================&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;CREATE&lt;/span&gt; &lt;span style="color: #0000ff"&gt;PROCEDURE&lt;/span&gt; [dbo].[uspGetEventDetails]&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;AS&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;BEGIN&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;-- SET NOCOUNT ON added to prevent extra result sets from&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;-- interfering with SELECT statements.&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;SET&lt;/span&gt; NOCOUNT &lt;span style="color: #0000ff"&gt;ON&lt;/span&gt;;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;-- Insert statements for procedure here&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;SELECT&lt;/span&gt; EP.[EventPassId],EP.[EventId], E.EventName, EP.[StudentId], S.StudentName      &lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;FROM&lt;/span&gt; [dbo].[EventPass] &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; EP&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;INNER&lt;/span&gt; &lt;span style="color: #0000ff"&gt;JOIN&lt;/span&gt; .dbo.Student &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; S&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;ON&lt;/span&gt; EP.StudentId = S.StudentId&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;INNER&lt;/span&gt; &lt;span style="color: #0000ff"&gt;JOIN&lt;/span&gt; .dbo.[Event] &lt;span style="color: #0000ff"&gt;As&lt;/span&gt; E&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;ON&lt;/span&gt; EP.[EventId] = E.[EventId]&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;END&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;GO&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;/****** Object:  StoredProcedure [dbo].[uspAddEventPass]    Script Date: 07/27/2010 06:20:38 ******/&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;SET&lt;/span&gt; ANSI_NULLS &lt;span style="color: #0000ff"&gt;ON&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;GO&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;SET&lt;/span&gt; QUOTED_IDENTIFIER &lt;span style="color: #0000ff"&gt;ON&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;GO&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;-- =============================================&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;-- Author:        &amp;lt;Author,,Name&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;-- Create date: &amp;lt;Create Date,,&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;-- Description:    &amp;lt;Description,,&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;-- =============================================&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;CREATE&lt;/span&gt; &lt;span style="color: #0000ff"&gt;PROCEDURE&lt;/span&gt; [dbo].[uspAddEventPass]&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;-- Add the parameters for the stored procedure here&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;@EventId bigint,&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;@StudentId bigint&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;AS&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;BEGIN&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;-- SET NOCOUNT ON added to prevent extra result sets from&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;-- interfering with SELECT statements.&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;SET&lt;/span&gt; NOCOUNT &lt;span style="color: #0000ff"&gt;ON&lt;/span&gt;;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;-- Insert statements for procedure here&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;INSERT &lt;span style="color: #0000ff"&gt;INTO&lt;/span&gt; [dbo].[EventPass]&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;([EventId]&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;,[StudentId])&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;VALUES&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;(@EventId&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;,@StudentId)&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;END&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;GO&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;/****** Object:  ForeignKey [FK_EventPass_Event]    Script Date: 07/27/2010 06:20:37 ******/&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;ALTER&lt;/span&gt; &lt;span style="color: #0000ff"&gt;TABLE&lt;/span&gt; [dbo].[EventPass]  &lt;span style="color: #0000ff"&gt;WITH&lt;/span&gt; &lt;span style="color: #0000ff"&gt;CHECK&lt;/span&gt; &lt;span style="color: #0000ff"&gt;ADD&lt;/span&gt;  &lt;span style="color: #0000ff"&gt;CONSTRAINT&lt;/span&gt; [FK_EventPass_Event] &lt;span style="color: #0000ff"&gt;FOREIGN&lt;/span&gt; &lt;span style="color: #0000ff"&gt;KEY&lt;/span&gt;([EventId])&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;REFERENCES&lt;/span&gt; [dbo].[Event] ([EventId])&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;GO&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;ALTER&lt;/span&gt; &lt;span style="color: #0000ff"&gt;TABLE&lt;/span&gt; [dbo].[EventPass] &lt;span style="color: #0000ff"&gt;CHECK&lt;/span&gt; &lt;span style="color: #0000ff"&gt;CONSTRAINT&lt;/span&gt; [FK_EventPass_Event]&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;GO&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;/****** Object:  ForeignKey [FK_EventPass_Student]    Script Date: 07/27/2010 06:20:37 ******/&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;ALTER&lt;/span&gt; &lt;span style="color: #0000ff"&gt;TABLE&lt;/span&gt; [dbo].[EventPass]  &lt;span style="color: #0000ff"&gt;WITH&lt;/span&gt; &lt;span style="color: #0000ff"&gt;CHECK&lt;/span&gt; &lt;span style="color: #0000ff"&gt;ADD&lt;/span&gt;  &lt;span style="color: #0000ff"&gt;CONSTRAINT&lt;/span&gt; [FK_EventPass_Student] &lt;span style="color: #0000ff"&gt;FOREIGN&lt;/span&gt; &lt;span style="color: #0000ff"&gt;KEY&lt;/span&gt;([StudentId])&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;REFERENCES&lt;/span&gt; [dbo].[Student] ([StudentId])&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;GO&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;ALTER&lt;/span&gt; &lt;span style="color: #0000ff"&gt;TABLE&lt;/span&gt; [dbo].[EventPass] &lt;span style="color: #0000ff"&gt;CHECK&lt;/span&gt; &lt;span style="color: #0000ff"&gt;CONSTRAINT&lt;/span&gt; [FK_EventPass_Student]&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;GO&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/div&gt;&lt;/div&gt;
&lt;h3&gt;Steps:&lt;/h3&gt;
&lt;h4&gt;Step 1:&lt;/h4&gt;
&lt;p&gt;Open Visual Studio and create a new SQL Server 2008 Database Project as displayed below&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/1261.image_5F00_2FFE88F1.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/5327.image_5F00_thumb_5F00_4266D9A6.png" width="680" height="230" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt; Step 2: &lt;/h4&gt;
&lt;p&gt;Save the test SQL script for on you machine. Right click the project and click import script and import the saved script as displayed below&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/8154.image1_5F00_5AE65129.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/2605.image1_5F00_thumb_5F00_0AC0F2EB.png" width="693" height="241" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;After import is done you will find the schema objects as highlighted below&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/8081.image6_5F00_5EE0792E.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/2234.image6_5F00_thumb_5F00_6A298D6B.png" width="291" height="423" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;h4&gt;Step 3:&lt;/h4&gt;
&lt;p&gt;In the Properties –&amp;gt; Deploy tab of the project set&lt;/p&gt;
&lt;p&gt;Configure deployment settings for –&amp;gt; My Isolated development environment&lt;/p&gt;
&lt;p&gt;Deploy Action –&amp;gt; Create a deployment script(.sql) and deploy to database&lt;/p&gt;
&lt;p&gt;Target Connection –&amp;gt; Edit/New connection&lt;/p&gt;
&lt;p&gt;Deployment configuration file –&amp;gt; Edit –&amp;gt; Uncheck Block incremental deployment if data loss might occur checkbox &lt;/p&gt;
&lt;p&gt;as displayed below&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/2234.image18_5F00_34D05539.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/7360.image18_5F00_thumb_5F00_2B27E703.png" width="705" height="357" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt; Here an isolated development environment is set so that each database developer can make and test changes without affecting other members of the team. The isolated database development environment is based on the database project that contains the definitions for all the objects that are in the production database.&lt;/p&gt;
&lt;p&gt;Create a deployment script(.sql) and deploy to database is selected as we want the database project to be deployed for each build configuration.&lt;/p&gt;
&lt;p&gt;When you make changes to a database project and deploy them to a database server, some changes can result in data loss from database project being dropped and recreated. Here data loss is allowed as we are working in an isolated development environment on a database that is populated with test data.&lt;/p&gt;
&lt;p&gt;Save changes and Build the solution.&lt;/p&gt;
&lt;h4&gt;Step 4:&lt;/h4&gt;
&lt;p&gt;Deploy this project as displayed below&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/3666.image23_5F00_34244CB7.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/3187.image23_5F00_thumb_5F00_5F886DB1.png" width="388" height="177" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;You can configure the properties as displayed below. If you click Show All files then you can view the files generated e.g. in Debug mode. The connection string that you specified is saved in sql –&amp;gt; debug –&amp;gt; UnitTestDB.deploymanifest&amp;nbsp; &lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/8473.image29_5F00_14D18017.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/4682.image29_5F00_thumb_5F00_51A601E9.png" width="256" height="421" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;Step 5:&lt;/h4&gt;
&lt;p&gt;I’ll now create database unit tests for the stored procedures. As displayed below go to View –&amp;gt; Database Schema View and then right click the stored procedure for which you want to write unit test and click Create Unit Tests as displayed below.&lt;/p&gt;
&lt;p&gt;In case this option is disabled then there must be some issue with the sql file that has been imported and check the Error List for Warnings/Errors e.g. in my case I had specified [Database].[Schema].[Object] in one of the store procedure and though there was warning but I ignored as there were no errors :) and when I tried to create the unit test the option was disabled. The fix was to use [Schema].[Object] as displayed below&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/5672.image33_5F00_65FBA1A7.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/4604.image33_5F00_thumb_5F00_58B51894.png" width="518" height="155" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/0815.image37_5F00_75DAC09E.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/0755.image37_5F00_thumb_5F00_5DF3D978.png" width="676" height="483" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Now select the procedures as displayed below&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/4087.image42_5F00_079708D2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/5670.image42_5F00_thumb_5F00_2FE63B26.png" width="499" height="439" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;h4&gt;Step 6:&lt;/h4&gt;
&lt;p&gt;In the configuration dialog for project ‘SampleDBTestProject’ configure options as displayed below&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/8637.image58_5F00_467863A0.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/8664.image58_5F00_thumb_5F00_1595AC35.png" width="688" height="476" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;The connection string that you specified is saved in the app.config of this project.&lt;/p&gt;
&lt;h4&gt;Step 7:&lt;/h4&gt;
&lt;p&gt;Open the SampleDBStoredProcedureUnitTests as displayed below&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/7510.image62_5F00_44F3F534.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/0763.image62_5F00_thumb_5F00_7E968F1E.png" width="671" height="403" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Select dbo_uspAddStudentTest and in Test Conditions remove Inconclusive test condition. If an Inconclusive Test Condition is added to a database unit test, the test will always fail with an Inconclusive result. It’s not a passed result, nor a failed result. It indicates that the results of the test could not be verified. Add Row Count test condition&amp;nbsp; and set Row Count = 1 as only one row gets added when this store procedure runs as displayed below&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/3312.image73_5F00_2B7BCC2D.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/4722.image73_5F00_thumb_5F00_7B0547B6.png" width="686" height="452" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;The snippet is displayed below &lt;/p&gt;
&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'Courier New', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
&lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;-- unit test for dbo.uspAddStudent&lt;/span&gt;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;DECLARE&lt;/span&gt; @RC &lt;span style="color: #0000ff"&gt;AS&lt;/span&gt; &lt;span style="color: #0000ff"&gt;INT&lt;/span&gt;, @StudentName &lt;span style="color: #0000ff"&gt;AS&lt;/span&gt; NVARCHAR (100);&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;SELECT&lt;/span&gt; @RC = 0,&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;@StudentName = &lt;span style="color: #006080"&gt;'Unit Test'&lt;/span&gt;;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;EXECUTE&lt;/span&gt; @RC = [dbo].[uspAddStudent] @StudentName;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--crlf--&gt;&lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;SELECT&lt;/span&gt; * &lt;span style="color: #0000ff"&gt;FROM&lt;/span&gt; [dbo].[Student];&lt;/pre&gt;&lt;!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/!--crlf--&gt;&lt;/div&gt;&lt;/div&gt;
&lt;h4&gt; Step 8:&lt;/h4&gt;
&lt;p&gt;Go to Test –&amp;gt; Windows –&amp;gt; Test View and select dbo_uspAddEventTest and Run Selection as displayed below.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/0121.image77_5F00_1AA3FBB2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36-metablogapi/2727.image77_5F00_thumb_5F00_1ECDD377.png" width="716" height="504" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;In the Test Results the results of the tests run will be displayed. In case a particular test fails it will display as failed and the reason for failure.&lt;/p&gt;
&lt;p&gt;In the same way the unit tests for other stored procedures can be written by specifying the Pre-Test/Test/Post-Test Conditions and Test Conditions.&lt;/p&gt;
&lt;p&gt;The link to the next part of this series is &lt;a href="http://blogs.msdn.com/b/atverma/archive/2010/08/22/how-to-unit-test-sql-server-2008-database-using-visual-studio-2010-part-2.aspx" target="_blank"&gt;Unit test SQL Server 2008 - Part 2&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:a05c6592-36fd-4b17-a8f1-8c09b73a4a65" class="wlWriterEditableSmartContent"&gt;del.icio.us Tags: &lt;a href="http://del.icio.us/popular/Visual+Studio+2010" rel="tag"&gt;Visual Studio 2010&lt;/a&gt;,&lt;a href="http://del.icio.us/popular/SQL+Server+2008" rel="tag"&gt;SQL Server 2008&lt;/a&gt;,&lt;a href="http://del.icio.us/popular/Unit+Test" rel="tag"&gt;Unit Test&lt;/a&gt;,&lt;a href="http://del.icio.us/popular/Test+View" rel="tag"&gt;Test View&lt;/a&gt;,&lt;a href="http://del.icio.us/popular/Database+Schema+View" rel="tag"&gt;Database Schema View&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;References: &lt;a title="http://msdn.microsoft.com/en-us/library/aa833283.aspx" href="http://msdn.microsoft.com/en-us/library/aa833283.aspx"&gt;http://msdn.microsoft.com/en-us/library/aa833283.aspx&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10043255" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-37-36/1351.UnitTestDB.zip" length="387820" type="application/zip" /><category domain="http://blogs.msdn.com/b/atverma/archive/tags/Visual+Studio+2010/">Visual Studio 2010</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/SQL/">SQL</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/SQL+Server+2008/">SQL Server 2008</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/Unit+Test/">Unit Test</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/Database/">Database</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/Visual+Studio+2010+Ultimate/">Visual Studio 2010 Ultimate</category><category domain="http://blogs.msdn.com/b/atverma/archive/tags/Test+View/">Test View</category></item></channel></rss>