<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-2990193854398450266</id><updated>2025-08-23T14:27:15.264+00:00</updated><category term="C#"/><category term=".Net Routing"/><category term="Asp.Net Web Forms"/><category term="Asp.Net MVC5"/><category term="Unit Test"/><category term="Azure"/><category term="Continuous Integration"/><category term="EF6"/><category term="Entity Framework 6"/><category term="Azure Application Gateway"/><category term="Azure Service Fabric"/><category term="Design Patterns"/><category term="JQuery"/><category term="Mocking &amp; Faking"/><category term="TFS"/><category term="TFS Build Tasks"/><category term="TFS Release Management"/><category term="Test Double"/><category term="Unity Dependency Injection"/><category term="VSTS Builds &amp; Release"/><category term="WCF"/><category term=".RunSettings"/><category term="Asp.Net MVC"/><category term="Asp.Net MVC3"/><category term="Azure App Service"/><category term="AzureDevOps"/><category term="Code Coverage"/><category term="Code First"/><category term="Quality Gates"/><category term="SSL"/><category term="Service Fabric"/><title type='text'>Jon Lanceley&#39;s .Net Blog</title><subtitle type='html'>A blog for .Net developers, covering all things .net</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://jonlanceley.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2990193854398450266/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://jonlanceley.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Jon</name><uri>http://www.blogger.com/profile/03999374060620875716</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtN6KAyfs2XT5axA13YSBK6vG1fODGqFwkd7i3EgUB0JjSkFLFVaAZ4pbpaS_vohqo9WxkqepTFpoOWWpFhX_ozDe4BOvA-JHUiJlQBcVNk713PsbLK_Hj96vnzr2hHx0/s113/Me2.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>20</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-2990193854398450266.post-1155988713024919523</id><published>2018-12-22T06:55:00.001+00:00</published><updated>2018-12-22T06:58:05.707+00:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="AzureDevOps"/><category scheme="http://www.blogger.com/atom/ns#" term="Continuous Integration"/><category scheme="http://www.blogger.com/atom/ns#" term="Quality Gates"/><category scheme="http://www.blogger.com/atom/ns#" term="VSTS Builds &amp; Release"/><title type='text'>Setting up an Azure DevOps Post Deployment Gate that checks Application Insights for any Server Exceptions in the last 10 minutes.</title><content type='html'>&lt;p&gt;We have a release pipleline which deploys a web site to an Azure App Service and then runs a bunch of Selenium tests against the website.&lt;/p&gt;  &lt;p&gt;However that does not test the Azure Function we also deploy. Nor does it check for any errors being reported by the server.&lt;/p&gt;  &lt;p&gt;What we will do is make use of a Post Deployment Gate, which will go and look inside Application Insights and check if any Server Exceptions were logged in the time since the web site was released.&lt;/p&gt;  &lt;p&gt;If any server exceptions are found then the release will not progress to the next environment.    &lt;br /&gt;&lt;/p&gt;  &lt;br /&gt;  &lt;p&gt;&lt;b&gt;1. &lt;/b&gt;&lt;b&gt;Enable API Access in Application Insights&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;Create an API Key if you do not already have one e.g.&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcTEqxZrW3ezHqiSE_1UQVBv3dsQZ4GkBt_lFQIV0Rc9xaedjQdeWbyKk-55DsmOdoAe92L9uPuL9hx8bgu-BDoWX_CQMrkwhv7kfQkPfLy9whQdI0qUbtojEO4OjdRyNV9cnZUpyXOlbd/s1600-h/image%255B26%255D&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhioWf4cxnLyIoIt798m8YcWUBCH0SsJ7M2fWhk9yOpS8LlycN-hRv78PuujLeQ17DlfBxT0ivdMvF7CZxWhm-3JzLyHrnPIfk3OxpvI-3UqsoG4wNPJy_sHShstb3fWfjbs5VXuMLMPLK2/?imgmax=800&quot; width=&quot;667&quot; height=&quot;571&quot; /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;2. &lt;/b&gt;&lt;b&gt;Add a ‘Post Deployment’ gate &lt;/b&gt;&lt;/p&gt;  &lt;p&gt;In the release definition click ‘Post-deployment conditions’ then enable ‘Gates’.&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj93In6S2CPKoB18-gL9LyDlDcPcwz__U0TqizY3vhvGAs-0hgfxceQ2Glfb9bdbC33Ne8V1IVHHsfTYgdBAsoiS5rU7loKtKbor7Fop8FgQxrfa1KQsPbXkk4urcoNaj7O0i5JIP-TrcuQ/s1600-h/image%255B40%255D&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgK9rF2DXArIfcoUMwytZndonVN9Kj11nA_xQC59am5CAODKLGXPEynhgqQtfswvg59mAMsoIbfnEtQEUzpLqcRuwG0LzzBnGVlcGoyeVQwleA23PgTmjtHheCDvihinanhco0w-QuQMm_g/?imgmax=800&quot; width=&quot;710&quot; height=&quot;154&quot; /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Set the delay before evaluation = 2 minutes (this allows extra time for the application insights data to come in before the gates are evaluated, although data should be there because Selenium tests will be running before this step)&lt;/p&gt;  &lt;br /&gt;  &lt;p&gt;Add an Invoke REST API task&lt;/p&gt;  &lt;p&gt;Connection type: Generic&lt;/p&gt;  &lt;p&gt;Generic service connection: Choose the one for the application insights account or Click ‘Manage’ and add this:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;New Service Connection -&amp;gt; Generic&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;Connection name: give it a name e.g. Application Insights Connection&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;Server URL: https://api.applicationinsights.io/v1/apps/&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;Username &amp;amp; password can remain empty&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;e.g.&lt;/p&gt;    &lt;p&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8gj2bPNgmzAhh_6x-yevB62m5vI29fwL1XXHk8OEK7DvRj6fOXcjpSA35NbYQxQ2r1_P80QIFzJ4oscxK2D_6gQvOP97zsFyX9rQDxO_LNxo4gU7vj6vqjqdhPMkGx9YrTtMctnsm3BBH/s1600-h/image%255B41%255D&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEggndU2L9SW_c04MNpfksRIPEeS1PMzHEjU4WmHmzcneaNohxqsFKGtA_qndhEdBrL4L4P3CgdHJ_9wZEycZSx574YBy0MjSo4srLQN1k7TTD9dZX3GE970tDvjZmg9MZbGqHBval5qmY9t/?imgmax=800&quot; width=&quot;453&quot; height=&quot;268&quot; /&gt;&lt;/a&gt;&lt;/p&gt;    &lt;p&gt;Method: Post&lt;/p&gt;    &lt;p&gt;Headers (replace with this): &lt;/p&gt;    &lt;p&gt;{&lt;/p&gt;    &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;quot;Content-Type&amp;quot;:&amp;quot;application/json&amp;quot;, &lt;/p&gt;    &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;quot;x-api-key&amp;quot;: &amp;quot;$(ApplicationInsightsAPIKey)&amp;quot;&lt;/p&gt;    &lt;p&gt;}&lt;/p&gt;    &lt;br /&gt;    &lt;p&gt;Body:&lt;/p&gt;    &lt;p&gt;&lt;u&gt;For all server exceptions use:&lt;/u&gt;&lt;/p&gt;    &lt;p&gt;{&lt;/p&gt;    &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; &amp;quot;query&amp;quot;: &amp;quot;exceptions | where client_Type != &#39;Browser&#39; | where timestamp &amp;gt; ago(10m) | count&amp;quot;&lt;/p&gt;    &lt;p&gt;}&lt;/p&gt;    &lt;p&gt;&lt;u&gt;To filter exceptions to within an assembly you can use (e.g. for all Unity server exceptions):&lt;/u&gt;&lt;/p&gt;    &lt;p&gt;{&lt;/p&gt;    &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; &amp;quot;query&amp;quot;: &amp;quot;exceptions | where client_Type != &#39;Browser&#39; | where assembly contains &#39;Unity&#39; | where timestamp &amp;gt; ago(10m) | count&amp;quot;&lt;/p&gt;    &lt;p&gt;}&lt;/p&gt;    &lt;p&gt;&lt;u&gt;Or to filter on trace messages&lt;/u&gt;&lt;/p&gt;    &lt;p&gt;e.g. If you have an Azure Function that sends emails and writes a trace message when it’s running you can ensure emails are not failing by checking the trace messages.&lt;/p&gt;    &lt;p&gt;{&lt;/p&gt;    &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; &amp;quot;query&amp;quot;: &amp;quot;traces | where operation_Name == &#39;SendEmailFunction&#39; | where message contains &#39;Success&#39; | where client_Type != &#39;Browser&#39;| where timestamp &amp;gt; ago(10m)| count&amp;quot;&lt;/p&gt;    &lt;p&gt;}&lt;/p&gt;    &lt;br /&gt;    &lt;p&gt;&lt;b&gt;Note:&lt;/b&gt; The timestamp is something to play around with, it basically needs to cover:&lt;/p&gt;    &lt;ul&gt;     &lt;li&gt;The time the automated Selenium tests take to run (start to finish) - for us approx. 2 minutes&lt;/li&gt;      &lt;li&gt;+ ‘the delay before evaluation’ (2 minutes we set above)&lt;/li&gt;      &lt;li&gt;+ If the Gates fail they re-evaluate until the 6 minute timeout so we need to ensure the time range allows for this too.&lt;/li&gt;   &lt;/ul&gt;    &lt;p&gt;The reason for this is once the Selenium tests stop they will not generate application insights data so by the time it re-evaluates the gate again there may be no data in app insights and the gate would incorrectly pass.&lt;/p&gt;    &lt;p&gt;Therefore we need to be checking around the last 10 minutes worth of Application Insights data&lt;/p&gt;    &lt;br /&gt;    &lt;p&gt;Url suffix and parameters:&lt;/p&gt;    &lt;p&gt;$(ApplicationInsightsApplicationID)/query&lt;/p&gt;    &lt;br /&gt;    &lt;p&gt;&lt;u&gt;Advanced&lt;/u&gt;&lt;/p&gt;    &lt;p&gt;Completion event: &lt;/p&gt;    &lt;p&gt;ApiResponse&lt;/p&gt;    &lt;p&gt;Success criteria (The below checks for a count of 0 records to be returned):&lt;/p&gt;    &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; eq(jsonpath(&#39;$.tables[0].rows[0]&#39;)[0][0],0)&lt;/p&gt;    &lt;p&gt;Or this makes sure there are records being returned (e.g. &amp;gt; 0)&lt;/p&gt;    &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; ne(jsonpath(&#39;$.tables[0].rows[0]&#39;)[0][0],0)&lt;/p&gt;    &lt;p&gt;&lt;u&gt;&lt;/u&gt;&lt;/p&gt;    &lt;br /&gt;    &lt;p&gt;&lt;u&gt;Evaluation options&lt;/u&gt;&lt;/p&gt;    &lt;p&gt;Time between re-evaluation of gates: 5 minutes&lt;/p&gt;    &lt;p&gt;Minimum duration for steady results after a successful gate evaluation: 0 minutes&lt;/p&gt;    &lt;p&gt;The timeout after which all gates fail: 6 minutes&lt;/p&gt;    &lt;p&gt;Gates and approvals: On successful gates, ask for approvals&lt;/p&gt;    &lt;p&gt;Example:&lt;/p&gt;    &lt;p&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnzvRY0EN_Iwwtj7GLFUpktuRlUyNGa2GymxNEJADCihlZKnHGJZz3DwSThkbnIehaQH3et_ViyRl0-RvW-kcEOxNUUDTm418XG0aF-VqKCrUT_GafUAj5q7-Anre34ekCzOz744Gg3sdK/s1600-h/1%255B11%255D&quot;&gt;&lt;img title=&quot;1&quot; style=&quot;margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;&quot; border=&quot;0&quot; alt=&quot;1&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgK5lqeBq2JuhS67Faor6H_Y4C3YGpS-JNe52QO5QpFKwd4nYkXgNGAfBAGw-eA5e7n73VcDQ-JOrJp5be58AWzk30vGHOuettq3XoKw-SDUGhiRX_mErP1nXG23NKhjS9YU8hQxv_ZSsFu/?imgmax=800&quot; width=&quot;458&quot; height=&quot;952&quot; /&gt;&lt;/a&gt;&lt;/p&gt;    &lt;p&gt;&lt;b&gt;3. &lt;/b&gt;&lt;b&gt;Set Release variables&lt;/b&gt;&lt;/p&gt;    &lt;p&gt;Add these keys with a scope to the Environment you are releasing:&lt;/p&gt;    &lt;p&gt;ApplicationInsightsAPIKey - This one should be a secret so hide the value&lt;/p&gt;    &lt;p&gt;ApplicationInsightsApplicationID&lt;/p&gt;    &lt;p&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiTQD4JZgL3bWVPFFOQh5wipoc45t7PW_LKY-SUYx4r9BV8lfHCOVKF2kJRajVGmirlLNSQ5QWEti76MDL6CwP8-682SllXnZ-DgUG8qIveDAQq_Jjq4yts6yO_JZoeEu2ZkBX2RPQZBD9R/s1600-h/image%255B42%255D&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhVj3Z8Ziw3iXY2hhpfDo8WZ2btD9SHsGWtIY-KCoQSAx9vibBYKlzMlcKkwnH6FOHmN9AzL8cf2YmmgmRx9FIxVLVYEFJyrowYT5a8V9nRWMWZgFw7xC16pnIfbg_GrKP7NTaxI-4RHa2D/?imgmax=800&quot; width=&quot;871&quot; height=&quot;188&quot; /&gt;&lt;/a&gt;&lt;/p&gt;    &lt;br /&gt;    &lt;p&gt;&lt;strong&gt;4. Save and test it by creating a release&lt;/strong&gt;&lt;/p&gt;    &lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;    &lt;br /&gt;    &lt;br /&gt;    &lt;p&gt;&lt;b&gt;Useful Websites&lt;/b&gt;&lt;/p&gt;    &lt;p&gt;The API Explorer web site was very useful in constructing the correct message&lt;/p&gt;    &lt;p&gt;&lt;a href=&quot;https://dev.applicationinsights.io/apiexplorer/postQuery&quot;&gt;https://dev.applicationinsights.io/apiexplorer/postQuery&lt;/a&gt;&lt;/p&gt;    &lt;p&gt;Application Insights ‘Analytics’ was useful in constructing the query&lt;/p&gt;    &lt;p&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxlD2bktlBWPE4qR-lEqtfss9HfMxkxJ3rTydRzMknZ9VMpE54i8NvSJ2v05y4h5QJzaWYux7JQKjSd7rCch6epmOFUTiB0SN8SjIRo90OmOCGsBjlRek2hqqATtNyyUUrQCrGVbF9nsv6/s1600-h/image%255B43%255D&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh8-TGhyphenhyphenV5sGRxWsmF2UC7jqi5T_ZNoo4Gp9hPZ9j-nXVyrGoxUMqd1dDGKE7jLnuKYb_2t3F-KgRXPKnUzf8OnjQs2QdCmjCkG1NyBhwuKyvQb78sVXprFmG1o-lnZmDrg9IiXZNWHvdjd/?imgmax=800&quot; width=&quot;747&quot; height=&quot;459&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&lt;/blockquote&gt;</content><link rel='replies' type='application/atom+xml' href='http://jonlanceley.blogspot.com/feeds/1155988713024919523/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jonlanceley.blogspot.com/2018/12/setting-up-azure-devops-post-deployment.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2990193854398450266/posts/default/1155988713024919523'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2990193854398450266/posts/default/1155988713024919523'/><link rel='alternate' type='text/html' href='http://jonlanceley.blogspot.com/2018/12/setting-up-azure-devops-post-deployment.html' title='Setting up an Azure DevOps Post Deployment Gate that checks Application Insights for any Server Exceptions in the last 10 minutes.'/><author><name>Jon</name><uri>http://www.blogger.com/profile/03999374060620875716</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtN6KAyfs2XT5axA13YSBK6vG1fODGqFwkd7i3EgUB0JjSkFLFVaAZ4pbpaS_vohqo9WxkqepTFpoOWWpFhX_ozDe4BOvA-JHUiJlQBcVNk713PsbLK_Hj96vnzr2hHx0/s113/Me2.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhioWf4cxnLyIoIt798m8YcWUBCH0SsJ7M2fWhk9yOpS8LlycN-hRv78PuujLeQ17DlfBxT0ivdMvF7CZxWhm-3JzLyHrnPIfk3OxpvI-3UqsoG4wNPJy_sHShstb3fWfjbs5VXuMLMPLK2/s72-c?imgmax=800" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2990193854398450266.post-6056082195278343894</id><published>2018-02-17T06:54:00.001+00:00</published><updated>2018-02-17T07:19:55.646+00:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Asp.Net MVC5"/><category scheme="http://www.blogger.com/atom/ns#" term="Azure"/><category scheme="http://www.blogger.com/atom/ns#" term="Azure App Service"/><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="Continuous Integration"/><category scheme="http://www.blogger.com/atom/ns#" term="EF6"/><category scheme="http://www.blogger.com/atom/ns#" term="Entity Framework 6"/><category scheme="http://www.blogger.com/atom/ns#" term="TFS Build Tasks"/><category scheme="http://www.blogger.com/atom/ns#" term="TFS Release Management"/><category scheme="http://www.blogger.com/atom/ns#" term="VSTS Builds &amp; Release"/><title type='text'>Zero downtime Azure App Service deployments with EF6 Code First Migrations and MVC5</title><content type='html'>&lt;p&gt;This post is about how we deploy our production web sites to an Azure Web App Service and execute Entity Framework 6 code first migrations as part of a VSTS Release process.&lt;/p&gt;  &lt;p&gt;&lt;u&gt;&lt;/u&gt;&lt;/p&gt;  &lt;br /&gt;&lt;p&gt;&lt;u&gt;A little bit of history:&lt;/u&gt;&lt;/p&gt;  &lt;p&gt;What we were doing was running dbMigrator.Update() on the start of the website.&lt;/p&gt;  &lt;p&gt;So in Startup.cs we had this:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font color=&quot;#0000ff&quot;&gt;var&lt;/font&gt; efConfiguration = &lt;font color=&quot;#0000ff&quot;&gt;new&lt;/font&gt; Configuration();&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font color=&quot;#0000ff&quot;&gt;var&lt;/font&gt; dbMigrator = &lt;font color=&quot;#0000ff&quot;&gt;new&lt;/font&gt; System.Data.Entity.Migrations.DbMigrator(efConfiguration);&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;dbMigrator.Update();&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;This worked well, it upgraded the database, and applied any seed data. The downside was the site became unusable until all this had finished which for us was about 1 minute.&lt;/p&gt;  &lt;p&gt;This also had a major downside when we turned on Azure auto scaling on the App Plan, when it scaled to more than 1 instance, all instances started up, and all of them called dbMigrator.Update(). Resulting in a fair number of exceptions and the site failing to start.&lt;/p&gt;    &lt;br /&gt;&lt;p&gt;&lt;u&gt;What we now do:&lt;/u&gt;&lt;/p&gt;  &lt;p&gt;We needed to remove the database logic from Startup.cs and do it as part of the VSTS Release process instead. So we deploy the site to a staging slot, execute database migrations via Migrate.exe into the production database (on the build server), and then swap the staging slot to production.&lt;/p&gt;  &lt;p&gt;This does mean the production web site code is running against a newer database schema until the site swaps over, but this is fine as long as the developers code to handle current and current-1 database versions.&amp;#160; This is how production now looks, sharing the same database.&lt;/p&gt;  &lt;p align=&quot;center&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiVufAduOP4NSqDBCPMFeqU-kup0m_vlsTKff0y_Xi1XP4VxhxM0Re1N5cXxCqWkb1LhrLXV6DcI40Yxn4bdwcXRf9W18Y452PWQbwcnIMvBVL5bxl1lo0y-fQiW7dOhsBZiGPEqhDmJ36r/s1600-h/clip_image002%255B3%255D&quot;&gt;&lt;img title=&quot;clip_image002&quot; style=&quot;display: inline; background-image: none;&quot; border=&quot;0&quot; alt=&quot;clip_image002&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgRPd7WWfefp91XDL9SdW2c578QH7-Q1kD4kOzHC2hzbzCdLapHLPH_kZZvlB8EXaVdUUKBtTPPqRvkNF9FfrRB7X4KKk0YZgTbQZiJVDY7A1Biwy8VhEaop8N-V_rHv9PzoMinTd30u9uZ/?imgmax=800&quot; width=&quot;180&quot; height=&quot;219&quot; /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;How to implement this:&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;1. &lt;/b&gt;&lt;b&gt;The build Process&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;As well as packaging up the website into its own Artifact we now package up as another Artifact all the files we need in order to run migrate.exe, so we have 2 extra build tasks as part of our Main branch build:&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihcT_QHezYADYjrVAfJ1dHPvNDDx0AhAcifs8en_R0DiHdMr9QXqyszV8GW3iXr0EK3zwCw2hEh6hJexX8v3YnszmUX2TAclR-Z6dAwBXJQU7XyEBm5p14XbWF3OF-pWI9xB1y_dh8WoSO/s1600-h/clip_image004%255B3%255D&quot;&gt;&lt;img title=&quot;clip_image004&quot; style=&quot;margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;&quot; border=&quot;0&quot; alt=&quot;clip_image004&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYGMNF6LbwMuhyphenhyphenHO_LZ4Psh5hpprIOZNQEOjbFyEyuMMA7VYfB7CmpQIAGLzaBW9FqNQ2zJEJiTBpAKIUIAE5aHiWUpRf-c_Wn5De3kPsjxhxN6Rnbh2d7cXZq49fKcmSIZq-fAg9RaCjC/?imgmax=800&quot; width=&quot;244&quot; height=&quot;81&quot; /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;table cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; align=&quot;center&quot; border=&quot;1&quot;&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign=&quot;top&quot; width=&quot;339&quot;&gt;         &lt;p&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEguMoDYrRw-BlZfVyI5S55CV7ldjuyIZqtq6t-KJyxIWjZjBsb5Sd44Fc3vz-1lTU0pm1b72qwHVhy6PWlGVmJ94V8x54TLR-GLTqSigpHXyQwK8ocEj-_ozSyypGzZzPBLRalODLaRE6al/s1600-h/clip_image006%255B5%255D&quot;&gt;&lt;img title=&quot;clip_image006&quot; style=&quot;display: inline; background-image: none;&quot; border=&quot;0&quot; alt=&quot;clip_image006&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZpUGfPFmmfF-bN1_7Mu-SgqO9n_KKuGbIPniE1cSM2a1-QDNKHIeUSeQ6Jr4cpdBQfmtfanKXGr48KLPLhSgBlHzZvbCr4TLKWnR36yC52XH1Pi0bxeffnbq3zVZKrryPasR7DYGV8zlA/?imgmax=800&quot; width=&quot;380&quot; height=&quot;502&quot; /&gt;&lt;/a&gt;&lt;/p&gt;       &lt;/td&gt;        &lt;td valign=&quot;top&quot; width=&quot;342&quot;&gt;         &lt;p align=&quot;center&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjaWyrX8sxPMn9xffCpZgt3GPQQJu1zbjVoGeB4b0yps8Vi2yDYAAxmMlamxrJWmj8lM1WNQWAdMalUH0EjCkNa78_8hsKpQzbxH17JDZx97vdJk7X9uGIebeA6Fl0KtStbnZccPjg59LU2/s1600-h/clip_image008%255B6%255D&quot;&gt;&lt;img title=&quot;clip_image008&quot; style=&quot;display: inline; background-image: none;&quot; border=&quot;0&quot; alt=&quot;clip_image008&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgr0MNvjahdXzdMeJfRS5F1aumbDotwMQ0nGEkDUs37T6V6ARYHPzanx5w3Vz-jFp2Ki_UUn9pURW7lmwPm7BsscgaqzMqXEa0PJqrwxl4aUXsBiXyLu2kk8vjhpVJHWE5Tr27-zwX16Czr/?imgmax=800&quot; width=&quot;277&quot; height=&quot;524&quot; /&gt;&lt;/a&gt;&lt;/p&gt;       &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;In the contents section:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;line 1 : Copies our dll’s containing our entity framework migrations&lt;/p&gt;    &lt;p&gt;line 2: Copies the DeployDatabase.ps1 PowerShell script below&lt;/p&gt;    &lt;p&gt;line 3: Copies the migrate.exe provided by Entity Framework in the packages folder.&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;u&gt;The DeployDatabase.ps1 PowerShell file contains:&lt;/u&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color=&quot;#008080&quot; size=&quot;1&quot;&gt;#&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color=&quot;#008080&quot; size=&quot;1&quot;&gt;# DeployDatabase.ps1&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color=&quot;#008080&quot; size=&quot;1&quot;&gt;#&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size=&quot;1&quot;&gt;[&lt;font color=&quot;#4bacc6&quot;&gt;CmdletBinding&lt;/font&gt;()]&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size=&quot;1&quot;&gt;Param(&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size=&quot;1&quot;&gt;[&lt;font color=&quot;#4bacc6&quot;&gt;Parameter&lt;/font&gt;(Mandatory=&lt;font color=&quot;#d16349&quot;&gt;$True&lt;/font&gt;,Position=1)]&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size=&quot;1&quot;&gt;[&lt;font color=&quot;#008080&quot;&gt;string&lt;/font&gt;]&lt;font color=&quot;#d16349&quot;&gt;$webAppName&lt;/font&gt;,&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size=&quot;1&quot;&gt;[&lt;font color=&quot;#4bacc6&quot;&gt;Parameter&lt;/font&gt;(Mandatory=&lt;font color=&quot;#d16349&quot;&gt;$False&lt;/font&gt;,Position=2)]&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size=&quot;1&quot;&gt;[&lt;font color=&quot;#008080&quot;&gt;string&lt;/font&gt;]&lt;font color=&quot;#d16349&quot;&gt;$slotName&lt;/font&gt;,&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size=&quot;1&quot;&gt;[&lt;font color=&quot;#4bacc6&quot;&gt;Parameter&lt;/font&gt;(Mandatory=&lt;font color=&quot;#d16349&quot;&gt;$False&lt;/font&gt;,Position=3)]&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size=&quot;1&quot;&gt;[&lt;font color=&quot;#008080&quot;&gt;string&lt;/font&gt;]&lt;font color=&quot;#d16349&quot;&gt;$slotResourceGroup&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size=&quot;1&quot;&gt;)&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color=&quot;#0000ff&quot; size=&quot;1&quot;&gt;cls&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size=&quot;1&quot;&gt;&lt;font color=&quot;#d16349&quot;&gt;$ErrorActionPreference&lt;/font&gt; = &amp;quot;Stop&amp;quot; # Stop as soon as an error occurs&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size=&quot;1&quot;&gt;&lt;font color=&quot;#0000ff&quot;&gt;if&lt;/font&gt;(&lt;font color=&quot;#d16349&quot;&gt;$slotName&lt;/font&gt; -ne &lt;font color=&quot;#d16349&quot;&gt;$null&lt;/font&gt; -and &lt;font color=&quot;#d16349&quot;&gt;$slotName&lt;/font&gt; -ne &#39;&#39;) {&lt;/font&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font size=&quot;1&quot;&gt;&lt;font color=&quot;#d16349&quot;&gt;$isSlot&lt;/font&gt; = &lt;font color=&quot;#d16349&quot;&gt;$True&lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;font size=&quot;1&quot;&gt;}&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size=&quot;1&quot;&gt;&lt;font color=&quot;#0000ff&quot;&gt;else&lt;/font&gt; {&lt;/font&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font size=&quot;1&quot;&gt;&lt;font color=&quot;#d16349&quot;&gt;$isSlot&lt;/font&gt; = &lt;font color=&quot;#d16349&quot;&gt;$False&lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;font size=&quot;1&quot;&gt;}&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size=&quot;1&quot;&gt;&lt;font color=&quot;#0000ff&quot;&gt;Write-Host&lt;/font&gt; &amp;quot;PSScriptRoot : &amp;quot; &lt;font color=&quot;#d16349&quot;&gt;$PSScriptRoot&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size=&quot;1&quot;&gt;&lt;font color=&quot;#0000ff&quot;&gt;Write-host&lt;/font&gt; &amp;quot;Web app: &amp;quot; &lt;font color=&quot;#d16349&quot;&gt;$webAppName&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size=&quot;1&quot;&gt;&lt;font color=&quot;#0000ff&quot;&gt;Write-Host&lt;/font&gt; &amp;quot;Using slot: &amp;quot; $isSlot &amp;quot; &amp;quot; &lt;font color=&quot;#d16349&quot;&gt;$slotName&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size=&quot;1&quot;&gt;&lt;font color=&quot;#0000ff&quot;&gt;Write-Host&lt;/font&gt; &amp;quot;SlotResourceGroup: &amp;quot; &lt;font color=&quot;#d16349&quot;&gt;$slotResourceGroup&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size=&quot;1&quot;&gt;&lt;font color=&quot;#d16349&quot;&gt;$dll&lt;/font&gt; = &amp;quot;SiteDataAccess.Extended.Customer.dll&amp;quot;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size=&quot;1&quot;&gt;&lt;font color=&quot;#0000ff&quot;&gt;Write-Host&lt;/font&gt; &amp;quot;Using dll: &amp;quot; &lt;font color=&quot;#d16349&quot;&gt;$dll&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size=&quot;1&quot;&gt;&lt;font color=&quot;#0000ff&quot;&gt;if&lt;/font&gt;(&lt;font color=&quot;#d16349&quot;&gt;$isSlot&lt;/font&gt;) {&lt;/font&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font size=&quot;1&quot;&gt;&lt;font color=&quot;#d16349&quot;&gt;$GetWebSite&lt;/font&gt; = &lt;font color=&quot;#0000ff&quot;&gt;Get-AzureRmWebAppSlot&lt;/font&gt; -Name &lt;font color=&quot;#d16349&quot;&gt;$webAppName&lt;/font&gt; -Slot &lt;font color=&quot;#d16349&quot;&gt;$slotName&lt;/font&gt; -ResourceGroupName &lt;font color=&quot;#d16349&quot;&gt;$slotResourceGroup&lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;font size=&quot;1&quot;&gt;}&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size=&quot;1&quot;&gt;&lt;font color=&quot;#0000ff&quot;&gt;else&lt;/font&gt; {&lt;/font&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font size=&quot;1&quot;&gt;&lt;font color=&quot;#d16349&quot;&gt;$GetWebSite&lt;/font&gt; = &lt;font color=&quot;#0000ff&quot;&gt;Get-AzureRmWebApp&lt;/font&gt; -Name &lt;font color=&quot;#d16349&quot;&gt;$webAppName&lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;font size=&quot;1&quot;&gt;}&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size=&quot;1&quot;&gt;&lt;font color=&quot;#d16349&quot;&gt;$Connection&lt;/font&gt; = &lt;font color=&quot;#d16349&quot;&gt;$GetWebSite&lt;/font&gt;.SiteConfig.ConnectionStrings | &lt;font color=&quot;#0000ff&quot;&gt;Where&lt;/font&gt; {&lt;font color=&quot;#d16349&quot;&gt;$_&lt;/font&gt;.name -eq &amp;quot;ExtendedSiteDBContext&amp;quot;}&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size=&quot;1&quot;&gt;&lt;font color=&quot;#d16349&quot;&gt;$ConnectionString&lt;/font&gt; = &lt;font color=&quot;#d16349&quot;&gt;$Connection&lt;/font&gt;.ConnectionString&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size=&quot;1&quot;&gt;&lt;font color=&quot;#0000ff&quot;&gt;Write-host&lt;/font&gt; &amp;quot;Executing Database migrations and seeding with Migrate.exe&amp;quot;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size=&quot;1&quot;&gt;&amp;amp; &amp;quot;&lt;font color=&quot;#d16349&quot;&gt;$PSScriptRoot&lt;/font&gt;\migrate.exe&amp;quot; &lt;font color=&quot;#d16349&quot;&gt;$dll&lt;/font&gt; /connectionString=&lt;font color=&quot;#d16349&quot;&gt;$ConnectionString&lt;/font&gt; /connectionProviderName=&amp;quot;System.Data.SqlClient&amp;quot; /verbose&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size=&quot;1&quot;&gt;if (&lt;font color=&quot;#d16349&quot;&gt;$LastExitCode&lt;/font&gt; -ne 0) { &lt;/font&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font size=&quot;1&quot;&gt;&lt;font color=&quot;#0000ff&quot;&gt;throw&lt;/font&gt; &#39;migrate.exe returned a non-zero exit code...&#39;&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;font size=&quot;1&quot;&gt;} &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size=&quot;1&quot;&gt;&lt;font color=&quot;#0000ff&quot;&gt;Write-host&lt;/font&gt; &amp;quot;Finished executing Database migrations and seeding with Migrate.exe&amp;quot;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size=&quot;1&quot;&gt;&lt;font color=&quot;#0000ff&quot;&gt;Write-host&lt;/font&gt; &amp;quot;Finished&amp;quot;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;What that script does when called from an Azure Powershell task in a Release definition is lookup the connectionString from the web app service in Azure and then uses that to call migrate.exe. We did this so we did not have to store any connectionStrings in VSTS. If the sql user in the connectionString used when executing migrate.exe needs different permissions to that of the website you could change this to use VSTS release variables instead.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;  &lt;br /&gt;  &lt;p&gt;&lt;b&gt;2. &lt;/b&gt;&lt;b&gt;The Release definition&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;When we release a site our process is:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;· Stop the deployment slot ‘stage’&lt;/p&gt;    &lt;p&gt;· Deploy the website zip to slot ‘stage’&lt;/p&gt;    &lt;p&gt;· Update the database using the PowerShell script&lt;/p&gt;    &lt;p&gt;· Start the Stage site&lt;/p&gt;    &lt;p&gt;· Swap Stage with production&lt;/p&gt;    &lt;p&gt;· Ping production site &lt;/p&gt;    &lt;p&gt;· Stop the stage site (to save resources)&lt;/p&gt; &lt;/blockquote&gt;  &lt;br /&gt;  &lt;p&gt;Our release definition looks like this:&lt;/p&gt;  &lt;table cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; align=&quot;center&quot; border=&quot;1&quot;&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign=&quot;top&quot; width=&quot;362&quot;&gt;         &lt;p&gt;&lt;b&gt;Release definition&lt;/b&gt;&lt;/p&gt;          &lt;p&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;       &lt;/td&gt;        &lt;td valign=&quot;top&quot; width=&quot;337&quot;&gt;         &lt;p&gt;&lt;b&gt;Task Groups&lt;/b&gt;&lt;/p&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign=&quot;top&quot; width=&quot;362&quot;&gt;         &lt;p&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0PxS9wBf9h9hqeCpFkYmjvUf8iQNEBHv4sYVUIWB8Y2fZFs0P4AeolykCK2s6h7uoIHbes_mKr-ZcF3oJimlOEGG6DVKVeuFgEsyS_Cfhp3m3zaWkWf0GUke6nLfjg-ITHoYjydBCsCfJ/s1600-h/clip_image010%255B5%255D&quot;&gt;&lt;img title=&quot;clip_image010&quot; style=&quot;display: inline; background-image: none;&quot; border=&quot;0&quot; alt=&quot;clip_image010&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQkf5pZg35DoRoFSnN_a2Xml9u52km4DahJAdRZqu22fNiOZ5bTomq86QcFufbf41HSZHgejqNVQDYJ6O67U0vzuYsBXhyphenhyphen1h7Z8zNpV_1bcbyfOKZNPOFEs_WiF7KpZDr334W3lKCa9dgf/?imgmax=800&quot; width=&quot;389&quot; height=&quot;185&quot; /&gt;&lt;/a&gt;&lt;/p&gt;       &lt;/td&gt;        &lt;td valign=&quot;top&quot; width=&quot;337&quot;&gt;         &lt;p&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgBlF9cWnWgY6BaJe3dWJLMTw0380g1XfjdUWAKOcs5P_3RgiJASemKgeXCPSSZqEMh58w_AstQvmTLsfIKIaEsxwdQ1bI7yOeNrPJO5I_lcZ0YvWdxuOqAw1_eV-j0gm-iIo7FNGoSyEUj/s1600-h/clip_image012%255B4%255D&quot;&gt;&lt;img title=&quot;clip_image012&quot; style=&quot;display: inline; background-image: none;&quot; border=&quot;0&quot; alt=&quot;clip_image012&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgB41doS9oTYHuFQkqKtF121CAqSLGUV4Ca2ercDV8Knut-MZIn1L1i4CAmKVw_g6UEwNXwWggD7OL7tm5sBtogXEuUk5lu2Cp_2w065qa8U-8z2uVTRkdgcODWCgAN8MjS-oqrUpvwoid3/?imgmax=800&quot; width=&quot;313&quot; height=&quot;227&quot; /&gt;&lt;/a&gt;&lt;/p&gt;          &lt;p&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgJ7NJe-EPgZIQqkVbfUA7LAabFztisHQy8vxjpGkcuCdCyeD6t36DoM8IATTx0sSHrAsNfGHZa0pV-91v4Vly_gOzLRG6qDvaTnxE34pu85RLFYferJKu8YEy9WLEBjIAcF1iPSk9LOMtR/s1600-h/clip_image014%255B7%255D&quot;&gt;&lt;img title=&quot;clip_image014&quot; style=&quot;display: inline; background-image: none;&quot; border=&quot;0&quot; alt=&quot;clip_image014&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgvCdAt7hbdChTaDpEDOV8THPk7E_PAdw92azC6PHk_Xt9Eg-h7hVqnj1FckiXd6GKDHs2yWbWcSBpm7lLSGAKE36Bm9jkpbfWvcEA44KyFco9dtPKO9xn4kL2wtQF0wXQ_rzsl1yaCGwos/?imgmax=800&quot; width=&quot;347&quot; height=&quot;267&quot; /&gt;&lt;/a&gt;&lt;/p&gt;       &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;The Update Database task is just an Azure PowerShell task containing:&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-etz61k1lSZC8xi5mfyZV4xILFMEJyl8fEXLkwAsMJWlU_pn2HqNUr-9F9ENS0zPQjY_X2XpifwKTVH4sR3nqakmRfDm5CgYoY1JlqoiHxp4-k5llupWMp-vZ6bz8AYAHrYpeqNAiFBC5/s1600-h/clip_image016%255B5%255D&quot;&gt;&lt;img title=&quot;clip_image016&quot; style=&quot;margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;&quot; border=&quot;0&quot; alt=&quot;clip_image016&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh7i7C-ZMyiVodlVjqmzOdBDE6OCOdI86AMK3Xikh3_5jdgeavSaUErSt_nY4TDNjHyqwM00DNI4ZMSjA_gJBAiuBsuoPHvspAG1NhqZdcnH3IuYSRbIWGpLYr9MkyIGGdz55bGxiBVuM__/?imgmax=800&quot; width=&quot;482&quot; height=&quot;539&quot; /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;In Azure the App Service Plan is configured so that the production site and the stage slot are almost identical (baring a few appSetting values). They share the same connectionString and every appSetting and ConnectionString value has the ‘Slot Setting’ checkbox ticked.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;br /&gt;  &lt;p&gt;&lt;strong&gt;Our big gotcha&lt;/strong&gt; &lt;/p&gt;  &lt;p&gt;Was during the swap slots task the website will be warm started automatically by that process hitting localhost under http, or it will try the domain name of the site but again under http. We had this in our filter.config&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font color=&quot;#008080&quot;&gt;// Ensure all http connections are redirected to https&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;filters.Add(&lt;font color=&quot;#0000ff&quot;&gt;new&lt;/font&gt; RequireHttpsAttribute());&lt;/p&gt; &lt;/blockquote&gt;  &lt;br /&gt;  &lt;p&gt;Which meant the warm start process instantly failed to start the site, the swap process continued and the site then started up from cold in production. We could see that because our ping task that pinged the production site, was taking a minute to respond.&lt;/p&gt;  &lt;p&gt;What we had to do was create a custom version of the RequireHttpsattribute, once we did this our ping task responds in 1-3 seconds:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font color=&quot;#008080&quot;&gt;// Ensure all http connections are redirected to https&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;filters.Add(&lt;font color=&quot;#0000ff&quot;&gt;new&lt;/font&gt; CustomRequireHttpsAttribute());&lt;/p&gt;    &lt;br /&gt;    &lt;p&gt;&lt;u&gt;And the code for the attribute is:&lt;/u&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = &lt;font color=&quot;#0000ff&quot;&gt;true&lt;/font&gt;, AllowMultiple = &lt;font color=&quot;#0000ff&quot;&gt;false&lt;/font&gt;)]&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font color=&quot;#0000ff&quot;&gt;public class&lt;/font&gt; &lt;font color=&quot;#4bacc6&quot;&gt;CustomRequireHttpsAttribute&lt;/font&gt; : RequireHttpsAttribute&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;{&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; &lt;font color=&quot;#0000ff&quot;&gt;protected override void&lt;/font&gt; HandleNonHttpsRequest(AuthorizationContext filterContext)&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;{&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; &lt;font color=&quot;#0000ff&quot;&gt;string&lt;/font&gt; ipAddress = filterContext.RequestContext.HttpContext.Request.UserHostAddress;&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; &lt;font color=&quot;#0000ff&quot;&gt;var&lt;/font&gt; userAgent = filterContext.RequestContext.HttpContext.Request.UserAgent.ToLower();&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; &lt;font color=&quot;#008080&quot;&gt;// 0.0.0.0 and 127.0.0.1 and ::1 are used by the Azure App Service Swap Slot process to Warm up the site before swapping the slot to production&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; if(ipAddress == &amp;quot;&lt;font color=&quot;#d16349&quot;&gt;0.0.0.0&lt;/font&gt;&amp;quot; || ipAddress == &lt;font color=&quot;#d16349&quot;&gt;&amp;quot;::1&lt;/font&gt;&amp;quot; || ipAddress == &amp;quot;&lt;font color=&quot;#d16349&quot;&gt;127.0.0.1&lt;/font&gt;&amp;quot;)&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font color=&quot;#008080&quot;&gt;&amp;#160;&amp;#160;&amp;#160; //if(userAgent.Contains(&amp;quot;sitewarmup&amp;quot;)) // doesnt work&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; {&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;font color=&quot;#0000ff&quot;&gt;return&lt;/font&gt;;&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; &lt;font color=&quot;#0000ff&quot;&gt;base&lt;/font&gt;.HandleNonHttpsRequest(filterContext);&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;}&lt;/p&gt;&lt;/blockquote&gt;</content><link rel='replies' type='application/atom+xml' href='http://jonlanceley.blogspot.com/feeds/6056082195278343894/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jonlanceley.blogspot.com/2018/02/zero-downtime-azure-app-service.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2990193854398450266/posts/default/6056082195278343894'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2990193854398450266/posts/default/6056082195278343894'/><link rel='alternate' type='text/html' href='http://jonlanceley.blogspot.com/2018/02/zero-downtime-azure-app-service.html' title='Zero downtime Azure App Service deployments with EF6 Code First Migrations and MVC5'/><author><name>Jon</name><uri>http://www.blogger.com/profile/03999374060620875716</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtN6KAyfs2XT5axA13YSBK6vG1fODGqFwkd7i3EgUB0JjSkFLFVaAZ4pbpaS_vohqo9WxkqepTFpoOWWpFhX_ozDe4BOvA-JHUiJlQBcVNk713PsbLK_Hj96vnzr2hHx0/s113/Me2.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgRPd7WWfefp91XDL9SdW2c578QH7-Q1kD4kOzHC2hzbzCdLapHLPH_kZZvlB8EXaVdUUKBtTPPqRvkNF9FfrRB7X4KKk0YZgTbQZiJVDY7A1Biwy8VhEaop8N-V_rHv9PzoMinTd30u9uZ/s72-c?imgmax=800" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2990193854398450266.post-7184891187165638340</id><published>2017-04-23T11:50:00.001+00:00</published><updated>2017-04-23T11:50:23.709+00:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Azure"/><category scheme="http://www.blogger.com/atom/ns#" term="Azure Application Gateway"/><category scheme="http://www.blogger.com/atom/ns#" term="Azure Service Fabric"/><title type='text'>Setup Application Gateway &amp; the Internal Front-End Load Balancer for an application</title><content type='html'>&lt;p&gt;&lt;b&gt;Setup Application Gateway &amp;amp; the Internal Front-End Load Balancer for an application&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;This post follows on from the one on creating a service fabric environment in Azure &lt;a title=&quot;http://jonlanceley.blogspot.co.uk/2017/04/3-node-service-fabric-environment-with.html&quot; href=&quot;http://jonlanceley.blogspot.co.uk/2017/04/3-node-service-fabric-environment-with.html&quot;&gt;http://jonlanceley.blogspot.co.uk/2017/04/3-node-service-fabric-environment-with.html&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;After you have deployed an application to service fabric you need to add the port for it to the service fabric cluster Front End load balancer and then to the Application Gateway.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;1. &lt;/b&gt;&lt;b&gt;Front End load balancer&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;The port is the one you have defined in your serviceManifest.xml e.g.&lt;/p&gt;  &lt;p&gt;&amp;lt;Resources&amp;gt;&lt;/p&gt;  &lt;p&gt;&amp;lt;Endpoints&amp;gt;&lt;/p&gt;  &lt;p&gt;&amp;lt;Endpoint Protocol=&amp;quot;http&amp;quot; Name=&amp;quot;ServiceEndpoint&amp;quot; Type=&amp;quot;Input&amp;quot; Port&lt;font style=&quot;background-color: #ffff00&quot;&gt;=&amp;quot;8702&amp;quot;&lt;/font&gt; /&amp;gt;&lt;/p&gt;  &lt;p&gt;&amp;lt;/Endpoints&amp;gt;&lt;/p&gt;  &lt;p&gt;&amp;lt;/Resources&amp;gt;&lt;/p&gt;  &lt;p&gt;&amp;lt;/ServiceManifest&amp;gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Create a new Health Probe &lt;/b&gt;&lt;/p&gt;  &lt;p&gt;e.g. 8702Probe&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjnlJtFb4mEImi4nY0y8SqjXfdjs9f1cQBEPbXUDS46qFWElTRnZliBOobJlF7anw5IfZyy0_K36Btb-ujdpt8YqIaargTFR_wfa561Cki5vAAJv7dnARTMowEcOm1PHOwyBQppVYOfzkap/s1600-h/image%255B3%255D&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; float: none; padding-top: 0px; padding-left: 0px; margin-left: auto; border-left: 0px; display: block; padding-right: 0px; margin-right: auto&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjvxgUwszEquWuSnz4XbYufqtkHvWVxuiptU2NCqy1bVDxS2BFElSwUaZix4YiHeFJJJnXVQ0R3CD3-uNsu8Mao8aGXEEXdMJ-J98Q2045qZFfck0wbDuUa9n6EVMx15tuJOqxOl_oWd50T/?imgmax=800&quot; width=&quot;713&quot; height=&quot;246&quot; /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Create a new Load balancing rule&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;e.g. 8702Rule, make sure you set the highlighted items correctly.&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSJOUomQKmYBNlOTUsEeUOZhpJziAiyDPYhyphenhyphenQR1jM0v4Sf0UnxC1LAvNYiteyBljfpc8Cwb5SZLO9g8Qq4jtIvPgFlzPoGode478GZidsE-jAMUUFVpxCyemvgOi-gSo1C75h40njmRQ2v/s1600-h/image%255B7%255D&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; float: none; padding-top: 0px; padding-left: 0px; margin-left: auto; border-left: 0px; display: block; padding-right: 0px; margin-right: auto&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiivHlZCfw05TOrcqZ7Blv1I8IbGcxdaNBysoOMrYex_60FMzzG5bKD6GpZChefeAOm-YSsDR66Zz6ai9zqwyG8Pw3KXD1grv2gYbesjiubTMaldjIR_5qNWyNHyOvGYzkCDp1yuJiYmyCf/?imgmax=800&quot; width=&quot;426&quot; height=&quot;483&quot; /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhScXJavMHMXOmDSYflHt9nQxr5h8-EAF7sxvtoR_LuJeDHNi688FMB1D9Z9Mi3kcJ5a17wTgccwOrddThDQECvI-uYModoJ6ojQQBNIcmFjnZFS8l-NrwcvL8VuvnFuvdl3oO3PXkWm6py/s1600-h/image%255B11%255D&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; float: none; padding-top: 0px; padding-left: 0px; margin-left: auto; border-left: 0px; display: block; padding-right: 0px; margin-right: auto&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQoh3YVJHwCZxEFXM7shiJsuVASM5X0KEVoXZ6gGJz-UNqbpaqcVJP5zhxXuI5YdhpfnxRe37QjM1sw3haRM8c2abOyN4j07nG_LlSCbg_E_0d6dK7xEjibfGXNplC7sOUEajr7fnoS0Yd/?imgmax=800&quot; width=&quot;686&quot; height=&quot;203&quot; /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;     &lt;br /&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;2. &lt;/b&gt;&lt;b&gt;Application Gateway&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Add a new Health Probe&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiAe2pTBBLaEKbe_8eICoKe004VXHWlhGeHsVh3xcdvMQWjIIkQqPELJcr041jipP83DKWk50J9V7vh-zxnJanZ9tXxHfdEUSMC_pwqbkcbhr1FyNiQAVcr7V8znflIECivFl3tsdiS4_lw/s1600-h/image%255B15%255D&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; float: none; padding-top: 0px; padding-left: 0px; margin-left: auto; border-left: 0px; display: block; padding-right: 0px; margin-right: auto&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiyuaxMGH85L-4ytpDwuSXAGKyA5LNP0kHDi9fHHn-tWBsC9YjeRek-47lBYCfsznV-LBm29m8tOCxCAWhe4oq0UwEEswQeIVuYmja_iBdgJQz_OcdvPDivbNfgED5tUBHwYFLrqGnBce8_/?imgmax=800&quot; width=&quot;432&quot; height=&quot;355&quot; /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;The path just needs to be an endpoint which can return a response so the health probe knows if the application is alive.&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhInuGAJNnQG_kbfxzI-cwJ0Uqz09p0PqwzkThLn6QTCLHqClMnFHfmM0jkGEO0S5U6L13Sm10fQzIiIiHp82CYOrCNFGdub78_BvXgNR73BzphcZGV0TeKNOt3zprAz7OqEgyLfrSJt4jY/s1600-h/image%255B19%255D&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; float: none; padding-top: 0px; padding-left: 0px; margin-left: auto; border-left: 0px; display: block; padding-right: 0px; margin-right: auto&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiT6twK3_Bq2_MSKyYUwFqQzg4psS1g6o51lp_xNonGm57uLGpwZTA-p3J-9T6nDXTAouTywmtpLI2Xcphk75glWIBw4oiiCQKlt-U6gTvnTuSHMKsT3Qsp6HOv15u5mGsA_SKN9HiiQcQM/?imgmax=800&quot; width=&quot;572&quot; height=&quot;134&quot; /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;     &lt;br /&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Add a new Http Setting&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqltDocrDbU8ARCP9GNLDppaHtxaeaoyxSODQXGG7C3q9UJXk1vKgNCRPTdayLJQ_Ic_2Wr5zEFf8lhyYe48smvwSvt7qfll7zUoXipoz4o1d0GNT-IxoymHWCtSQxhW2qcb3upvOaauoq/s1600-h/image%255B23%255D&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; float: none; padding-top: 0px; padding-left: 0px; margin-left: auto; border-left: 0px; display: block; padding-right: 0px; margin-right: auto&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEeRbVwxXNKZY1EwRRKsy_10Mom2PvthHpRaHPimkY5Hj5JRqZgyaso3i4R34iJZ1TicNXPZ2S5HRNEZ1wfzeYMOhKe7HxBqI3lQVLJhVp0UStJ-zO7YBif0kxBIOwkMO2erP2e_G-ktNZ/?imgmax=800&quot; width=&quot;547&quot; height=&quot;443&quot; /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCN2Wf2TSMeLNJKP_XBmGEf8pBjH1gSerdFYQ-mQcd_JYOdTGB8U-RlexxcZuZtAQs1qHgc_7zqxriB-fkPjs7cvDSzRxn488IB34xsNaFhRzzigDxkbHPqoDa44P-v4o0T6rnKe87G0CY/s1600-h/image%255B27%255D&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; float: none; padding-top: 0px; padding-left: 0px; margin-left: auto; border-left: 0px; display: block; padding-right: 0px; margin-right: auto&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhohmY2jh6Z4vByoX6fHIzWk6TnmPnDHcAIBd2I_2_8-kdA9kEDuHZvLqrTDbLzn8WDHZHgRdti-pXOgEkUlMpK6maNlHBi_15l20-QtxWVlSGg9GjQX8G0FNQ6MBk7KjoKCv9tD4OlZ97Z/?imgmax=800&quot; width=&quot;582&quot; height=&quot;146&quot; /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;     &lt;br /&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Add a new Mult-Site Listener&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEglJZ5juWx_8UMFUkOjT5uNujZlTo8HJnsXNGRKW4l5GDvfpWteZ0KomOiw6EgnRP4fA-4eu3h235kUDdrDwg0paraYtvLR1CMwZ13Y2fNJrBPWHA-U-348_4DnPnt4WLF6znxkJKiVKRB8/s1600-h/image%255B31%255D&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; float: none; padding-top: 0px; padding-left: 0px; margin-left: auto; border-left: 0px; display: block; padding-right: 0px; margin-right: auto&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKuslFY8YLBU6KorJ2O7MTa7bXmvUjiUUoEzp6L586XTNqCg28LPDtqhHqGwVjYdU-td2TEYfACT8UwJOVd-By7Q3pYafdOfjMWcDGujExdyQ9z9jDnv_AJEDpnIBNpUfeMb1mCbNN2FqV/?imgmax=800&quot; width=&quot;556&quot; height=&quot;349&quot; /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgyLsiPc30n4HHRxIMN-ynEP1p1R6KAVfa0xhPBsQ7oSaxHgc8K0f64QorElrBmykhi9ShZvtisUJoATawyo_a-i94sy-cIVqtXs-S42cU5xIHFNSX-ILpvBXrKZ7SgXvGUyQXhM7yrrb5D/s1600-h/image%255B35%255D&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; float: none; padding-top: 0px; padding-left: 0px; margin-left: auto; border-left: 0px; display: block; padding-right: 0px; margin-right: auto&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYyN2MsMrp29RLy-eGkS6e928SAPD7YiDUahBjshaoN4BqTtAXZCQcFPTvhnBvtPCJfETC56GtigDVMHfe8XQPm1NZjusDTGWj40Cx5BeoIa7TEwWEZsi03Olrgc1y48bPU4347czJQqXM/?imgmax=800&quot; width=&quot;542&quot; height=&quot;138&quot; /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;     &lt;br /&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Add a new Basic rule&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;Make sure you choose the httpSetting you created earlier&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiAAul-VMyjst4F2xQV71x3TiAQTdWPRcqrti9KJSegU4hCKmgnLvnLb0FJrKK8qP2cYhTkfZC4Ye-TyZzKyIijpRM5rZRcfHVMt_d2tuq37Ba2GoTmUmv1WqXWU_3k38JmCRVkLP9Ula7f/s1600-h/image%255B39%255D&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; float: none; padding-top: 0px; padding-left: 0px; margin-left: auto; border-left: 0px; display: block; padding-right: 0px; margin-right: auto&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHvQJOh10de99zFgOROO4jAvlQpEfRZv2o9FssySNMUqYyOiuo2pEZxFpgTQjSe_dAF7zrRBkXaxGlWe2EEt4UBMsSjthHapPSt3cRO-p2vJki0-ysZM3SjMwtnFeS8Ef6-oO0KxA8wsDx/?imgmax=800&quot; width=&quot;469&quot; height=&quot;273&quot; /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgHfAcn7QwLS34e0qiQvTKsEY8QF27j-3MJdQssp2KEqIga9cLMWWuAtfNjGo3drNDVpnE5yDlwoy2Wmy3tzi9sm94g8jyuCyvgRo8xz2DB8-_xzPM5PsoCdKUca-iVOQnp-MU-lRVGuRPp/s1600-h/image%255B43%255D&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; float: none; padding-top: 0px; padding-left: 0px; margin-left: auto; border-left: 0px; display: block; padding-right: 0px; margin-right: auto&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrdap8pLZCai2KyddphXVc7ARosIjLEFMAzYKCKkRiO6iqh1Na4n3k2IEqOXb6Pis5oVhmwliwSa5Eh4Yoh1tq0TzreyoPdDs9kVZ28l3L19jFPQjBLtCAj2sCya5I3keA53JBt-zPIPz7/?imgmax=800&quot; width=&quot;543&quot; height=&quot;157&quot; /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Remove rule1 for the appGatewayHttpListener&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgiB_WawfYK6TTUj2XYl3QiKTmNUXft5KGwX4efrbVafhU_kGLYxcVvfGv2UyAKdhEdSavRwPdiNWXo1GPWTE8U3Kz8v1QgqoeJ5J0ygz5A0MZqlq86RoK8JfJey_aksYGYE_IfaF1TnMqe/s1600-h/image%255B47%255D&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; float: none; padding-top: 0px; padding-left: 0px; margin-left: auto; border-left: 0px; display: block; padding-right: 0px; margin-right: auto&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhFmcdhyphenhyphen3xbJr-EeyEqusRgrvjTTHKWf7b2w-BWZWF2HWt2KYDoO9oiS55ZhrSAeaZ1C_niDlURd7fCxpR6IHkx0Op93T-ynD6uQz_61Y8TtMtkQaPwMyMMsEEeklZrIkB64ySU5d-Ntqto/?imgmax=800&quot; width=&quot;569&quot; height=&quot;150&quot; /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;     &lt;br /&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Check the backend health&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;Before connecting via a browser it’s worth checking that the Backend health report is Healthy otherwise you have missed something.&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiiaX9VQjmbRopOEuCPR4JrKVOYK1M7ZIFbxPmkWaFe9ByMdwmCyguzmDC6ld2Pq03XepLQ6Mh2WZhBNz1x3yuW597-BtV4M5hD0yn1AymxIFx7nYqJ3x-j9wtGlECq1GEmn0yb1UvoL9e6/s1600-h/image%255B51%255D&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; float: none; padding-top: 0px; padding-left: 0px; margin-left: auto; border-left: 0px; display: block; padding-right: 0px; margin-right: auto&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjHkRj_jMnScftDAKPtv0XWXLt22NPkquoBlc4oIABm-nmYTbWBzIG4blUmdGvKzE1boxXj7sXC7RzYhgzNTg1vJ73pWos98lCIVB1Dd5kAcOlN7h7OyGszo6LsbordJfqcJVVyuNIERzjA/?imgmax=800&quot; width=&quot;433&quot; height=&quot;336&quot; /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;If it’s healthy, try opening your application in a browser e.g.&lt;/p&gt;  &lt;p&gt;http://sfapptest.com/api/values/get &lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://jonlanceley.blogspot.com/feeds/7184891187165638340/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jonlanceley.blogspot.com/2017/04/setup-application-gateway-internal.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2990193854398450266/posts/default/7184891187165638340'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2990193854398450266/posts/default/7184891187165638340'/><link rel='alternate' type='text/html' href='http://jonlanceley.blogspot.com/2017/04/setup-application-gateway-internal.html' title='Setup Application Gateway &amp; the Internal Front-End Load Balancer for an application'/><author><name>Jon</name><uri>http://www.blogger.com/profile/03999374060620875716</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtN6KAyfs2XT5axA13YSBK6vG1fODGqFwkd7i3EgUB0JjSkFLFVaAZ4pbpaS_vohqo9WxkqepTFpoOWWpFhX_ozDe4BOvA-JHUiJlQBcVNk713PsbLK_Hj96vnzr2hHx0/s113/Me2.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjvxgUwszEquWuSnz4XbYufqtkHvWVxuiptU2NCqy1bVDxS2BFElSwUaZix4YiHeFJJJnXVQ0R3CD3-uNsu8Mao8aGXEEXdMJ-J98Q2045qZFfck0wbDuUa9n6EVMx15tuJOqxOl_oWd50T/s72-c?imgmax=800" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2990193854398450266.post-7239311596296756146</id><published>2017-04-19T19:36:00.001+00:00</published><updated>2017-04-23T11:52:28.116+00:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Azure"/><category scheme="http://www.blogger.com/atom/ns#" term="Azure Application Gateway"/><category scheme="http://www.blogger.com/atom/ns#" term="Azure Service Fabric"/><category scheme="http://www.blogger.com/atom/ns#" term="Service Fabric"/><title type='text'>3 Node Service Fabric Environment with an Azure Application Gateway</title><content type='html'>&lt;p&gt;This is an article I put together as I was experimenting with Service Fabric for a real world solution to a problem we had.&amp;#160; &lt;/p&gt;  &lt;p&gt;In it we will create a service fabric environment in Azure which contains 3 node types, FrontEnd, BackEnd, and Management, plus an Application Gateway in front which all internet traffic can be routed through to the FrontEnd node. We will also be using an existing Virtual Network and Subnets that we will put the service fabric cluster into. &lt;/p&gt;  &lt;p&gt;This post helped me a lot with producing this solution:&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;https://brentdacodemonkey.wordpress.com/2016/08/01/network-isolationsecurity-with-azure-service-fabric/&quot;&gt;https://brentdacodemonkey.wordpress.com/2016/08/01/network-isolationsecurity-with-azure-service-fabric/&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;My template originally came from the Azure Portal when creating a new service fabric cluster there is the option of saving it as a template. It was then customised as the portal wizard does not let you do certain things. Most of the customisations came from this site: &lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;https://docs.microsoft.com/en-us/azure/service-fabric/service-fabric-patterns-networking&quot;&gt;https://docs.microsoft.com/en-us/azure/service-fabric/service-fabric-patterns-networking&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;This is what we will build:&lt;/p&gt;  &lt;p&gt;&lt;img style=&quot;float: none; margin-left: auto; display: block; margin-right: auto&quot; src=&quot;https://raw.githubusercontent.com/jonlanceley/jonlanceley/master/CreateServiceFabricEnvironment/ServiceFabricEnvironment.PNG&quot; width=&quot;721&quot; height=&quot;543&quot; /&gt;&lt;/p&gt;  &lt;p&gt;The FrontEnd node type is where we put any stateless services.&lt;/p&gt;  &lt;p&gt;The BackEnd node type is where we would put any stateful services.&lt;/p&gt;  &lt;p&gt;The Azure service fabric services will run on the Management / Primary node type.&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;· This has a public static outbound IP number, so we can connect to view the status of the cluster.&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;· It can also host services which need to connect out to a third party which have IP security on their firewall. The third party then only needs to add this IP number to their firewall.&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;· We can also use this to securely access an Azure SQL database that has IP restricted access.&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;The steps below are my notes for creating the service fabric environment.&amp;#160; All the scripts and ARM template are available on Github: &lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a title=&quot;https://github.com/jonlanceley/jonlanceley/tree/master/CreateServiceFabricEnvironment&quot; href=&quot;https://github.com/jonlanceley/jonlanceley/tree/master/CreateServiceFabricEnvironment&quot;&gt;https://github.com/jonlanceley/jonlanceley/tree/master/CreateServiceFabricEnvironment&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;b&gt;1. &lt;/b&gt;&lt;b&gt;Create Service Fabric dependencies.&lt;/b&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;· Public Static IP (for Management nodeType)&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;· Key Vault (for service fabric certificates)&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;· Active Directory Application (for authentication)&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;· Resource Group to put service fabric cluster in&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;· Existing Virtual Network with 4 subnets for:&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; o FrontEnd&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; o BackEnd&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; o Management&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; o WAF / Application Gateway&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Edit &amp;amp; change the parameters as required in this script:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;Azure-CreateDependanciesForServiceFabricPlatform.ps1&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Execute the script&lt;/p&gt;  &lt;p&gt;&lt;i&gt;Note: this script will prompt you yes/no to create each of the above items.&lt;/i&gt;&lt;/p&gt;  &lt;p&gt;If you’re creating a non-development version we &lt;u&gt;do not&lt;/u&gt; want to use a self-signed certificate so say ‘no’ when prompted. After the script has run you then need to manually add certificates into the key vault. Details here:&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;https://docs.microsoft.com/en-us/azure/service-fabric/service-fabric-cluster-creation-via-portal#add-certificates-to-key-vault&quot;&gt;https://docs.microsoft.com/en-us/azure/service-fabric/service-fabric-cluster-creation-via-portal#add-certificates-to-key-vault&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;https://blogs.technet.microsoft.com/kv/2016/09/26/get-started-with-azure-key-vault-certificates/&quot;&gt;https://blogs.technet.microsoft.com/kv/2016/09/26/get-started-with-azure-key-vault-certificates/&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;     &lt;br /&gt;2. &lt;/b&gt;&lt;b&gt;Create the Service Fabric Environment&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;This will create a 3 nodeType service fabric environment FrontEnd, Backend and Management nodeTypes.&lt;/p&gt;  &lt;p&gt;The management node type is set as the Primary.&lt;/p&gt;  &lt;p&gt;&lt;i&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p&gt;&lt;i&gt;Note the NSG’s are not assigned to the Subnet but they are created by the script.&lt;/i&gt;&lt;/p&gt;  &lt;p&gt;Go to folder:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;secureTemplateAnd3NodeTypeWithApplicationGatewayAndExistingSubnet&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Copy the parameters.json file and then change the parameters.&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;Note: By default the script creates the minimum number of VM’s all at Standard A0 size. If this is a non-development environment you will want to change the VM size to be:&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; · Minimum number of instances: &lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; o Set to 5 on Management/Primary node type&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; o Set to 5 on Backend node type (stateful)&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; o Set to 2 on Frontend node type (stateless)&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; · Size (set to Standard D1_V2 the minimum supported spec for all node types)&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; · Reliability Level of the cluster should be minimum of Silver in production (default is Bronze)&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;o Static IP parameters (change to match those you just setup):&lt;/p&gt; &lt;/blockquote&gt;  &lt;ul&gt;   &lt;ul&gt;     &lt;li&gt;existingStaticIPResourceGroup &lt;/li&gt;      &lt;li&gt;existingStaticIPName &lt;/li&gt;      &lt;li&gt;existingStaticIPDnsFQDN &lt;/li&gt;   &lt;/ul&gt; &lt;/ul&gt;  &lt;blockquote&gt;   &lt;p&gt;o Specifiy the existing Virtual network and subnet names:&lt;/p&gt; &lt;/blockquote&gt;  &lt;ul&gt;   &lt;ul&gt;     &lt;li&gt;virtualNetworkName &lt;/li&gt;      &lt;li&gt;existingVNetRGName &lt;/li&gt;      &lt;li&gt;subnet0Name &lt;/li&gt;      &lt;li&gt;subnet1Name &lt;/li&gt;      &lt;li&gt;subnet2Name &lt;/li&gt;      &lt;li&gt;subnetWAFName &lt;/li&gt;   &lt;/ul&gt; &lt;/ul&gt;  &lt;blockquote&gt;   &lt;p&gt;o Active Directory parameters (change to match those you just setup):&lt;/p&gt; &lt;/blockquote&gt;  &lt;ul&gt;   &lt;ul&gt;     &lt;li&gt;aadTenantId &lt;/li&gt;      &lt;li&gt;aadClusterApplicationId &lt;/li&gt;      &lt;li&gt;aadClientApplicationId &lt;/li&gt;   &lt;/ul&gt; &lt;/ul&gt;  &lt;blockquote&gt;   &lt;p&gt;o Certificate parameters (change to match those you just setup):&lt;/p&gt; &lt;/blockquote&gt;  &lt;ul&gt;   &lt;ul&gt;     &lt;li&gt;SourceVaultValue &lt;/li&gt;      &lt;li&gt;certificateUrlValue &lt;/li&gt;      &lt;li&gt;certificateThumbprint &lt;/li&gt;   &lt;/ul&gt; &lt;/ul&gt;  &lt;blockquote&gt;   &lt;p&gt;o VM login parameters (used if you ever need to RDP into a cluster machine):&lt;/p&gt; &lt;/blockquote&gt;  &lt;ul&gt;   &lt;ul&gt;     &lt;li&gt;adminUserName &lt;/li&gt;      &lt;li&gt;adminPassword &lt;/li&gt;   &lt;/ul&gt; &lt;/ul&gt;  &lt;blockquote&gt;   &lt;p&gt;o Other parameters&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;Execute the deploy script:&lt;/p&gt;  &lt;p&gt;.\deploy.ps1 -subscriptionId &amp;lt;yourAzureSubscriptionIdHere&amp;gt; -resourceGroupName mycluster -deploymentName mycluster -parametersFilePath .\parameters.json &lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;If after a long time it errors with this message ‘Monitoring Agent not reporting success after launch’&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7nNLLK6ift9dYFlwBtCcQINDTQ7chFialz82lZN2nxsMNoPHEF4gqDESEA9qb9o5l7Ad1fxvekj2tIpvNdXl5jtKF5Mw6s1IdcvwbAqNbmwzDKiULA5wjvyIHywxxN3b8k626zsBdEca9/s1600-h/image%25255B12%25255D.png&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; float: none; padding-top: 0px; padding-left: 0px; margin-left: auto; display: block; padding-right: 0px; border-top-width: 0px; margin-right: auto&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlDLgLNp-u0UbdqLamsS1QfDduoO5h9nHNeR7E2fdkKumVFkZli27Gu6FxlNJ_nyj_JgYXOGHpeO812eqep2f_pwcwLEAeXv7KeLDV7SKA3fwOEkCdhDww9Fiar2pyNcdHKpNeVy7Fwry4/?imgmax=800&quot; width=&quot;643&quot; height=&quot;114&quot; /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Then you should be fine as Service Fabric will automatically recover the nodes that this failed for.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;3. &lt;/b&gt;&lt;b&gt;After deployment&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;Go to the Azure portal and find your service fabric cluster and you should eventually see the nodes (they may take some time to appear).&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgbH331I_EpRoga6iQe-PPaxazWERSoBHo-L8i7oZoUSY1xM5KjSq34vbOCyyKh21WiK87Ly5BckMqJnAjwwgMNDQO88Rm37PZqAOUoZLPtuAWY49Jr-o5RSp_JpOSo1dTX17bcFbpuYCtX/s1600-h/image%25255B11%25255D.png&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; float: none; padding-top: 0px; padding-left: 0px; margin-left: auto; display: block; padding-right: 0px; border-top-width: 0px; margin-right: auto&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhlbBMtpPKRPx6vPrqojjKW4srxddLdZr80qV18G0OdIcT-LFzL6NdcbC1sE6KZ7H0_V-L-QsiNqa0ncrAVI7VWbbuw3ICt9xV26zW9f65wFMrKh1agbM4jbuUilNFZv3fM0DWp-Ois3MKb/?imgmax=800&quot; width=&quot;715&quot; height=&quot;512&quot; /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Once the deployment has finished and you can see in the Azure Portal that the nodes in the cluster are running you should be able to view the cluster e.g.&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;https://jonscluster.northeurope.cloudapp.azure.com:19080/Explorer&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;This should prompt you to login. If you see a message:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;AADSTS50105: The signed in user &#39;jon.lanceley_xxxxxxxxx.com#EXT#@jonlanceleyxxxxxxxx.onmicrosoft.com&#39; is not assigned to a role for the application &#39;9df93f43-6682-4004-addd-1522a4e13439&#39;.&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Go to Azure Active Directory -&amp;gt; Enterprise Applications -&amp;gt; All Applications&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p align=&quot;center&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9aQxonPsAoH-W97g8cGgctsVkvGRPw62D96yYCbiECwwCywgsbhl_86df2jf1LvLEwdTgJFiBKG5voZT5E_OM6UQi-a3U03KqXpMILN1o0zVQi9kC1-47WEsn2LkJd9CQd6I9gpYM_lGq/s1600-h/image%25255B16%25255D.png&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzQy68rRJ79K-pZ2V2JRyHPcQaVlHezuZCP9-X-TGO6ViAiuqZaZj94x4pHXZGSMhFIcwc-WlnenNqJPUDAoiHkyB-Y8_FH6pdM5ncm-Hj6zoQq6if677e6Cx1tn9cvo1d-RpETqW-FKl4/?imgmax=800&quot; width=&quot;233&quot; height=&quot;281&quot; /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Find the cluster server application (not the client one)&lt;/p&gt;  &lt;p&gt;Add the user as an Admin&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEip41BGgjeX689ORj2dUKHuee2_EO6RDjozzDlleteqtWH_pe2pfpTuvVGaAdo7_vYOl66RiYV2Xd6XazBx0J2lX7oDJ-W4MdC28JWO2YZKNDQGrLLMaWVlaNC7BmsQF16tMuCTUpgEnE59/s1600-h/image%25255B22%25255D.png&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; float: none; padding-top: 0px; padding-left: 0px; margin-left: auto; display: block; padding-right: 0px; border-top-width: 0px; margin-right: auto&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg3SicHhWlwHfmGKwljqTxLrCyxXrv7_lH22qUROJ5-ZOq4irINeIoyx4QuIuUzEJR5r5KGZl7dQW9G0i45GhDP9VglOY1sJQhyphenhyphenq4DxIXtb6p3O8ukDtW0cxNZHCkDfAP76Nwmi_hQufEaH/?imgmax=800&quot; width=&quot;642&quot; height=&quot;298&quot; /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;That’s it, you should now have a running Service Fabric Cluster.&amp;#160; &lt;/p&gt;  &lt;p&gt;You now just need to deploy some code to it.&amp;#160; And then open the Front End Internal load balancer and the Application Gateway ports for the application: &lt;a title=&quot;http://jonlanceley.blogspot.co.uk/2017/04/setup-application-gateway-internal.html&quot; href=&quot;http://jonlanceley.blogspot.co.uk/2017/04/setup-application-gateway-internal.html&quot;&gt;http://jonlanceley.blogspot.co.uk/2017/04/setup-application-gateway-internal.html&lt;/a&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://jonlanceley.blogspot.com/feeds/7239311596296756146/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jonlanceley.blogspot.com/2017/04/3-node-service-fabric-environment-with.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2990193854398450266/posts/default/7239311596296756146'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2990193854398450266/posts/default/7239311596296756146'/><link rel='alternate' type='text/html' href='http://jonlanceley.blogspot.com/2017/04/3-node-service-fabric-environment-with.html' title='3 Node Service Fabric Environment with an Azure Application Gateway'/><author><name>Jon</name><uri>http://www.blogger.com/profile/03999374060620875716</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtN6KAyfs2XT5axA13YSBK6vG1fODGqFwkd7i3EgUB0JjSkFLFVaAZ4pbpaS_vohqo9WxkqepTFpoOWWpFhX_ozDe4BOvA-JHUiJlQBcVNk713PsbLK_Hj96vnzr2hHx0/s113/Me2.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlDLgLNp-u0UbdqLamsS1QfDduoO5h9nHNeR7E2fdkKumVFkZli27Gu6FxlNJ_nyj_JgYXOGHpeO812eqep2f_pwcwLEAeXv7KeLDV7SKA3fwOEkCdhDww9Fiar2pyNcdHKpNeVy7Fwry4/s72-c?imgmax=800" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2990193854398450266.post-8356191848245381280</id><published>2016-04-12T06:08:00.001+00:00</published><updated>2016-04-12T06:08:29.651+00:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Asp.Net MVC5"/><category scheme="http://www.blogger.com/atom/ns#" term="Continuous Integration"/><category scheme="http://www.blogger.com/atom/ns#" term="EF6"/><category scheme="http://www.blogger.com/atom/ns#" term="Entity Framework 6"/><category scheme="http://www.blogger.com/atom/ns#" term="TFS"/><category scheme="http://www.blogger.com/atom/ns#" term="TFS Build Tasks"/><category scheme="http://www.blogger.com/atom/ns#" term="TFS Release Management"/><title type='text'>Release Management in TFS 2015.2</title><content type='html'>&lt;p&gt;With the TFS 2015.2 update we now have the ability to use Release Manager in TFS on premise. This is how I have setup our branching structure, gated check-in and release manager to control the deployment (with approvals at some stages) of an MVC5 web site with Entity Framework into multiple Azure Web Application environments.&lt;/p&gt;  &lt;p&gt;We have our branching structure set as:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;Dev\developer name 1&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;Dev\developer name 2 etc&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;Main&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Developers take a branch from main into the dev folder under their name and work on changes. When development is complete they check-in to their dev branch and then merge the changes into the Main branch. This allows the developer to pull in other changes from main into their dev branch, and be able to check-in at least daily into their dev branch so their code is backed up overnight.&lt;/p&gt;  &lt;p&gt;We are using the new TFS build tasks; and setup against the Main branch is:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;A gated check-in. &lt;/li&gt; &lt;/ul&gt;  &lt;p align=&quot;center&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDJyOKKz4ZNLhyphenhyphen6pE1X1ZIAw5ZI-iXemAoKbO4hKJkBcJb4WRST1NoDvjc7avGbusZwcXLXDSH9_V__JsiL51-wlARdSVzdnTAk1PCQbXP-Ytk7ytQplet23cUS4eQjtTA9ZNhcHmIjYjM/s1600-h/image001_thumb7_thumb%25255B2%25255D.png&quot;&gt;&lt;img title=&quot;image001_thumb7_thumb&quot; style=&quot;border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; margin: 0px; display: inline; padding-right: 0px&quot; border=&quot;0&quot; alt=&quot;image001_thumb7_thumb&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiN7cT8F9srzvM4hX0HrRUbw4Ko5PIq5sf3e6br6hy_Zv08SNHUloywfaycUtxEAFxeojCMsFWx1fljfRNX3tdKPgWA7psQL8Y4_kgDZgQTy0Li5lNUzNFdkNSjPt4WUZnR3JMIQQbx9VjS/?imgmax=800&quot; width=&quot;414&quot; height=&quot;415&quot; /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;And a number of build tasks that compile the code in Release mode, run some unit tests and finally copy the files/build artifacts we need to deploy the web site into the drop folder (essentially a web deploy zip file is created). &lt;/li&gt; &lt;/ul&gt;  &lt;p align=&quot;center&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEitKgRLzQS-jW9I1bOzTw04loxIe8ml0ebsAeOx_rlUe6_7j2VqJumhCjbo9eztfIgV15gir-4-KdUZ16ISwpuOqa_y4hXnA4mJXc-9-R6YgnjnhUlnZ0hQtiLaQBw4GJMd4n7lXEi8tEbW/s1600-h/image002_thumb2_thumb%25255B2%25255D.png&quot;&gt;&lt;img title=&quot;image002_thumb2_thumb&quot; style=&quot;border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; margin: 0px; display: inline; padding-right: 0px&quot; border=&quot;0&quot; alt=&quot;image002_thumb2_thumb&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgrKtNfhiuSlIZEtVAw11NCtT2KqashnTpeN9xXaEhlfB6zSgsdjOBSTxTTw9FpAHARv9YceE-GI9gZh1E8oQSlWSIgON5CJqKk4M3f56oGKdpSKKDiPBzpumyF4weZJG_aMsqYYiT5ALiF/?imgmax=800&quot; width=&quot;615&quot; height=&quot;438&quot; /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p align=&quot;center&quot;&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;The key to creating a web deploy zip file is the MS Build Arguments:&lt;/p&gt;  &lt;p&gt;/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true&lt;/p&gt;  &lt;p&gt;In the copy and Publish build artifacts task we have:&lt;/p&gt;  &lt;p align=&quot;center&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgbbWjjxpOziNNcNu8JlYNCXQRWZehk50atNni33UvYWI1UfVRBNW1KJQPJ0wg08_nXRInobTcuXOIlROcHurIEEKO0t_S4JjLxqVzp-KfCD8gDERm6-jKsh_hh-lRPNyWGudSVHG2Q-mfT/s1600-h/image003_thumb1_thumb%25255B2%25255D.png&quot;&gt;&lt;img title=&quot;image003_thumb1_thumb&quot; style=&quot;border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; margin: 0px; display: inline; padding-right: 0px&quot; border=&quot;0&quot; alt=&quot;image003_thumb1_thumb&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXVfdKFs-o5EXi6J9HW2xacMsSOPjTPooI7kC176IvwhKHGVNm9adgdWORBdAuWIG-s6avFo5Gi611r-x9Xogzjd62Syl1q_cc_TP0d_lYaQFGv_CNS4lf8nBeE9qr2-OKi7Kxf-_gHCwC/?imgmax=800&quot; width=&quot;638&quot; height=&quot;281&quot; /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;This automatically builds all changes checked into the Main branch with the final step it produces the web deploy files. Assuming the build passes then Release Manager will take over to deploy the web site into an Azure Web Application.&lt;/p&gt;  &lt;p&gt;We have 4 environments in Azure that we need to deploy to ‘UAT Staging’, ‘UAT’, ‘Production Staging’ and ‘Production’. For us these are split into 2 Azure subscriptions, one for UAT one for Production. Within each subscription is 1 web application e.g. UAT and against that 1 slot ‘staging’ and each has its own Azure SQL database. This gives us 2 websites and 2 databases. We make use of sticky slot settings as well so the connection string / app settings stay against its environment because in production we make use of the Azure web application swap slot functionality.&lt;/p&gt;  &lt;p&gt;So we configure release manager to deploy the code to UAT staging, UAT and Production staging. But for production release manager just initiates a swap slot PowerShell command.&lt;/p&gt;  &lt;p&gt;So in Release manager we will need to setup the deployment process or tasks for each of these environments.&lt;/p&gt;  &lt;p&gt;But first Release manager is setup to watch the main branch for a new build artifact which is done by setting the release trigger to Continuous Deployment.&lt;/p&gt;  &lt;p align=&quot;center&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCHeFmzdkjcsGRB3766YSlREg6CDp_5nBJYYSciwrDeWl2XOKTd_Wpo-PXVvaI7JWGYRnaLBASuYFxcetu5sPxB1kdFJ0nxx4FeX9pEWriHuKLgc9xWW7FXkC75Pboy49_KM2E4eBCLgZH/s1600-h/image004_thumb1_thumb%25255B2%25255D.png&quot;&gt;&lt;img title=&quot;image004_thumb1_thumb&quot; style=&quot;border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; margin: 0px; display: inline; padding-right: 0px&quot; border=&quot;0&quot; alt=&quot;image004_thumb1_thumb&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7QNK8r-Bn5BPr7xi7AQPQyMDS2wG6NKWXaYtiN_G30Dsir_d2KD-MCjQtTcoVnkzerPVSAuZJy8UM_ZjvKAjCPm86xVztbQ6rB1LHHcnvsNtfplmVGEbI1gJJCbyyiJVjGV2Xk3Ukx0xH/?imgmax=800&quot; width=&quot;407&quot; height=&quot;560&quot; /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;As soon as a new version is checked in setting the UAT Staging environment trigger to ‘Automated after release creation’ will initiate a deployment into that environment automatically (and for us with no approvals required because that is the first server in Azure which our developers can test against).&lt;/p&gt;  &lt;p&gt;On the environments tab we define the deployment steps for each environment so for UAT Staging we have:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Stop the Azure web application &lt;/li&gt;    &lt;li&gt;Deploy the new code/web site &lt;/li&gt;    &lt;li&gt;Start the Azure web application &lt;/li&gt; &lt;/ul&gt;  &lt;p align=&quot;center&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7KCLmNncfH6LJnAU8qA-1wndDrL8C67EuEJ4gT8vflfOT-nd8hNRRAOreiNMuuv5g8XXVBULX1NzRfpBiAZRX7CwdURyWz5MCQQ80zGSJIlfr2L2TsGP4xsNYb-RA-nlhwQ8G03rNAD8f/s1600-h/image005_thumb1_thumb%25255B2%25255D.png&quot;&gt;&lt;img title=&quot;image005_thumb1_thumb&quot; style=&quot;border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; margin: 0px; display: inline; padding-right: 0px&quot; border=&quot;0&quot; alt=&quot;image005_thumb1_thumb&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjydeS_Qfq3N1znpJ77dUq6gjl0vtctMU1RavfrWil5zfSH1D2UndFrPexcDrmiK-MmRaNSKNNHEXse-S38VW82Zs71wh9AIvCCru2taPabekPkna2RktAqwwhPjEqOktXH5y8x_1mqiNnC/?imgmax=800&quot; width=&quot;716&quot; height=&quot;407&quot; /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;We are making use of the new TFS Market Place extension ‘Run Inline Azure Powershell’ task which allows us to stop the Azure web application with:&lt;/p&gt;  &lt;p&gt;Stop-AzureWebsite -Name $(WebAppName) -Slot stage&lt;/p&gt;  &lt;p&gt;And below are the properties of the Azure Web App Deployment task, with the main one being the path to the Web Deploy Package.&lt;/p&gt;  &lt;p&gt;&lt;i&gt;Note: Our web applications are always running in Azure we are not creating them on demand.&lt;/i&gt;&lt;/p&gt;  &lt;p align=&quot;center&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidxOx64cHKeS8j4vxMvhIx-r2FsZ2mPVHqXTm7pkGzCvQHe34-Oa1M2zTlDcHCGei8KdMuaGldqSanNXZc8fAxC5YXUTgxuGQ6uUPrD5aeMKJQhCOG8p_cZIyQ9bhUAsGVkZS0zTQp1Dt4/s1600-h/image006_thumb2_thumb%25255B2%25255D.png&quot;&gt;&lt;img title=&quot;image006_thumb2_thumb&quot; style=&quot;border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; margin: 0px; display: inline; padding-right: 0px&quot; border=&quot;0&quot; alt=&quot;image006_thumb2_thumb&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDYuCprICTTdDinDc-JoUoW7vr4X4wnIJ26GSG4pDquxpAElW1fxH-hY87d1Vsnzu5QKe9HFXGKc1WfaHXbr_wfX7tjLIm_4b0-FisUNFneT5o3nm1Gt7sWXAZakiN6_Jegg-_UUUVyZB2/?imgmax=800&quot; width=&quot;381&quot; height=&quot;316&quot; /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;The UAT and Production Staging environments all have the same 3 tasks. Deployment into an environment takes about 1 minute 20 seconds.&lt;/p&gt;  &lt;p&gt;The Production environment has 1 task which swaps Production Staging with Production by executing this powershell script:&lt;/p&gt;  &lt;p&gt;Switch-AzureWebsiteSlot -Name $(WebAppName) -Slot1 stage -Slot2 production -Force -Verbose&lt;/p&gt;  &lt;p align=&quot;center&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEggbSN30jacgGcnMCH6rShkkkpenn7QsiEol2h1tHKUxTxKTlZz-HAo-wc1WakNCfsh7kkD7Rrw_lV76Zg5HpDR4i1emZPdCjDSlS_RhBbnUqJ1sib56-JnPqbnMIqbCkaiIxK4ybGeYhtM/s1600-h/image007_thumb2_thumb%25255B2%25255D.png&quot;&gt;&lt;img title=&quot;image007_thumb2_thumb&quot; style=&quot;border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; margin: 0px; display: inline; padding-right: 0px&quot; border=&quot;0&quot; alt=&quot;image007_thumb2_thumb&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6ssD9jk3OLgbRFmb9hddnbtOsOtIFiZrCyMNMmhV_DZf9nKUolyheirWk6eV_EUz1P7GqbQVZSK0COkKMZ6-tznHva5UMBaqOC-lXnzvppW-CisKgp3mxKa5cDtWzXBFmvbkhnHaeNxcb/?imgmax=800&quot; width=&quot;632&quot; height=&quot;157&quot; /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;That allows us to do a quick production deployment (saving us that 1 minute 20).&lt;/p&gt;  &lt;p&gt;UAT, Production Staging and Production all have Pre-Deployment approvers setup.&lt;/p&gt;  &lt;p align=&quot;center&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnoDVNZKezBObUSegkTFUikiKIwEhi2AFKIvVvOy5FVMuPS9LK76o_ULTX_Qgnx7tcFbdX0qa2UbBOEeZJZ6dq1rbEN8rbk-GLqgro2xSy8BLedq0iAgLUDr9GMUqrMvrEES2YzT8cqVyP/s1600-h/image008_thumb1_thumb%25255B2%25255D.png&quot;&gt;&lt;img title=&quot;image008_thumb1_thumb&quot; style=&quot;border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; margin: 0px; display: inline; padding-right: 0px&quot; border=&quot;0&quot; alt=&quot;image008_thumb1_thumb&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmtCOS4nPMzOWWgAZCQpzoDIGm5Ej7j4Zi3mXgzdAZG0maRA60JFAr527O540s9K1-6hTTuSH98Isq7Rld2DgA61G6L88ClETrjFKOQzUHjFKMEWQWoljYk3aNlHEtBQwj0Vg18_BKOFVV/?imgmax=800&quot; width=&quot;456&quot; height=&quot;411&quot; /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;So deployment to the 1&lt;sup&gt;st&lt;/sup&gt; Azure environment ‘UAT Staging’ happens automatically upon a successful check-in to the Main branch.&lt;/p&gt;  &lt;p&gt;The developer has the chance now to manually test the site. When they want to deploy to the next environment ‘UAT’ they would open the release in release manager and start the deployment:&lt;/p&gt;  &lt;p align=&quot;center&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxdgRGuIh1Xm20DewVyJz8K29sMA-Yhfu6INHd65uruN3ZTu4EK-PD7QfweHEWWfTY1wOmmXzrfqOMzueFpALaM5ty7DiQyV9Y5WlCpzfQ-Pho_8tbVXFUaoiVulTbkTQlkb_w1-1uk_D8/s1600-h/image009_thumb1_thumb%25255B2%25255D.png&quot;&gt;&lt;img title=&quot;image009_thumb1_thumb&quot; style=&quot;border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; margin: 0px; display: inline; padding-right: 0px&quot; border=&quot;0&quot; alt=&quot;image009_thumb1_thumb&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjY-wAC5BQLaawb-fTv7R7JIKY1C6ZuNppM-gBh1YTM6-eu90ms3OZnbrD3OwEF9-G-o9M0hUNF8ePJEeowVzn2u_ADIBDTBL_1DbupY-Uz3DpPPGXcVG7kXoaHYpYxn-crZgqRX_VIWedE/?imgmax=800&quot; width=&quot;620&quot; height=&quot;217&quot; /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p align=&quot;center&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjvWu_XVNOCUfn-RtMj5t3gBgc6dTMhFw1NgIiPIHn4X0dfsuHOPXDgx3Vt61Ot-_iTN7yh1BvKUH6Is7lsRc_2V_Ua_Dyl2yoqotMDthGqcTPNg9uVsdCcTpM3CHa7STYJMeAfMtKiuK2C/s1600-h/image010_thumb1_thumb%25255B2%25255D.png&quot;&gt;&lt;img title=&quot;image010_thumb1_thumb&quot; style=&quot;border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; margin: 0px; display: inline; padding-right: 0px&quot; border=&quot;0&quot; alt=&quot;image010_thumb1_thumb&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjoLF0wAAPW8l1_ZAfDKyGXJcjLZf5XdtWTCvFgIHsSLg9TXzCTjWiccl4yy5OOmkQE33lUztTiMARrYdYoop8NDFY2qPmqQ-PSYgiER6BnbnqhF8DFwx3dO9fM0LAShhmvJ0ZPhFNLz6Ze/?imgmax=800&quot; width=&quot;484&quot; height=&quot;520&quot; /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;By using the ‘Deploy’ button to request the code is deployed into the UAT environment this will send an email to the approvers who will ‘hopefully’ approve the release and if they do release manager will execute the 3 deployment tasks setup for the UAT environment.&lt;/p&gt;  &lt;p&gt;The same process would be followed for the remaining environments, the developer tests then uses the deploy button to move the same web application code to the next environment.&lt;/p&gt;  &lt;p&gt;At any point we can check what release is in what environment by looking at the overview tab.&lt;/p&gt;  &lt;p align=&quot;center&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgmEv8XDVDCGW94D5ZRDCXBgmDLWE30LqBnOgNzzuL0_t2PlWJCxa-YaaDcFi_dcr89L6qNoA_eqRcblgH4VeiDl8gXWh81U_5ezThMwxyij6-Tv_GscYK-UgVQSd9O2IgrLE3jQ8cKJxve/s1600-h/image011_thumb2_thumb%25255B2%25255D.png&quot;&gt;&lt;img title=&quot;image011_thumb2_thumb&quot; style=&quot;border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px&quot; border=&quot;0&quot; alt=&quot;image011_thumb2_thumb&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEig6MPk3w6eHRyjSfvu-qUKY3bRkGFVyv6NSHT7pL0TnH90Yw3bGtsJKL1qpCnKaEDC8UjgBbefol9ayk69E2yXCFXNfQ975FyPMZtekDarolaxANCw1DECqQcthNgpw4Ht1BnbwuiOctXP/?imgmax=800&quot; width=&quot;644&quot; height=&quot;243&quot; /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Database changes are done via Entity Framework Code First Migrations which are executed upon web site start up by running this code added to the MVC site startup.cs class:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;var efConfiguration = new Configuration();&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;var dbMigrator = new System.Data.Entity.Migrations.DbMigrator(efConfiguration);&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;dbMigrator.Update();&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;This will execute any schema changes and then run the seed data method. The key to keeping the seed data updated is using the extension method ‘AddOrUpdate’.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Useful Links&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;https://msdn.microsoft.com/library/vs/alm/release/overview&quot;&gt;https://msdn.microsoft.com/library/vs/alm/release/overview&lt;/a&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://jonlanceley.blogspot.com/feeds/8356191848245381280/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jonlanceley.blogspot.com/2016/04/release-management-in-tfs-20152.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2990193854398450266/posts/default/8356191848245381280'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2990193854398450266/posts/default/8356191848245381280'/><link rel='alternate' type='text/html' href='http://jonlanceley.blogspot.com/2016/04/release-management-in-tfs-20152.html' title='Release Management in TFS 2015.2'/><author><name>Jon</name><uri>http://www.blogger.com/profile/03999374060620875716</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtN6KAyfs2XT5axA13YSBK6vG1fODGqFwkd7i3EgUB0JjSkFLFVaAZ4pbpaS_vohqo9WxkqepTFpoOWWpFhX_ozDe4BOvA-JHUiJlQBcVNk713PsbLK_Hj96vnzr2hHx0/s113/Me2.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiN7cT8F9srzvM4hX0HrRUbw4Ko5PIq5sf3e6br6hy_Zv08SNHUloywfaycUtxEAFxeojCMsFWx1fljfRNX3tdKPgWA7psQL8Y4_kgDZgQTy0Li5lNUzNFdkNSjPt4WUZnR3JMIQQbx9VjS/s72-c?imgmax=800" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2990193854398450266.post-1524875083596247911</id><published>2015-08-30T12:53:00.001+00:00</published><updated>2015-08-30T12:53:51.864+00:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="Code First"/><category scheme="http://www.blogger.com/atom/ns#" term="EF6"/><category scheme="http://www.blogger.com/atom/ns#" term="Entity Framework 6"/><category scheme="http://www.blogger.com/atom/ns#" term="Unit Test"/><title type='text'>Unit Testing (part 4) - Faking Entity Framework code first DbContext &amp;amp; DbSet</title><content type='html'>&lt;style&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;!--&lt;br /&gt; /* Font Definitions */&lt;br /&gt; @font-face&lt;br /&gt;	{font-family:wingdings;&lt;br /&gt;	panose-1:5 0 0 0 0 0 0 0 0 0;&lt;br /&gt;	mso-font-charset:2;&lt;br /&gt;	mso-generic-font-family:auto;&lt;br /&gt;	mso-font-pitch:variable;&lt;br /&gt;	mso-font-signature:0 268435456 0 0 -2147483648 0;}&lt;br /&gt;@font-face&lt;br /&gt;	{font-family:wingdings;&lt;br /&gt;	panose-1:5 0 0 0 0 0 0 0 0 0;&lt;br /&gt;	mso-font-charset:2;&lt;br /&gt;	mso-generic-font-family:auto;&lt;br /&gt;	mso-font-pitch:variable;&lt;br /&gt;	mso-font-signature:0 268435456 0 0 -2147483648 0;}&lt;br /&gt;@font-face&lt;br /&gt;	{font-family:calibri;&lt;br /&gt;	panose-1:2 15 5 2 2 2 4 3 2 4;&lt;br /&gt;	mso-font-charset:0;&lt;br /&gt;	mso-generic-font-family:swiss;&lt;br /&gt;	mso-font-pitch:variable;&lt;br /&gt;	mso-font-signature:-536870145 1073786111 1 0 415 0;}&lt;br /&gt;@font-face&lt;br /&gt;	{font-family:tahoma;&lt;br /&gt;	panose-1:2 11 6 4 3 5 4 4 2 4;&lt;br /&gt;	mso-font-charset:0;&lt;br /&gt;	mso-generic-font-family:swiss;&lt;br /&gt;	mso-font-pitch:variable;&lt;br /&gt;	mso-font-signature:-520081665 -1073717157 41 0 66047 0;}&lt;br /&gt;@font-face&lt;br /&gt;	{font-family:consolas;&lt;br /&gt;	panose-1:2 11 6 9 2 2 4 3 2 4;&lt;br /&gt;	mso-font-charset:0;&lt;br /&gt;	mso-generic-font-family:modern;&lt;br /&gt;	mso-font-pitch:fixed;&lt;br /&gt;	mso-font-signature:-520092929 1073806591 9 0 415 0;}&lt;br /&gt; /* Style Definitions */&lt;br /&gt; p.msonormal, li.msonormal, div.msonormal&lt;br /&gt;	{mso-style-unhide:no;&lt;br /&gt;	mso-style-qformat:yes;&lt;br /&gt;	mso-style-parent:&quot;&quot;;&lt;br /&gt;	margin-top:0cm;&lt;br /&gt;	margin-right:0cm;&lt;br /&gt;	margin-bottom:10.0pt;&lt;br /&gt;	margin-left:0cm;&lt;br /&gt;	line-height:115%;&lt;br /&gt;	mso-pagination:widow-orphan;&lt;br /&gt;	font-size:11.0pt;&lt;br /&gt;	font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;&lt;br /&gt;	mso-ascii-font-family:calibri;&lt;br /&gt;	mso-ascii-theme-font:minor-latin;&lt;br /&gt;	mso-fareast-font-family:calibri;&lt;br /&gt;	mso-fareast-theme-font:minor-latin;&lt;br /&gt;	mso-hansi-font-family:calibri;&lt;br /&gt;	mso-hansi-theme-font:minor-latin;&lt;br /&gt;	mso-bidi-font-family:&quot;Times New Roman&quot;;&lt;br /&gt;	mso-bidi-theme-font:minor-bidi;&lt;br /&gt;	mso-fareast-language:en-us;}&lt;br /&gt;p.msoacetate, li.msoacetate, div.msoacetate&lt;br /&gt;	{mso-style-noshow:yes;&lt;br /&gt;	mso-style-priority:99;&lt;br /&gt;	mso-style-link:&quot;Balloon Text Char&quot;;&lt;br /&gt;	margin:0cm;&lt;br /&gt;	margin-bottom:.0001pt;&lt;br /&gt;	mso-pagination:widow-orphan;&lt;br /&gt;	font-size:8.0pt;&lt;br /&gt;	font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;;&lt;br /&gt;	mso-fareast-font-family:calibri;&lt;br /&gt;	mso-fareast-theme-font:minor-latin;&lt;br /&gt;	mso-fareast-language:en-us;}&lt;br /&gt;p.msolistparagraph, li.msolistparagraph, div.msolistparagraph&lt;br /&gt;	{mso-style-priority:34;&lt;br /&gt;	mso-style-unhide:no;&lt;br /&gt;	mso-style-qformat:yes;&lt;br /&gt;	margin-top:0cm;&lt;br /&gt;	margin-right:0cm;&lt;br /&gt;	margin-bottom:10.0pt;&lt;br /&gt;	margin-left:36.0pt;&lt;br /&gt;	mso-add-space:auto;&lt;br /&gt;	line-height:115%;&lt;br /&gt;	mso-pagination:widow-orphan;&lt;br /&gt;	font-size:11.0pt;&lt;br /&gt;	font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;&lt;br /&gt;	mso-ascii-font-family:calibri;&lt;br /&gt;	mso-ascii-theme-font:minor-latin;&lt;br /&gt;	mso-fareast-font-family:calibri;&lt;br /&gt;	mso-fareast-theme-font:minor-latin;&lt;br /&gt;	mso-hansi-font-family:calibri;&lt;br /&gt;	mso-hansi-theme-font:minor-latin;&lt;br /&gt;	mso-bidi-font-family:&quot;Times New Roman&quot;;&lt;br /&gt;	mso-bidi-theme-font:minor-bidi;&lt;br /&gt;	mso-fareast-language:en-us;}&lt;br /&gt;p.msolistparagraphcxspfirst, li.msolistparagraphcxspfirst, div.msolistparagraphcxspfirst&lt;br /&gt;	{mso-style-priority:34;&lt;br /&gt;	mso-style-unhide:no;&lt;br /&gt;	mso-style-qformat:yes;&lt;br /&gt;	mso-style-type:export-only;&lt;br /&gt;	margin-top:0cm;&lt;br /&gt;	margin-right:0cm;&lt;br /&gt;	margin-bottom:0cm;&lt;br /&gt;	margin-left:36.0pt;&lt;br /&gt;	margin-bottom:.0001pt;&lt;br /&gt;	mso-add-space:auto;&lt;br /&gt;	line-height:115%;&lt;br /&gt;	mso-pagination:widow-orphan;&lt;br /&gt;	font-size:11.0pt;&lt;br /&gt;	font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;&lt;br /&gt;	mso-ascii-font-family:calibri;&lt;br /&gt;	mso-ascii-theme-font:minor-latin;&lt;br /&gt;	mso-fareast-font-family:calibri;&lt;br /&gt;	mso-fareast-theme-font:minor-latin;&lt;br /&gt;	mso-hansi-font-family:calibri;&lt;br /&gt;	mso-hansi-theme-font:minor-latin;&lt;br /&gt;	mso-bidi-font-family:&quot;Times New Roman&quot;;&lt;br /&gt;	mso-bidi-theme-font:minor-bidi;&lt;br /&gt;	mso-fareast-language:en-us;}&lt;br /&gt;p.msolistparagraphcxspmiddle, li.msolistparagraphcxspmiddle, div.msolistparagraphcxspmiddle&lt;br /&gt;	{mso-style-priority:34;&lt;br /&gt;	mso-style-unhide:no;&lt;br /&gt;	mso-style-qformat:yes;&lt;br /&gt;	mso-style-type:export-only;&lt;br /&gt;	margin-top:0cm;&lt;br /&gt;	margin-right:0cm;&lt;br /&gt;	margin-bottom:0cm;&lt;br /&gt;	margin-left:36.0pt;&lt;br /&gt;	margin-bottom:.0001pt;&lt;br /&gt;	mso-add-space:auto;&lt;br /&gt;	line-height:115%;&lt;br /&gt;	mso-pagination:widow-orphan;&lt;br /&gt;	font-size:11.0pt;&lt;br /&gt;	font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;&lt;br /&gt;	mso-ascii-font-family:calibri;&lt;br /&gt;	mso-ascii-theme-font:minor-latin;&lt;br /&gt;	mso-fareast-font-family:calibri;&lt;br /&gt;	mso-fareast-theme-font:minor-latin;&lt;br /&gt;	mso-hansi-font-family:calibri;&lt;br /&gt;	mso-hansi-theme-font:minor-latin;&lt;br /&gt;	mso-bidi-font-family:&quot;Times New Roman&quot;;&lt;br /&gt;	mso-bidi-theme-font:minor-bidi;&lt;br /&gt;	mso-fareast-language:en-us;}&lt;br /&gt;p.msolistparagraphcxsplast, li.msolistparagraphcxsplast, div.msolistparagraphcxsplast&lt;br /&gt;	{mso-style-priority:34;&lt;br /&gt;	mso-style-unhide:no;&lt;br /&gt;	mso-style-qformat:yes;&lt;br /&gt;	mso-style-type:export-only;&lt;br /&gt;	margin-top:0cm;&lt;br /&gt;	margin-right:0cm;&lt;br /&gt;	margin-bottom:10.0pt;&lt;br /&gt;	margin-left:36.0pt;&lt;br /&gt;	mso-add-space:auto;&lt;br /&gt;	line-height:115%;&lt;br /&gt;	mso-pagination:widow-orphan;&lt;br /&gt;	font-size:11.0pt;&lt;br /&gt;	font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;&lt;br /&gt;	mso-ascii-font-family:calibri;&lt;br /&gt;	mso-ascii-theme-font:minor-latin;&lt;br /&gt;	mso-fareast-font-family:calibri;&lt;br /&gt;	mso-fareast-theme-font:minor-latin;&lt;br /&gt;	mso-hansi-font-family:calibri;&lt;br /&gt;	mso-hansi-theme-font:minor-latin;&lt;br /&gt;	mso-bidi-font-family:&quot;Times New Roman&quot;;&lt;br /&gt;	mso-bidi-theme-font:minor-bidi;&lt;br /&gt;	mso-fareast-language:en-us;}&lt;br /&gt;span.balloontextchar&lt;br /&gt;	{mso-style-name:&quot;Balloon Text Char&quot;;&lt;br /&gt;	mso-style-noshow:yes;&lt;br /&gt;	mso-style-priority:99;&lt;br /&gt;	mso-style-unhide:no;&lt;br /&gt;	mso-style-locked:yes;&lt;br /&gt;	mso-style-link:&quot;Balloon Text&quot;;&lt;br /&gt;	mso-ansi-font-size:8.0pt;&lt;br /&gt;	mso-bidi-font-size:8.0pt;&lt;br /&gt;	font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;;&lt;br /&gt;	mso-ascii-font-family:tahoma;&lt;br /&gt;	mso-hansi-font-family:tahoma;&lt;br /&gt;	mso-bidi-font-family:tahoma;}&lt;br /&gt;.msochpdefault&lt;br /&gt;	{mso-style-type:export-only;&lt;br /&gt;	mso-default-props:yes;&lt;br /&gt;	font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;&lt;br /&gt;	mso-ascii-font-family:calibri;&lt;br /&gt;	mso-ascii-theme-font:minor-latin;&lt;br /&gt;	mso-fareast-font-family:calibri;&lt;br /&gt;	mso-fareast-theme-font:minor-latin;&lt;br /&gt;	mso-hansi-font-family:calibri;&lt;br /&gt;	mso-hansi-theme-font:minor-latin;&lt;br /&gt;	mso-bidi-font-family:&quot;Times New Roman&quot;;&lt;br /&gt;	mso-bidi-theme-font:minor-bidi;&lt;br /&gt;	mso-fareast-language:en-us;}&lt;br /&gt;.msopapdefault&lt;br /&gt;	{mso-style-type:export-only;&lt;br /&gt;	margin-bottom:10.0pt;&lt;br /&gt;	line-height:115%;}&lt;br /&gt;@page wordsection1&lt;br /&gt;	{size:595.3pt 841.9pt;&lt;br /&gt;	margin:72.0pt 72.0pt 2.0cm 72.0pt;&lt;br /&gt;	mso-header-margin:35.4pt;&lt;br /&gt;	mso-footer-margin:35.4pt;&lt;br /&gt;	mso-paper-source:0;}&lt;br /&gt;div.wordsection1&lt;br /&gt;	{page:wordsection1;}&lt;br /&gt; /* List Definitions */&lt;br /&gt; @list l0&lt;br /&gt;	{mso-list-id:323365286;&lt;br /&gt;	mso-list-type:hybrid;&lt;br /&gt;	mso-list-template-ids:-594775382 134807553 134807555 134807557 134807553 134807555 134807557 134807553 134807555 134807557;}&lt;br /&gt;@list l0:level1&lt;br /&gt;	{mso-level-number-format:bullet;&lt;br /&gt;	mso-level-text:\f0b7;&lt;br /&gt;	mso-level-tab-stop:none;&lt;br /&gt;	mso-level-number-position:left;&lt;br /&gt;	text-indent:-18.0pt;&lt;br /&gt;	font-family:symbol;}&lt;br /&gt;@list l0:level2&lt;br /&gt;	{mso-level-number-format:bullet;&lt;br /&gt;	mso-level-text:o;&lt;br /&gt;	mso-level-tab-stop:none;&lt;br /&gt;	mso-level-number-position:left;&lt;br /&gt;	text-indent:-18.0pt;&lt;br /&gt;	font-family:&quot;Courier New&quot;;}&lt;br /&gt;@list l0:level3&lt;br /&gt;	{mso-level-number-format:bullet;&lt;br /&gt;	mso-level-text:\f0a7;&lt;br /&gt;	mso-level-tab-stop:none;&lt;br /&gt;	mso-level-number-position:left;&lt;br /&gt;	text-indent:-18.0pt;&lt;br /&gt;	font-family:wingdings;}&lt;br /&gt;@list l0:level4&lt;br /&gt;	{mso-level-number-format:bullet;&lt;br /&gt;	mso-level-text:\f0b7;&lt;br /&gt;	mso-level-tab-stop:none;&lt;br /&gt;	mso-level-number-position:left;&lt;br /&gt;	text-indent:-18.0pt;&lt;br /&gt;	font-family:symbol;}&lt;br /&gt;@list l0:level5&lt;br /&gt;	{mso-level-number-format:bullet;&lt;br /&gt;	mso-level-text:o;&lt;br /&gt;	mso-level-tab-stop:none;&lt;br /&gt;	mso-level-number-position:left;&lt;br /&gt;	text-indent:-18.0pt;&lt;br /&gt;	font-family:&quot;Courier New&quot;;}&lt;br /&gt;@list l0:level6&lt;br /&gt;	{mso-level-number-format:bullet;&lt;br /&gt;	mso-level-text:\f0a7;&lt;br /&gt;	mso-level-tab-stop:none;&lt;br /&gt;	mso-level-number-position:left;&lt;br /&gt;	text-indent:-18.0pt;&lt;br /&gt;	font-family:wingdings;}&lt;br /&gt;@list l0:level7&lt;br /&gt;	{mso-level-number-format:bullet;&lt;br /&gt;	mso-level-text:\f0b7;&lt;br /&gt;	mso-level-tab-stop:none;&lt;br /&gt;	mso-level-number-position:left;&lt;br /&gt;	text-indent:-18.0pt;&lt;br /&gt;	font-family:symbol;}&lt;br /&gt;@list l0:level8&lt;br /&gt;	{mso-level-number-format:bullet;&lt;br /&gt;	mso-level-text:o;&lt;br /&gt;	mso-level-tab-stop:none;&lt;br /&gt;	mso-level-number-position:left;&lt;br /&gt;	text-indent:-18.0pt;&lt;br /&gt;	font-family:&quot;Courier New&quot;;}&lt;br /&gt;@list l0:level9&lt;br /&gt;	{mso-level-number-format:bullet;&lt;br /&gt;	mso-level-text:\f0a7;&lt;br /&gt;	mso-level-tab-stop:none;&lt;br /&gt;	mso-level-number-position:left;&lt;br /&gt;	text-indent:-18.0pt;&lt;br /&gt;	font-family:wingdings;}&lt;br /&gt;@list l1&lt;br /&gt;	{mso-list-id:633801148;&lt;br /&gt;	mso-list-type:hybrid;&lt;br /&gt;	mso-list-template-ids:1677916706 134807553 134807555 134807557 134807553 134807555 134807557 134807553 134807555 134807557;}&lt;br /&gt;@list l1:level1&lt;br /&gt;	{mso-level-number-format:bullet;&lt;br /&gt;	mso-level-text:\f0b7;&lt;br /&gt;	mso-level-tab-stop:none;&lt;br /&gt;	mso-level-number-position:left;&lt;br /&gt;	text-indent:-18.0pt;&lt;br /&gt;	font-family:symbol;}&lt;br /&gt;@list l1:level2&lt;br /&gt;	{mso-level-number-format:bullet;&lt;br /&gt;	mso-level-text:o;&lt;br /&gt;	mso-level-tab-stop:none;&lt;br /&gt;	mso-level-number-position:left;&lt;br /&gt;	text-indent:-18.0pt;&lt;br /&gt;	font-family:&quot;Courier New&quot;;}&lt;br /&gt;@list l1:level3&lt;br /&gt;	{mso-level-number-format:bullet;&lt;br /&gt;	mso-level-text:\f0a7;&lt;br /&gt;	mso-level-tab-stop:none;&lt;br /&gt;	mso-level-number-position:left;&lt;br /&gt;	text-indent:-18.0pt;&lt;br /&gt;	font-family:wingdings;}&lt;br /&gt;@list l1:level4&lt;br /&gt;	{mso-level-number-format:bullet;&lt;br /&gt;	mso-level-text:\f0b7;&lt;br /&gt;	mso-level-tab-stop:none;&lt;br /&gt;	mso-level-number-position:left;&lt;br /&gt;	text-indent:-18.0pt;&lt;br /&gt;	font-family:symbol;}&lt;br /&gt;@list l1:level5&lt;br /&gt;	{mso-level-number-format:bullet;&lt;br /&gt;	mso-level-text:o;&lt;br /&gt;	mso-level-tab-stop:none;&lt;br /&gt;	mso-level-number-position:left;&lt;br /&gt;	text-indent:-18.0pt;&lt;br /&gt;	font-family:&quot;Courier New&quot;;}&lt;br /&gt;@list l1:level6&lt;br /&gt;	{mso-level-number-format:bullet;&lt;br /&gt;	mso-level-text:\f0a7;&lt;br /&gt;	mso-level-tab-stop:none;&lt;br /&gt;	mso-level-number-position:left;&lt;br /&gt;	text-indent:-18.0pt;&lt;br /&gt;	font-family:wingdings;}&lt;br /&gt;@list l1:level7&lt;br /&gt;	{mso-level-number-format:bullet;&lt;br /&gt;	mso-level-text:\f0b7;&lt;br /&gt;	mso-level-tab-stop:none;&lt;br /&gt;	mso-level-number-position:left;&lt;br /&gt;	text-indent:-18.0pt;&lt;br /&gt;	font-family:symbol;}&lt;br /&gt;@list l1:level8&lt;br /&gt;	{mso-level-number-format:bullet;&lt;br /&gt;	mso-level-text:o;&lt;br /&gt;	mso-level-tab-stop:none;&lt;br /&gt;	mso-level-number-position:left;&lt;br /&gt;	text-indent:-18.0pt;&lt;br /&gt;	font-family:&quot;Courier New&quot;;}&lt;br /&gt;@list l1:level9&lt;br /&gt;	{mso-level-number-format:bullet;&lt;br /&gt;	mso-level-text:\f0a7;&lt;br /&gt;	mso-level-tab-stop:none;&lt;br /&gt;	mso-level-number-position:left;&lt;br /&gt;	text-indent:-18.0pt;&lt;br /&gt;	font-family:wingdings;}&lt;br /&gt;@list l2&lt;br /&gt;	{mso-list-id:1765958515;&lt;br /&gt;	mso-list-type:hybrid;&lt;br /&gt;	mso-list-template-ids:873354456 134807553 134807555 134807557 134807553 134807555 134807557 134807553 134807555 134807557;}&lt;br /&gt;@list l2:level1&lt;br /&gt;	{mso-level-number-format:bullet;&lt;br /&gt;	mso-level-text:\f0b7;&lt;br /&gt;	mso-level-tab-stop:none;&lt;br /&gt;	mso-level-number-position:left;&lt;br /&gt;	text-indent:-18.0pt;&lt;br /&gt;	font-family:symbol;}&lt;br /&gt;@list l2:level2&lt;br /&gt;	{mso-level-number-format:bullet;&lt;br /&gt;	mso-level-text:o;&lt;br /&gt;	mso-level-tab-stop:none;&lt;br /&gt;	mso-level-number-position:left;&lt;br /&gt;	text-indent:-18.0pt;&lt;br /&gt;	font-family:&quot;Courier New&quot;;}&lt;br /&gt;@list l2:level3&lt;br /&gt;	{mso-level-number-format:bullet;&lt;br /&gt;	mso-level-text:\f0a7;&lt;br /&gt;	mso-level-tab-stop:none;&lt;br /&gt;	mso-level-number-position:left;&lt;br /&gt;	text-indent:-18.0pt;&lt;br /&gt;	font-family:wingdings;}&lt;br /&gt;@list l2:level4&lt;br /&gt;	{mso-level-number-format:bullet;&lt;br /&gt;	mso-level-text:\f0b7;&lt;br /&gt;	mso-level-tab-stop:none;&lt;br /&gt;	mso-level-number-position:left;&lt;br /&gt;	text-indent:-18.0pt;&lt;br /&gt;	font-family:symbol;}&lt;br /&gt;@list l2:level5&lt;br /&gt;	{mso-level-number-format:bullet;&lt;br /&gt;	mso-level-text:o;&lt;br /&gt;	mso-level-tab-stop:none;&lt;br /&gt;	mso-level-number-position:left;&lt;br /&gt;	text-indent:-18.0pt;&lt;br /&gt;	font-family:&quot;Courier New&quot;;}&lt;br /&gt;@list l2:level6&lt;br /&gt;	{mso-level-number-format:bullet;&lt;br /&gt;	mso-level-text:\f0a7;&lt;br /&gt;	mso-level-tab-stop:none;&lt;br /&gt;	mso-level-number-position:left;&lt;br /&gt;	text-indent:-18.0pt;&lt;br /&gt;	font-family:wingdings;}&lt;br /&gt;@list l2:level7&lt;br /&gt;	{mso-level-number-format:bullet;&lt;br /&gt;	mso-level-text:\f0b7;&lt;br /&gt;	mso-level-tab-stop:none;&lt;br /&gt;	mso-level-number-position:left;&lt;br /&gt;	text-indent:-18.0pt;&lt;br /&gt;	font-family:symbol;}&lt;br /&gt;@list l2:level8&lt;br /&gt;	{mso-level-number-format:bullet;&lt;br /&gt;	mso-level-text:o;&lt;br /&gt;	mso-level-tab-stop:none;&lt;br /&gt;	mso-level-number-position:left;&lt;br /&gt;	text-indent:-18.0pt;&lt;br /&gt;	font-family:&quot;Courier New&quot;;}&lt;br /&gt;@list l2:level9&lt;br /&gt;	{mso-level-number-format:bullet;&lt;br /&gt;	mso-level-text:\f0a7;&lt;br /&gt;	mso-level-tab-stop:none;&lt;br /&gt;	mso-level-number-position:left;&lt;br /&gt;	text-indent:-18.0pt;&lt;br /&gt;	font-family:wingdings;}&lt;br /&gt;ol&lt;br /&gt;	{margin-bottom:0cm;}&lt;br /&gt;ul&lt;br /&gt;	{margin-bottom:0cm;}&lt;br /&gt;--&gt;&lt;/style&gt;  &lt;div class=&quot;WordSection1&quot;&gt;   &lt;p class=&quot;MsoNormal&quot;&gt;     &lt;br /&gt;This is the 4&lt;sup&gt;th&lt;/sup&gt; in a series of posts about unit testing:&lt;b style=&quot;mso-bidi-font-weight: normal&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 36pt&quot;&gt;&lt;b style=&quot;mso-bidi-font-weight: normal&quot;&gt;&lt;a href=&quot;http://jonlanceley.blogspot.co.uk/2015/08/unit-testing-part-1-without-using.html&quot; target=&quot;_blank&quot;&gt;Unit Testing (part 1) - Without using a mocking framework&lt;/a&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 36pt&quot;&gt;&lt;b style=&quot;mso-bidi-font-weight: normal&quot;&gt;&lt;a href=&quot;http://jonlanceley.blogspot.co.uk/2015/08/unit-testing-part-2-faking-httpcontext.html&quot; target=&quot;_blank&quot;&gt;Unit Testing (part 2) - Faking the HttpContext and HttpContextBase&lt;/a&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 36pt&quot;&gt;&lt;b style=&quot;mso-bidi-font-weight: normal&quot;&gt;&lt;a href=&quot;http://jonlanceley.blogspot.co.uk/2015/08/unit-testing-part-3-running-unit-tests.html&quot; target=&quot;_blank&quot;&gt;Unit Testing (part 3) - Running Unit Tests &amp;amp; Code Coverage&lt;/a&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 36pt&quot;&gt;&lt;b style=&quot;mso-bidi-font-weight: normal&quot;&gt;Unit Testing (part 4) - Faking Entity Framework code first DbContext &amp;amp; DbSet&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: black; mso-bidi-font-family: consolas&quot;&gt;&lt;o:p&gt;&amp;#160;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: black; mso-bidi-font-family: consolas&quot;&gt;Following on from the last 3 articles we can use the same approach of faking with test doubles on our database repository methods.&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: black; mso-bidi-font-family: consolas&quot;&gt;I’m using Entity Framework 6 code first and I want to be able to call the code in my repository layer so I can test the where clauses etc, but I do not want to actually call the database.&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160; &lt;/span&gt;Entity framework has a &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; line-height: 115%; mso-highlight: white&quot;&gt;DBContext&lt;/span&gt;&lt;span style=&quot;color: black; mso-bidi-font-family: consolas&quot;&gt; and a &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; line-height: 115%; mso-highlight: white&quot;&gt;DbSet&lt;/span&gt;&lt;span style=&quot;color: black; mso-bidi-font-family: consolas&quot;&gt; we just need to fake them.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: black; mso-bidi-font-family: consolas&quot;&gt;All of our model properties implement this interface &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; line-height: 115%; mso-highlight: white&quot;&gt;IDbEntity&lt;/span&gt;&lt;span style=&quot;color: black; mso-bidi-font-family: consolas&quot;&gt;.&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;public&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;interface&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;IDbEntity&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;TPrimaryKey&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white&quot;&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white&quot;&gt; Unique identifier for this entity.&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white&quot;&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;TPrimaryKey&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; ID { &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;get&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;set&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 115%; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}&lt;/span&gt;&lt;span style=&quot;color: black; mso-bidi-font-family: consolas&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: black; mso-bidi-font-family: consolas&quot;&gt;What this does is say we must have a primary key called ID on each model.&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160; &lt;/span&gt;We will use this later to implement a fast generic DbSet Find method.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;Country&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; : &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: #2b91af; mso-highlight: yellow&quot;&gt;IDbEntity&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: black; mso-highlight: yellow&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: #2b91af; mso-highlight: yellow&quot;&gt;Int32&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: black; mso-highlight: yellow&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;[&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;Key&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;DatabaseGenerated&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;DatabaseGeneratedOption&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;.None)]&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: blue; mso-highlight: yellow&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: black; mso-highlight: yellow&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: #2b91af; mso-highlight: yellow&quot;&gt;Int32&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: black; mso-highlight: yellow&quot;&gt; ID { &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: blue; mso-highlight: yellow&quot;&gt;get&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: black; mso-highlight: yellow&quot;&gt;; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: blue; mso-highlight: yellow&quot;&gt;set&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: black; mso-highlight: yellow&quot;&gt;; }&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;[&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;Required&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;[&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;MaxLength&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;(100)]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 115%; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; line-height: 115%; mso-highlight: white&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 115%; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; line-height: 115%; mso-highlight: white&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 115%; mso-highlight: white&quot;&gt; Name { &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; line-height: 115%; mso-highlight: white&quot;&gt;get&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 115%; mso-highlight: white&quot;&gt;; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; line-height: 115%; mso-highlight: white&quot;&gt;set&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 115%; mso-highlight: white&quot;&gt;; }&lt;/span&gt;&lt;span style=&quot;color: black; mso-bidi-font-family: consolas&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: black; mso-bidi-font-family: consolas&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;color: black; mso-bidi-font-family: consolas&quot;&gt;First we need to setup our DbContext so we start with our interface which just contains a list of DbSet’s (which is what we need in order to begin faking it for the unit tests).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;interface&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;ISiteDBContext&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;DbSet&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;Country&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;gt; Countries { &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;get&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;set&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;; }&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 115%; mso-highlight: white&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: black; mso-bidi-font-family: consolas&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;span style=&quot;font-size: 11pt; font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;; background: white; line-height: 115%; mso-bidi-font-family: consolas; mso-highlight: white; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-fareast-language: en-us; mso-ansi-language: en-gb; mso-bidi-language: ar-sa&quot;&gt;     &lt;br style=&quot;page-break-before: always; mso-special-character: line-break&quot; clear=&quot;all&quot; /&gt;&lt;/span&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;background: white; mso-bidi-font-family: consolas; mso-highlight: white&quot;&gt;Our concrete class that the MVC web site uses looks like this:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;SiteDBContext&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; : &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;DbContext&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: #2b91af; mso-highlight: yellow&quot;&gt;ISiteDBContext&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: black; mso-highlight: yellow&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; SiteDBContext()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;: &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;base&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white&quot;&gt;// Disable database initialisation (e.g. when the site is first run)&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt 36pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;Database&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;.SetInitializer&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;SiteDBContext&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;gt;(&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;null&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&amp;#160;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; SiteDBContext(&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; nameOrConnectionString)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;: &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;base&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;(nameOrConnectionString)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white&quot;&gt;// Disable database initialisation (e.g. when the site is first run)&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt 36pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&lt;/span&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;Database&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;.SetInitializer&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;SiteDBContext&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;gt;(&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;null&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: blue; mso-highlight: yellow&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: black; mso-highlight: yellow&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: #2b91af; mso-highlight: yellow&quot;&gt;DbSet&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: black; mso-highlight: yellow&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: #2b91af; mso-highlight: yellow&quot;&gt;Country&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: black; mso-highlight: yellow&quot;&gt;&amp;gt; Countries { &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: blue; mso-highlight: yellow&quot;&gt;get&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: black; mso-highlight: yellow&quot;&gt;; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: blue; mso-highlight: yellow&quot;&gt;set&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: black; mso-highlight: yellow&quot;&gt;; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;protected&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;override&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; OnModelCreating(&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;DbModelBuilder&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; modelBuilder)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white&quot;&gt;// Fluent API commands go here e.g.&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;modelBuilder.Conventions.Remove&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;PluralizingTableNameConvention&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;gt;();&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt 36pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;modelBuilder.Conventions.Remove&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;OneToManyCascadeDeleteConvention&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;gt;();&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;base&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;.OnModelCreating(modelBuilder);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}&lt;/span&gt;&lt;span style=&quot;background: white; mso-bidi-font-family: consolas; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;background: white; mso-bidi-font-family: consolas; mso-highlight: white&quot;&gt;&lt;o:p&gt;&amp;#160;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;background: white; mso-bidi-font-family: consolas; mso-highlight: white&quot;&gt;And our fake one for unit testing looks like this (note the differences in yellow).&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160; &lt;/span&gt;We are implementing the interface but then in the constructor setting the Country DbSet to use our &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;FakeDbSet&lt;/span&gt;&lt;span style=&quot;background: white; mso-bidi-font-family: consolas; mso-highlight: white&quot;&gt; instead:&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;FakeSiteDBContext&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; : &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;DbContext&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: #2b91af; mso-highlight: yellow&quot;&gt;ISiteDBContext&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; FakeSiteDBContext() : &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;base&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;// Disable code first auto creation of a database &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;Database&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;.SetInitializer&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;FakeSiteDBContext&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;gt;(&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;null&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;blockquote&gt;     &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 115%; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&lt;/span&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: black; line-height: 115%; mso-highlight: yellow&quot;&gt;Countries = &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: blue; line-height: 115%; mso-highlight: yellow&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: black; line-height: 115%; mso-highlight: yellow&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: #2b91af; line-height: 115%; mso-highlight: yellow&quot;&gt;FakeDbSet&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: black; line-height: 115%; mso-highlight: yellow&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: #2b91af; line-height: 115%; mso-highlight: yellow&quot;&gt;Country&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: black; line-height: 115%; mso-highlight: yellow&quot;&gt;&amp;gt;();&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; color: black; line-height: 115%&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/blockquote&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 36pt&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; color: black; line-height: 115%&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 36pt&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: blue; line-height: 115%; mso-highlight: yellow&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: black; line-height: 115%; mso-highlight: yellow&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: #2b91af; line-height: 115%; mso-highlight: yellow&quot;&gt;DbSet&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: black; line-height: 115%; mso-highlight: yellow&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: #2b91af; line-height: 115%; mso-highlight: yellow&quot;&gt;Country&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: black; line-height: 115%; mso-highlight: yellow&quot;&gt;&amp;gt; Countries { &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: blue; line-height: 115%; mso-highlight: yellow&quot;&gt;get&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: black; line-height: 115%; mso-highlight: yellow&quot;&gt;; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: blue; line-height: 115%; mso-highlight: yellow&quot;&gt;set&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: black; line-height: 115%; mso-highlight: yellow&quot;&gt;; }&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; color: black; line-height: 115%&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; text-indent: 36pt; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;override&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;DbSet&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;TEntity&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;gt; Set&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;TEntity&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;gt;()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;foreach&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;PropertyInfo&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; property &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;in&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt 72pt; line-height: normal; text-autospace: ; text-indent: 36pt; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;typeof&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;FakeSiteDBContext&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;).GetProperties())&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; (property.PropertyType == &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;typeof&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;DbSet&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;TEntity&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;gt;))&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;var&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; value = property.GetValue(&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;null&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;as&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;DbSet&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;TEntity&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; value;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&amp;#160;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white&quot;&gt;// If the above fails fall back to the base default&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;base&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;.Set&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;TEntity&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; text-indent: 36pt&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 115%; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160; &lt;/span&gt;}&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; color: black; line-height: 115%&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; color: black; line-height: 115%&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&lt;/span&gt;}&lt;/span&gt;&lt;span style=&quot;color: black; mso-bidi-font-family: consolas&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;And this is the &lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; line-height: 115%; mso-highlight: white&quot;&gt;FakeDbSet&lt;/span&gt;: &lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;sealed&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;FakeDbSet&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;TEntity&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;gt; : &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;DbSet&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;TEntity&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;gt;, &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;IQueryable&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;IEnumerable&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;TEntity&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;gt;, &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;IDbAsyncEnumerable&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;TEntity&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;where&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;TEntity&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; : &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;ObservableCollection&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;TEntity&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;gt; _data;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;IQueryable&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; _query;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&amp;#160;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; FakeDbSet()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;_data = &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;ObservableCollection&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;TEntity&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;_query = _data.AsQueryable();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;#160;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;override&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;TEntity&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; Find(&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;params&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;object&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;[] keyValues)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white&quot;&gt;// &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: green; mso-highlight: yellow&quot;&gt;Find by the Primary Key (ID) as defined in the interface IDbEntity &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt 36pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;// which is set on all of our model classes. This is a fast generic way to&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt 36pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;// implement find.&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white&quot;&gt;// There is only currently 1 primary keyValue that can be passed in so we &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt 36pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;// use [0] to find it&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;var&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; result = _data.OfType&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;IDbEntity&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;Int32&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;gt;&amp;gt;().Where(m =&amp;gt; m.ID == &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt 288pt; line-height: normal; text-autospace: ; text-indent: 36pt; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;Int32&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;)keyValues[0]);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;var&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; myEntity = (&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;TEntity&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;)result.SingleOrDefault();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; myEntity;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&amp;#160;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;override&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;TEntity&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; Add(&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;TEntity&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; item)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white&quot;&gt;// In our FakeDbSet when an item is added to the context we increment it&#39;s &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; text-indent: 36pt; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;// primary Key (ID column) otherwise it will always be 0&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white&quot;&gt;// All our model classes inherit IDbEntity which defines an ID column as &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; text-indent: 36pt; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;// the primary key&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white&quot;&gt;// But note this will not update navigation properties, apperently there &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt 36pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;// is no way in EF to do that yet (so you have to work around it)&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; (item &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;is&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;IDbEntity&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;Int32&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;var&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; myItem = (&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;IDbEntity&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;Int32&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;gt;)item;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; (myItem.ID == 0)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white&quot;&gt;// Get the last record entered, so we can get it&#39;s ID then add 1 &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt 72pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;// to it for the new record&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;var&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; lastItem = _data.LastOrDefault();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; (lastItem == &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;null&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;myItem.ID = 1;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;else&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;var&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; myLastItem = (&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;IDbEntity&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;Int32&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;gt;)lastItem;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;myItem.ID = myLastItem.ID + 1;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&amp;#160;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;_data.Add(item);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; item;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;override&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;TEntity&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; Remove(&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;TEntity&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; item)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;_data.Remove(item);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; item;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&amp;#160;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;override&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;TEntity&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; Attach(&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;TEntity&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; item)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;_data.Add(item);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; item;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&amp;#160;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;override&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;TEntity&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; Create()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;Activator&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;.CreateInstance&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;TEntity&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&amp;#160;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;override&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;TDerivedEntity&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; Create&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;TDerivedEntity&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;gt;()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;Activator&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;.CreateInstance&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;TDerivedEntity&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&amp;#160;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;override&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;ObservableCollection&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;TEntity&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;gt; Local&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;get&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; { &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; _data; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&amp;#160;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;Type&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;IQueryable&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;.ElementType&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;get&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; { &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; _query.ElementType; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&amp;#160;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;Expression&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;IQueryable&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;.Expression&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;get&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; { &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; _query.Expression; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&amp;#160;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;IQueryProvider&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;IQueryable&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;.Provider&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;get&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; { &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;TestDbAsyncQueryProvider&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;TEntity&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;gt;(_query.Provider); }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&amp;#160;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;System.Collections.&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;IEnumerator&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; System.Collections.&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;IEnumerable&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;.GetEnumerator()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; _data.GetEnumerator();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&amp;#160;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;IEnumerator&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;TEntity&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;IEnumerable&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;TEntity&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;gt;.GetEnumerator()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; _data.GetEnumerator();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&amp;#160;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;IDbAsyncEnumerator&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;TEntity&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;IDbAsyncEnumerable&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;TEntity&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;gt;.GetAsyncEnumerator()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;TestDbAsyncEnumerator&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;TEntity&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;gt;(_data.GetEnumerator());&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&amp;#160;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;internal&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;TestDbAsyncQueryProvider&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;TEntity&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;gt; : &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;IDbAsyncQueryProvider&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;private&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;readonly&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;IQueryProvider&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; _inner;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&amp;#160;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;internal&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; TestDbAsyncQueryProvider(&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;IQueryProvider&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; inner)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;_inner = inner;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&amp;#160;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;IQueryable&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; CreateQuery(&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;Expression&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; expression)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;TestDbAsyncEnumerable&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;TEntity&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;gt;(expression);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&amp;#160;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;IQueryable&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;TElement&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;gt; CreateQuery&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;TElement&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;gt;(&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;Expression&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; expression)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;TestDbAsyncEnumerable&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;TElement&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;gt;(expression);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&amp;#160;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;object&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; Execute(&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;Expression&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; expression)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; _inner.Execute(expression);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&amp;#160;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;TResult&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; Execute&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;TResult&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;gt;(&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;Expression&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; expression)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; _inner.Execute&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;TResult&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;gt;(expression);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&amp;#160;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;Task&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;object&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;gt; ExecuteAsync(&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;Expression&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; expression, &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;CancellationToken&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; cancellationToken)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;Task&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;.FromResult(Execute(expression));&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&amp;#160;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;Task&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;TResult&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;gt; ExecuteAsync&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;TResult&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;gt;(&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;Expression&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; expression, &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;CancellationToken&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; cancellationToken)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;Task&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;.FromResult(Execute&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;TResult&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;gt;(expression));&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&amp;#160;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;internal&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;TestDbAsyncEnumerable&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;T&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;gt; : &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;EnumerableQuery&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;T&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;gt;, &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;IDbAsyncEnumerable&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;T&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;gt;, &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;IQueryable&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;T&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; TestDbAsyncEnumerable(&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;IEnumerable&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;T&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;gt; enumerable)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;: &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;base&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;(enumerable)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{ }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&amp;#160;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; TestDbAsyncEnumerable(&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;Expression&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; expression)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;: &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;base&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;(expression)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{ }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&amp;#160;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;IDbAsyncEnumerator&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;T&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;gt; GetAsyncEnumerator()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;TestDbAsyncEnumerator&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;T&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;gt;(&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;.AsEnumerable().GetEnumerator());&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&amp;#160;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;IDbAsyncEnumerator&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;IDbAsyncEnumerable&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;.GetAsyncEnumerator()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; GetAsyncEnumerator();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&amp;#160;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;IQueryProvider&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;IQueryable&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;.Provider&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;get&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; { &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;TestDbAsyncQueryProvider&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;T&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;gt;(&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;); }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&amp;#160;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;internal&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;TestDbAsyncEnumerator&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;T&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;gt; : &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;IDbAsyncEnumerator&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;T&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;private&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;readonly&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;IEnumerator&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;T&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;gt; _inner;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&amp;#160;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; TestDbAsyncEnumerator(&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;IEnumerator&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;T&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;gt; inner)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;_inner = inner;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&amp;#160;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; Dispose()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;_inner.Dispose();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&amp;#160;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;Task&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;bool&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;gt; MoveNextAsync(&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;CancellationToken&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; cancellationToken)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;Task&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;.FromResult(_inner.MoveNext());&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&amp;#160;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;T&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; Current&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;get&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; { &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; _inner.Current; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&amp;#160;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;object&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;IDbAsyncEnumerator&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;.Current&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;get&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; { &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; Current; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 115%; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; color: black; line-height: 115%&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: black; mso-bidi-font-family: consolas&quot;&gt;&lt;o:p&gt;&amp;#160;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: black; mso-bidi-font-family: consolas&quot;&gt;Then using dependency injection in your unit test you register the &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; line-height: 115%; mso-highlight: white&quot;&gt;FakeSiteDBContext&lt;/span&gt;&lt;span style=&quot;color: black; mso-bidi-font-family: consolas&quot;&gt;. &lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&lt;/span&gt;Using Unity it would be:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;blockquote&gt;     &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 115%; mso-highlight: white&quot;&gt;container.RegisterType&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; line-height: 115%; mso-highlight: white&quot;&gt;DbContext&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 115%; mso-highlight: white&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; line-height: 115%; mso-highlight: white&quot;&gt;FakeSiteDBContext&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 115%; mso-highlight: white&quot;&gt;&amp;gt;(&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; line-height: 115%; mso-highlight: white&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 115%; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; line-height: 115%; mso-highlight: white&quot;&gt;PerRequestLifetimeManager&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 115%; mso-highlight: white&quot;&gt;());&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; color: black; line-height: 115%&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/blockquote&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: black; mso-bidi-font-family: consolas&quot;&gt;And in the website you’d do:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;blockquote&gt;     &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 115%; mso-highlight: white&quot;&gt;container.RegisterType&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; line-height: 115%; mso-highlight: white&quot;&gt;DbContext&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 115%; mso-highlight: white&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; line-height: 115%; mso-highlight: white&quot;&gt;SiteDBContext&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 115%; mso-highlight: white&quot;&gt;&amp;gt;(&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; line-height: 115%; mso-highlight: white&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 115%; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; line-height: 115%; mso-highlight: white&quot;&gt;PerRequestLifetimeManager&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 115%; mso-highlight: white&quot;&gt;());&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; color: black; line-height: 115%&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/blockquote&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; color: black; line-height: 115%&quot;&gt;&lt;o:p&gt;&amp;#160;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;background: white; color: black; mso-bidi-font-family: consolas; mso-highlight: white&quot;&gt;The unit test would look like this, in this example I’m calling a basketService method which would do all the same calls as if we were running the MVC web site, except in the test it is going to call our &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;FakeDbSet&lt;/span&gt;&lt;span style=&quot;background: white; color: black; mso-bidi-font-family: consolas; mso-highlight: white&quot;&gt; and &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;FakeDbSiteContext&lt;/span&gt;&lt;span style=&quot;background: white; color: black; mso-bidi-font-family: consolas; mso-highlight: white&quot;&gt; to avoid hitting a database because that’s what we told our dependency injection to do swap out every instance of &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;DbContext&lt;/span&gt;&lt;span style=&quot;background: white; color: black; mso-bidi-font-family: consolas; mso-highlight: white&quot;&gt; with our &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;FakeSiteDBContext&lt;/span&gt;&lt;span style=&quot;background: white; color: black; mso-bidi-font-family: consolas; mso-highlight: white&quot;&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;background: white; color: black; mso-bidi-font-family: consolas; mso-highlight: white&quot;&gt;&lt;o:p&gt;&amp;#160;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;TestMethod&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; AddToBasket_AddUSDItemToNewBasket()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;HttpContext&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;.Current = &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;FakeHttpContext&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;().CreateFakeHttpContext();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;unityContainer = &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;UnityConfig&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;.GetConfiguredContainer();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;var&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; basketService = unityContainer.Resolve&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;IBasketService&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;var&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; httpContextWrapper = &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;FakeHttpContextWrapper&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;(httpContext: &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt 180pt; line-height: normal; text-autospace: ; text-indent: 36pt; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;HttpContext&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;.Current);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&amp;#160;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;var&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; model = basketService.AddSubscriptionItemToBasket(httpContextWrapper, params go here…);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;Assert&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;.AreEqual(&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;&amp;quot;en-US&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;, model.CurrencyFormat.CurrencyCulture, &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;&amp;quot;CurrencyCulture&amp;quot;);&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 115%; mso-highlight: white&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; color: black; line-height: 115%&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; color: black; line-height: 115%&quot;&gt;&lt;o:p&gt;&amp;#160;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: black; mso-bidi-font-family: consolas&quot;&gt;If you wanted to you can also seed the entity framework models with the same seed data you’d use in the real database, remember it’s all in memory and it’s fast.&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160; &lt;/span&gt;It’s also useful as your working with the same data rather than creating fake data for every test.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: black; mso-bidi-font-family: consolas&quot;&gt;There is nothing stopping you creating specific test data for one test as well, all you have to do is add populated models to the Entity Framework DbContext at the start of a unit test.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt 36pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;var&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; order = &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;Order&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;UserBasketID = userBasketId,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;OrderItems = &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;Collection&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;OrderItem&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;gt;(),&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;DateCreated = &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;DateTime&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;.Now&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;};&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&amp;#160;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;var&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; orderItem1 = &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;OrderItem&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;Price = 2.00M,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;Quantity = 1,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;DateCreated = &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;DateTime&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;.Now,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: black; mso-highlight: yellow&quot;&gt;Order = order&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;};&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;order.OrderItems.Add(orderItem1);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;dbContext.Orders.Add(order);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 115%; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;dbContext.OrderItems.Add(orderItem1);&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; color: black; line-height: 115%&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;No need to save (remember it’s in memory all you have to do is .Add).&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160; &lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;The only downside with this approach I’ve found so far are your site will run but the tests may fail because:&lt;/p&gt;    &lt;ul&gt;     &lt;li&gt;       &lt;div class=&quot;MsoListParagraphCxSpFirst&quot; style=&quot;text-indent: -18pt; mso-list: l0 level1 lfo2&quot;&gt;Navigation property might = null.&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160; &lt;/span&gt;&lt;/div&gt;     &lt;/li&gt;      &lt;li&gt;       &lt;div class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;text-indent: -18pt; mso-list: l0 level1 lfo2&quot;&gt;Not all the data is added to the context.&lt;/div&gt;     &lt;/li&gt;   &lt;/ul&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;Remember we are faking out the &lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; line-height: 115%; mso-highlight: white&quot;&gt;DbContext&lt;/span&gt; and &lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; line-height: 115%; mso-highlight: white&quot;&gt;DbSet&lt;/span&gt; so we do not get all the Entity Framework functionality.&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160; &lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;To address both of these points:&lt;/p&gt;    &lt;ul&gt;     &lt;li&gt;       &lt;div class=&quot;MsoListParagraphCxSpFirst&quot; style=&quot;text-indent: -18pt; mso-list: l2 level1 lfo3&quot;&gt;If you have reference/navigation properties make sure you set them like the ones in yellow above (we assign the order to the orderItem).&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160; &lt;/span&gt;This way your repository methods navigation properties will work in your unit test and won’t be null.&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160; &lt;/span&gt;&lt;/div&gt;     &lt;/li&gt;      &lt;li&gt;       &lt;div class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;text-indent: -18pt; mso-list: l2 level1 lfo3&quot;&gt;If you think back to EF v1 days you had to add the items to the context that you want to save.&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160; &lt;/span&gt;So in the example above EF would be fine with just the dbContext.Orders.Add(order) line it would know there are orderItems that also need saving.&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160; &lt;/span&gt;But the fake DbContext won’t!&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160; &lt;/span&gt;So if we are testing a lookup directly for orderItems our test would show 0 records.&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160; &lt;br /&gt;&lt;/span&gt;          &lt;br /&gt;We just have to also attach the orderItems to the dbContext too.&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160; &lt;/span&gt;It won’t affect the way the site runs and our tests will pass.&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160; &lt;/span&gt;So there is a compromise to be made here but in my opinion a small one.&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160; &lt;/span&gt;Some people will argue that we are changing our site code to make the tests pass, and yes we are (slightly and only when we hit this scenario which has not happened to me much so far).&lt;/div&gt;     &lt;/li&gt;   &lt;/ul&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;You should always follow up with UI integration tests such as Selenium, Microsoft’s Coded UI etc to test all the site functions and 3&lt;sup&gt;rd&lt;/sup&gt; party calls work, these will be slower, but at least now we’ve got a way to run lots of fast unit tests before the code leaves Visual Studio.&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;Using this approach here are just some of my unit tests so you can see how quick they are:&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 36pt&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWUg7o5dTH8P8yOeFFuPRy8LVhMksnfM0pr1Ht6v8Jkd6GRCA1xMPYVZypmWGNzG2ud2q_T6ZDP6xkPAdBpGLpGSm15QKEMqX5bzoHeC-hnUS1tdDrzNIpYgbBb9XsryqMg3XTkqV1i99D/s1600-h/image2.png&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px; border-top-width: 0px&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiVbWfZ-u8BzCn7BrkX1tLuPU5dW2a8qg_vsCxLOVvFMWWfEXRxGupJTlhrWOrWowyjnRWWf7ta7Xh1WCcuCWn6RpZQDvlSMAihOhMRI3_s9N7c4Anj8P4aVOVP-ql1fqTH1ZXGVgpKPeOL/?imgmax=800&quot; width=&quot;171&quot; height=&quot;187&quot; /&gt;&lt;/a&gt;&lt;/p&gt; &lt;/div&gt;  </content><link rel='replies' type='application/atom+xml' href='http://jonlanceley.blogspot.com/feeds/1524875083596247911/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jonlanceley.blogspot.com/2015/08/unit-testing-part-4-faking-entity.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2990193854398450266/posts/default/1524875083596247911'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2990193854398450266/posts/default/1524875083596247911'/><link rel='alternate' type='text/html' href='http://jonlanceley.blogspot.com/2015/08/unit-testing-part-4-faking-entity.html' title='Unit Testing (part 4) - Faking Entity Framework code first DbContext &amp;amp; DbSet'/><author><name>Jon</name><uri>http://www.blogger.com/profile/03999374060620875716</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtN6KAyfs2XT5axA13YSBK6vG1fODGqFwkd7i3EgUB0JjSkFLFVaAZ4pbpaS_vohqo9WxkqepTFpoOWWpFhX_ozDe4BOvA-JHUiJlQBcVNk713PsbLK_Hj96vnzr2hHx0/s113/Me2.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiVbWfZ-u8BzCn7BrkX1tLuPU5dW2a8qg_vsCxLOVvFMWWfEXRxGupJTlhrWOrWowyjnRWWf7ta7Xh1WCcuCWn6RpZQDvlSMAihOhMRI3_s9N7c4Anj8P4aVOVP-ql1fqTH1ZXGVgpKPeOL/s72-c?imgmax=800" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2990193854398450266.post-2406891161587981095</id><published>2015-08-30T12:52:00.001+00:00</published><updated>2015-08-30T12:56:07.762+00:00</updated><category scheme="http://www.blogger.com/atom/ns#" term=".RunSettings"/><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="Code Coverage"/><category scheme="http://www.blogger.com/atom/ns#" term="TFS"/><category scheme="http://www.blogger.com/atom/ns#" term="Unit Test"/><title type='text'>Unit Testing (part 3) – Running unit tests &amp;amp; code coverage</title><content type='html'>&lt;style&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;!--&lt;br /&gt; /* Font Definitions */&lt;br /&gt; @font-face&lt;br /&gt;	{font-family:wingdings;&lt;br /&gt;	panose-1:5 0 0 0 0 0 0 0 0 0;&lt;br /&gt;	mso-font-charset:2;&lt;br /&gt;	mso-generic-font-family:auto;&lt;br /&gt;	mso-font-pitch:variable;&lt;br /&gt;	mso-font-signature:0 268435456 0 0 -2147483648 0;}&lt;br /&gt;@font-face&lt;br /&gt;	{font-family:wingdings;&lt;br /&gt;	panose-1:5 0 0 0 0 0 0 0 0 0;&lt;br /&gt;	mso-font-charset:2;&lt;br /&gt;	mso-generic-font-family:auto;&lt;br /&gt;	mso-font-pitch:variable;&lt;br /&gt;	mso-font-signature:0 268435456 0 0 -2147483648 0;}&lt;br /&gt;@font-face&lt;br /&gt;	{font-family:calibri;&lt;br /&gt;	panose-1:2 15 5 2 2 2 4 3 2 4;&lt;br /&gt;	mso-font-charset:0;&lt;br /&gt;	mso-generic-font-family:swiss;&lt;br /&gt;	mso-font-pitch:variable;&lt;br /&gt;	mso-font-signature:-536870145 1073786111 1 0 415 0;}&lt;br /&gt;@font-face&lt;br /&gt;	{font-family:tahoma;&lt;br /&gt;	panose-1:2 11 6 4 3 5 4 4 2 4;&lt;br /&gt;	mso-font-charset:0;&lt;br /&gt;	mso-generic-font-family:swiss;&lt;br /&gt;	mso-font-pitch:variable;&lt;br /&gt;	mso-font-signature:-520081665 -1073717157 41 0 66047 0;}&lt;br /&gt;@font-face&lt;br /&gt;	{font-family:consolas;&lt;br /&gt;	panose-1:2 11 6 9 2 2 4 3 2 4;&lt;br /&gt;	mso-font-charset:0;&lt;br /&gt;	mso-generic-font-family:modern;&lt;br /&gt;	mso-font-pitch:fixed;&lt;br /&gt;	mso-font-signature:-520092929 1073806591 9 0 415 0;}&lt;br /&gt; /* Style Definitions */&lt;br /&gt; p.msonormal, li.msonormal, div.msonormal&lt;br /&gt;	{mso-style-unhide:no;&lt;br /&gt;	mso-style-qformat:yes;&lt;br /&gt;	mso-style-parent:&quot;&quot;;&lt;br /&gt;	margin-top:0cm;&lt;br /&gt;	margin-right:0cm;&lt;br /&gt;	margin-bottom:10.0pt;&lt;br /&gt;	margin-left:0cm;&lt;br /&gt;	line-height:115%;&lt;br /&gt;	mso-pagination:widow-orphan;&lt;br /&gt;	font-size:11.0pt;&lt;br /&gt;	font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;&lt;br /&gt;	mso-ascii-font-family:calibri;&lt;br /&gt;	mso-ascii-theme-font:minor-latin;&lt;br /&gt;	mso-fareast-font-family:calibri;&lt;br /&gt;	mso-fareast-theme-font:minor-latin;&lt;br /&gt;	mso-hansi-font-family:calibri;&lt;br /&gt;	mso-hansi-theme-font:minor-latin;&lt;br /&gt;	mso-bidi-font-family:&quot;Times New Roman&quot;;&lt;br /&gt;	mso-bidi-theme-font:minor-bidi;&lt;br /&gt;	mso-fareast-language:en-us;}&lt;br /&gt;p.msoacetate, li.msoacetate, div.msoacetate&lt;br /&gt;	{mso-style-noshow:yes;&lt;br /&gt;	mso-style-priority:99;&lt;br /&gt;	mso-style-link:&quot;Balloon Text Char&quot;;&lt;br /&gt;	margin:0cm;&lt;br /&gt;	margin-bottom:.0001pt;&lt;br /&gt;	mso-pagination:widow-orphan;&lt;br /&gt;	font-size:8.0pt;&lt;br /&gt;	font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;;&lt;br /&gt;	mso-fareast-font-family:calibri;&lt;br /&gt;	mso-fareast-theme-font:minor-latin;&lt;br /&gt;	mso-fareast-language:en-us;}&lt;br /&gt;p.msolistparagraph, li.msolistparagraph, div.msolistparagraph&lt;br /&gt;	{mso-style-priority:34;&lt;br /&gt;	mso-style-unhide:no;&lt;br /&gt;	mso-style-qformat:yes;&lt;br /&gt;	margin-top:0cm;&lt;br /&gt;	margin-right:0cm;&lt;br /&gt;	margin-bottom:10.0pt;&lt;br /&gt;	margin-left:36.0pt;&lt;br /&gt;	mso-add-space:auto;&lt;br /&gt;	line-height:115%;&lt;br /&gt;	mso-pagination:widow-orphan;&lt;br /&gt;	font-size:11.0pt;&lt;br /&gt;	font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;&lt;br /&gt;	mso-ascii-font-family:calibri;&lt;br /&gt;	mso-ascii-theme-font:minor-latin;&lt;br /&gt;	mso-fareast-font-family:calibri;&lt;br /&gt;	mso-fareast-theme-font:minor-latin;&lt;br /&gt;	mso-hansi-font-family:calibri;&lt;br /&gt;	mso-hansi-theme-font:minor-latin;&lt;br /&gt;	mso-bidi-font-family:&quot;Times New Roman&quot;;&lt;br /&gt;	mso-bidi-theme-font:minor-bidi;&lt;br /&gt;	mso-fareast-language:en-us;}&lt;br /&gt;p.msolistparagraphcxspfirst, li.msolistparagraphcxspfirst, div.msolistparagraphcxspfirst&lt;br /&gt;	{mso-style-priority:34;&lt;br /&gt;	mso-style-unhide:no;&lt;br /&gt;	mso-style-qformat:yes;&lt;br /&gt;	mso-style-type:export-only;&lt;br /&gt;	margin-top:0cm;&lt;br /&gt;	margin-right:0cm;&lt;br /&gt;	margin-bottom:0cm;&lt;br /&gt;	margin-left:36.0pt;&lt;br /&gt;	margin-bottom:.0001pt;&lt;br /&gt;	mso-add-space:auto;&lt;br /&gt;	line-height:115%;&lt;br /&gt;	mso-pagination:widow-orphan;&lt;br /&gt;	font-size:11.0pt;&lt;br /&gt;	font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;&lt;br /&gt;	mso-ascii-font-family:calibri;&lt;br /&gt;	mso-ascii-theme-font:minor-latin;&lt;br /&gt;	mso-fareast-font-family:calibri;&lt;br /&gt;	mso-fareast-theme-font:minor-latin;&lt;br /&gt;	mso-hansi-font-family:calibri;&lt;br /&gt;	mso-hansi-theme-font:minor-latin;&lt;br /&gt;	mso-bidi-font-family:&quot;Times New Roman&quot;;&lt;br /&gt;	mso-bidi-theme-font:minor-bidi;&lt;br /&gt;	mso-fareast-language:en-us;}&lt;br /&gt;p.msolistparagraphcxspmiddle, li.msolistparagraphcxspmiddle, div.msolistparagraphcxspmiddle&lt;br /&gt;	{mso-style-priority:34;&lt;br /&gt;	mso-style-unhide:no;&lt;br /&gt;	mso-style-qformat:yes;&lt;br /&gt;	mso-style-type:export-only;&lt;br /&gt;	margin-top:0cm;&lt;br /&gt;	margin-right:0cm;&lt;br /&gt;	margin-bottom:0cm;&lt;br /&gt;	margin-left:36.0pt;&lt;br /&gt;	margin-bottom:.0001pt;&lt;br /&gt;	mso-add-space:auto;&lt;br /&gt;	line-height:115%;&lt;br /&gt;	mso-pagination:widow-orphan;&lt;br /&gt;	font-size:11.0pt;&lt;br /&gt;	font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;&lt;br /&gt;	mso-ascii-font-family:calibri;&lt;br /&gt;	mso-ascii-theme-font:minor-latin;&lt;br /&gt;	mso-fareast-font-family:calibri;&lt;br /&gt;	mso-fareast-theme-font:minor-latin;&lt;br /&gt;	mso-hansi-font-family:calibri;&lt;br /&gt;	mso-hansi-theme-font:minor-latin;&lt;br /&gt;	mso-bidi-font-family:&quot;Times New Roman&quot;;&lt;br /&gt;	mso-bidi-theme-font:minor-bidi;&lt;br /&gt;	mso-fareast-language:en-us;}&lt;br /&gt;p.msolistparagraphcxsplast, li.msolistparagraphcxsplast, div.msolistparagraphcxsplast&lt;br /&gt;	{mso-style-priority:34;&lt;br /&gt;	mso-style-unhide:no;&lt;br /&gt;	mso-style-qformat:yes;&lt;br /&gt;	mso-style-type:export-only;&lt;br /&gt;	margin-top:0cm;&lt;br /&gt;	margin-right:0cm;&lt;br /&gt;	margin-bottom:10.0pt;&lt;br /&gt;	margin-left:36.0pt;&lt;br /&gt;	mso-add-space:auto;&lt;br /&gt;	line-height:115%;&lt;br /&gt;	mso-pagination:widow-orphan;&lt;br /&gt;	font-size:11.0pt;&lt;br /&gt;	font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;&lt;br /&gt;	mso-ascii-font-family:calibri;&lt;br /&gt;	mso-ascii-theme-font:minor-latin;&lt;br /&gt;	mso-fareast-font-family:calibri;&lt;br /&gt;	mso-fareast-theme-font:minor-latin;&lt;br /&gt;	mso-hansi-font-family:calibri;&lt;br /&gt;	mso-hansi-theme-font:minor-latin;&lt;br /&gt;	mso-bidi-font-family:&quot;Times New Roman&quot;;&lt;br /&gt;	mso-bidi-theme-font:minor-bidi;&lt;br /&gt;	mso-fareast-language:en-us;}&lt;br /&gt;span.balloontextchar&lt;br /&gt;	{mso-style-name:&quot;Balloon Text Char&quot;;&lt;br /&gt;	mso-style-noshow:yes;&lt;br /&gt;	mso-style-priority:99;&lt;br /&gt;	mso-style-unhide:no;&lt;br /&gt;	mso-style-locked:yes;&lt;br /&gt;	mso-style-link:&quot;Balloon Text&quot;;&lt;br /&gt;	mso-ansi-font-size:8.0pt;&lt;br /&gt;	mso-bidi-font-size:8.0pt;&lt;br /&gt;	font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;;&lt;br /&gt;	mso-ascii-font-family:tahoma;&lt;br /&gt;	mso-hansi-font-family:tahoma;&lt;br /&gt;	mso-bidi-font-family:tahoma;}&lt;br /&gt;span.spelle&lt;br /&gt;	{mso-style-name:&quot;&quot;;&lt;br /&gt;	mso-spl-e:yes;}&lt;br /&gt;span.grame&lt;br /&gt;	{mso-style-name:&quot;&quot;;&lt;br /&gt;	mso-gram-e:yes;}&lt;br /&gt;.msochpdefault&lt;br /&gt;	{mso-style-type:export-only;&lt;br /&gt;	mso-default-props:yes;&lt;br /&gt;	font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;&lt;br /&gt;	mso-ascii-font-family:calibri;&lt;br /&gt;	mso-ascii-theme-font:minor-latin;&lt;br /&gt;	mso-fareast-font-family:calibri;&lt;br /&gt;	mso-fareast-theme-font:minor-latin;&lt;br /&gt;	mso-hansi-font-family:calibri;&lt;br /&gt;	mso-hansi-theme-font:minor-latin;&lt;br /&gt;	mso-bidi-font-family:&quot;Times New Roman&quot;;&lt;br /&gt;	mso-bidi-theme-font:minor-bidi;&lt;br /&gt;	mso-fareast-language:en-us;}&lt;br /&gt;.msopapdefault&lt;br /&gt;	{mso-style-type:export-only;&lt;br /&gt;	margin-bottom:10.0pt;&lt;br /&gt;	line-height:115%;}&lt;br /&gt;@page wordsection1&lt;br /&gt;	{size:595.3pt 841.9pt;&lt;br /&gt;	margin:72.0pt 72.0pt 72.0pt 72.0pt;&lt;br /&gt;	mso-header-margin:35.4pt;&lt;br /&gt;	mso-footer-margin:35.4pt;&lt;br /&gt;	mso-paper-source:0;}&lt;br /&gt;div.wordsection1&lt;br /&gt;	{page:wordsection1;}&lt;br /&gt; /* List Definitions */&lt;br /&gt; @list l0&lt;br /&gt;	{mso-list-id:487749498;&lt;br /&gt;	mso-list-type:hybrid;&lt;br /&gt;	mso-list-template-ids:-792971818 134807553 134807555 134807557 134807553 134807555 134807557 134807553 134807555 134807557;}&lt;br /&gt;@list l0:level1&lt;br /&gt;	{mso-level-number-format:bullet;&lt;br /&gt;	mso-level-text:\f0b7;&lt;br /&gt;	mso-level-tab-stop:none;&lt;br /&gt;	mso-level-number-position:left;&lt;br /&gt;	text-indent:-18.0pt;&lt;br /&gt;	font-family:symbol;}&lt;br /&gt;@list l0:level2&lt;br /&gt;	{mso-level-number-format:bullet;&lt;br /&gt;	mso-level-text:o;&lt;br /&gt;	mso-level-tab-stop:none;&lt;br /&gt;	mso-level-number-position:left;&lt;br /&gt;	text-indent:-18.0pt;&lt;br /&gt;	font-family:&quot;Courier New&quot;;}&lt;br /&gt;@list l0:level3&lt;br /&gt;	{mso-level-number-format:bullet;&lt;br /&gt;	mso-level-text:\f0a7;&lt;br /&gt;	mso-level-tab-stop:none;&lt;br /&gt;	mso-level-number-position:left;&lt;br /&gt;	text-indent:-18.0pt;&lt;br /&gt;	font-family:wingdings;}&lt;br /&gt;@list l0:level4&lt;br /&gt;	{mso-level-number-format:bullet;&lt;br /&gt;	mso-level-text:\f0b7;&lt;br /&gt;	mso-level-tab-stop:none;&lt;br /&gt;	mso-level-number-position:left;&lt;br /&gt;	text-indent:-18.0pt;&lt;br /&gt;	font-family:symbol;}&lt;br /&gt;@list l0:level5&lt;br /&gt;	{mso-level-number-format:bullet;&lt;br /&gt;	mso-level-text:o;&lt;br /&gt;	mso-level-tab-stop:none;&lt;br /&gt;	mso-level-number-position:left;&lt;br /&gt;	text-indent:-18.0pt;&lt;br /&gt;	font-family:&quot;Courier New&quot;;}&lt;br /&gt;@list l0:level6&lt;br /&gt;	{mso-level-number-format:bullet;&lt;br /&gt;	mso-level-text:\f0a7;&lt;br /&gt;	mso-level-tab-stop:none;&lt;br /&gt;	mso-level-number-position:left;&lt;br /&gt;	text-indent:-18.0pt;&lt;br /&gt;	font-family:wingdings;}&lt;br /&gt;@list l0:level7&lt;br /&gt;	{mso-level-number-format:bullet;&lt;br /&gt;	mso-level-text:\f0b7;&lt;br /&gt;	mso-level-tab-stop:none;&lt;br /&gt;	mso-level-number-position:left;&lt;br /&gt;	text-indent:-18.0pt;&lt;br /&gt;	font-family:symbol;}&lt;br /&gt;@list l0:level8&lt;br /&gt;	{mso-level-number-format:bullet;&lt;br /&gt;	mso-level-text:o;&lt;br /&gt;	mso-level-tab-stop:none;&lt;br /&gt;	mso-level-number-position:left;&lt;br /&gt;	text-indent:-18.0pt;&lt;br /&gt;	font-family:&quot;Courier New&quot;;}&lt;br /&gt;@list l0:level9&lt;br /&gt;	{mso-level-number-format:bullet;&lt;br /&gt;	mso-level-text:\f0a7;&lt;br /&gt;	mso-level-tab-stop:none;&lt;br /&gt;	mso-level-number-position:left;&lt;br /&gt;	text-indent:-18.0pt;&lt;br /&gt;	font-family:wingdings;}&lt;br /&gt;@list l1&lt;br /&gt;	{mso-list-id:633801148;&lt;br /&gt;	mso-list-type:hybrid;&lt;br /&gt;	mso-list-template-ids:1677916706 134807553 134807555 134807557 134807553 134807555 134807557 134807553 134807555 134807557;}&lt;br /&gt;@list l1:level1&lt;br /&gt;	{mso-level-number-format:bullet;&lt;br /&gt;	mso-level-text:\f0b7;&lt;br /&gt;	mso-level-tab-stop:none;&lt;br /&gt;	mso-level-number-position:left;&lt;br /&gt;	text-indent:-18.0pt;&lt;br /&gt;	font-family:symbol;}&lt;br /&gt;@list l1:level2&lt;br /&gt;	{mso-level-number-format:bullet;&lt;br /&gt;	mso-level-text:o;&lt;br /&gt;	mso-level-tab-stop:none;&lt;br /&gt;	mso-level-number-position:left;&lt;br /&gt;	text-indent:-18.0pt;&lt;br /&gt;	font-family:&quot;Courier New&quot;;}&lt;br /&gt;@list l1:level3&lt;br /&gt;	{mso-level-number-format:bullet;&lt;br /&gt;	mso-level-text:\f0a7;&lt;br /&gt;	mso-level-tab-stop:none;&lt;br /&gt;	mso-level-number-position:left;&lt;br /&gt;	text-indent:-18.0pt;&lt;br /&gt;	font-family:wingdings;}&lt;br /&gt;@list l1:level4&lt;br /&gt;	{mso-level-number-format:bullet;&lt;br /&gt;	mso-level-text:\f0b7;&lt;br /&gt;	mso-level-tab-stop:none;&lt;br /&gt;	mso-level-number-position:left;&lt;br /&gt;	text-indent:-18.0pt;&lt;br /&gt;	font-family:symbol;}&lt;br /&gt;@list l1:level5&lt;br /&gt;	{mso-level-number-format:bullet;&lt;br /&gt;	mso-level-text:o;&lt;br /&gt;	mso-level-tab-stop:none;&lt;br /&gt;	mso-level-number-position:left;&lt;br /&gt;	text-indent:-18.0pt;&lt;br /&gt;	font-family:&quot;Courier New&quot;;}&lt;br /&gt;@list l1:level6&lt;br /&gt;	{mso-level-number-format:bullet;&lt;br /&gt;	mso-level-text:\f0a7;&lt;br /&gt;	mso-level-tab-stop:none;&lt;br /&gt;	mso-level-number-position:left;&lt;br /&gt;	text-indent:-18.0pt;&lt;br /&gt;	font-family:wingdings;}&lt;br /&gt;@list l1:level7&lt;br /&gt;	{mso-level-number-format:bullet;&lt;br /&gt;	mso-level-text:\f0b7;&lt;br /&gt;	mso-level-tab-stop:none;&lt;br /&gt;	mso-level-number-position:left;&lt;br /&gt;	text-indent:-18.0pt;&lt;br /&gt;	font-family:symbol;}&lt;br /&gt;@list l1:level8&lt;br /&gt;	{mso-level-number-format:bullet;&lt;br /&gt;	mso-level-text:o;&lt;br /&gt;	mso-level-tab-stop:none;&lt;br /&gt;	mso-level-number-position:left;&lt;br /&gt;	text-indent:-18.0pt;&lt;br /&gt;	font-family:&quot;Courier New&quot;;}&lt;br /&gt;@list l1:level9&lt;br /&gt;	{mso-level-number-format:bullet;&lt;br /&gt;	mso-level-text:\f0a7;&lt;br /&gt;	mso-level-tab-stop:none;&lt;br /&gt;	mso-level-number-position:left;&lt;br /&gt;	text-indent:-18.0pt;&lt;br /&gt;	font-family:wingdings;}&lt;br /&gt;ol&lt;br /&gt;	{margin-bottom:0cm;}&lt;br /&gt;ul&lt;br /&gt;	{margin-bottom:0cm;}&lt;br /&gt;--&gt;&lt;/style&gt;  &lt;div class=&quot;WordSection1&quot;&gt;   &lt;p class=&quot;MsoNormal&quot;&gt;     &lt;br /&gt;This is the 3&lt;sup&gt;rd&lt;/sup&gt; in a series of posts about unit testing:&lt;b style=&quot;mso-bidi-font-weight: normal&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 36pt&quot;&gt;&lt;b style=&quot;mso-bidi-font-weight: normal&quot;&gt;&lt;a href=&quot;http://jonlanceley.blogspot.co.uk/2015/08/unit-testing-part-1-without-using.html&quot; target=&quot;_blank&quot;&gt;Unit Testing (part 1) - Without using a mocking framework&lt;/a&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 36pt&quot;&gt;&lt;b style=&quot;mso-bidi-font-weight: normal&quot;&gt;&lt;a href=&quot;http://jonlanceley.blogspot.co.uk/2015/08/unit-testing-part-2-faking-httpcontext.html&quot; target=&quot;_blank&quot;&gt;Unit Testing (part 2) - Faking the HttpContext and HttpContextBase&lt;/a&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 36pt&quot;&gt;&lt;b style=&quot;mso-bidi-font-weight: normal&quot;&gt;Unit Testing (part 3) - Running Unit Tests &amp;amp; Code Coverage&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 36pt&quot;&gt;&lt;b style=&quot;mso-bidi-font-weight: normal&quot;&gt;&lt;a href=&quot;http://jonlanceley.blogspot.co.uk/2015/08/unit-testing-part-4-faking-entity.html&quot; target=&quot;_blank&quot;&gt;Unit Testing (part 4) - Faking Entity Framework code first DbContext &amp;amp; DbSet&lt;/a&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;o:p&gt;&amp;#160;&lt;/o:p&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;The new way of running unit tests from within Visual Studio or as part of a TFS build is by making use of the &lt;span class=&quot;SpellE&quot;&gt;TestSettings.&lt;span style=&quot;background: yellow; mso-highlight: yellow&quot;&gt;RunSettings&lt;/span&gt;&lt;/span&gt; file (the old file was &lt;span class=&quot;SpellE&quot;&gt;TestSettings.&lt;span style=&quot;background: yellow; mso-highlight: yellow&quot;&gt;TestSettings&lt;/span&gt;&lt;/span&gt;).&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;This is the &lt;span class=&quot;SpellE&quot;&gt;TestSettings.RunSettings&lt;/span&gt; file from Microsoft with our exclusions added to it in yellow.&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;What this does is when the code coverage tool is run it excludes certain code from that process such as the code first migrations files or 3&lt;sup&gt;rd&lt;/sup&gt; party DLL’s (as we cannot unit test them) so we need to exclude them otherwise our code coverage stats will never reach or get close to 100%!.&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;o:p&gt;&amp;#160;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;lt;?&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;xml&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: red; mso-highlight: white&quot;&gt;version&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;1.0&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: red; mso-highlight: white&quot;&gt;encoding&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;utf-8&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;lt;!--&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white&quot;&gt; File name extension must be .&lt;span class=&quot;SpellE&quot;&gt;runsettings&lt;/span&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;--&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;RunSettings&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;DataCollectionRunSettings&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;DataCollectors&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;DataCollector&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: red; mso-highlight: white&quot;&gt;friendlyName&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;Code Coverage&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: red; mso-highlight: white&quot;&gt;uri&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;datacollector&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;://Microsoft/&lt;span class=&quot;SpellE&quot;&gt;CodeCoverage&lt;/span&gt;/2.0&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: red; mso-highlight: white&quot;&gt;assemblyQualifiedName&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;Microsoft.VisualStudio.Coverage.DynamicCoverageDataCollector, &lt;span class=&quot;SpellE&quot;&gt;Microsoft.VisualStudio.TraceCollector&lt;/span&gt;, Version=11.0.0.0, Culture=neutral, &lt;span class=&quot;SpellE&quot;&gt;PublicKeyToken&lt;/span&gt;=b03f5f7f11d50a3a&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;Configuration&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;CodeCoverage&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;lt;!--&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white&quot;&gt;Additional paths to search for .&lt;span class=&quot;SpellE&quot;&gt;pdb&lt;/span&gt; (symbol) files. Symbols must be found for modules to be instrumented.&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white&quot;&gt;If .&lt;span class=&quot;SpellE&quot;&gt;pdb&lt;/span&gt; files are in the same folder as the .&lt;span class=&quot;SpellE&quot;&gt;dll&lt;/span&gt; or .exe files, they are automatically found. Otherwise, specify them here.&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white&quot;&gt;Note that searching for symbols increases code coverage runtime. So keep this small and local.&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;--&amp;gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;lt;!--&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&amp;lt;&lt;span class=&quot;SpellE&quot;&gt;SymbolSearchPaths&lt;/span&gt;&amp;gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;&amp;lt;Path&amp;gt;C:\Users\User\Documents\Visual Studio 2012\Projects\&lt;span class=&quot;SpellE&quot;&gt;ProjectX&lt;/span&gt;\bin\Debug&amp;lt;/Path&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;&amp;lt;Path&amp;gt;\\mybuildshare\builds\ProjectX&amp;lt;/Path&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&amp;lt;/&lt;span class=&quot;SpellE&quot;&gt;SymbolSearchPaths&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;--&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;lt;!--&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white&quot;&gt;About include/exclude lists:&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white&quot;&gt;Empty &amp;quot;Include&amp;quot; clauses imply all; empty &amp;quot;Exclude&amp;quot; clauses imply none.&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white&quot;&gt;Each element in the list is a regular expression (ECMAScript syntax). See http://msdn.microsoft.com/library/2k3te2cs.aspx.&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white&quot;&gt;An item must first match at least one entry in the include list to be included.&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white&quot;&gt;Included items must then not match any entries in the exclude list to remain included.&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;--&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span class=&quot;GramE&quot;&gt;&amp;lt;!--&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white&quot;&gt; Match assembly file paths: &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;--&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;ModulePaths&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;Include&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;ModulePath&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;.*\.&lt;span class=&quot;SpellE&quot;&gt;dll&lt;/span&gt;$&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;ModulePath&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;ModulePath&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;.*\.exe$&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;ModulePath&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;Include&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;Exclude&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;ModulePath&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;.*&lt;span class=&quot;SpellE&quot;&gt;CPPUnitTestFramework&lt;/span&gt;.*&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;ModulePath&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: blue; mso-highlight: yellow&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: #a31515; mso-highlight: yellow&quot;&gt;ModulePath&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: blue; mso-highlight: yellow&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: black; mso-highlight: yellow&quot;&gt;.*&lt;span class=&quot;SpellE&quot;&gt;stackexchange&lt;/span&gt;.*&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: blue; mso-highlight: yellow&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: #a31515; mso-highlight: yellow&quot;&gt;ModulePath&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: blue; mso-highlight: yellow&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: black; mso-highlight: yellow&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;ModulePath&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;.*antlr3.*&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;ModulePath&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;ModulePath&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;.*&lt;span class=&quot;SpellE&quot;&gt;microsoft.practices&lt;/span&gt;.*&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;ModulePath&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;Exclude&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;ModulePaths&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&amp;#160;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span class=&quot;GramE&quot;&gt;&amp;lt;!--&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white&quot;&gt; Match fully qualified names of functions: &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;--&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span class=&quot;GramE&quot;&gt;&amp;lt;!--&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white&quot;&gt; (Use &amp;quot;\.&amp;quot; to delimit namespaces in C# or Visual Basic, &amp;quot;::&amp;quot; in C++.)&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;--&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;Functions&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;Exclude&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;Function&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;^&lt;span class=&quot;SpellE&quot;&gt;Fabrikam&lt;/span&gt;\.&lt;span class=&quot;SpellE&quot;&gt;UnitTest&lt;/span&gt;\&lt;span class=&quot;GramE&quot;&gt;..&lt;/span&gt;*&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;Function&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;Function&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;^&lt;span class=&quot;GramE&quot;&gt;std:&lt;/span&gt;:.*&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;Function&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;Function&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;^&lt;span class=&quot;GramE&quot;&gt;ATL:&lt;/span&gt;:.*&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;Function&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;Function&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;.*::__&lt;span class=&quot;SpellE&quot;&gt;GetTestMethodInfo&lt;/span&gt;.*&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;Function&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;Function&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;^Microsoft:&lt;span class=&quot;GramE&quot;&gt;:VisualStudio&lt;/span&gt;::CppCodeCoverageFramework::.*&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;Function&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;Function&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;^Microsoft:&lt;span class=&quot;GramE&quot;&gt;:VisualStudio&lt;/span&gt;::CppUnitTestFramework::.*&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;Function&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: blue; mso-highlight: yellow&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: #a31515; mso-highlight: yellow&quot;&gt;Function&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: blue; mso-highlight: yellow&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: black; mso-highlight: yellow&quot;&gt;^&lt;span class=&quot;SpellE&quot;&gt;SiteDataAccess&lt;/span&gt;\.Core\.Migrations\&lt;span class=&quot;GramE&quot;&gt;..&lt;/span&gt;*&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: blue; mso-highlight: yellow&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: #a31515; mso-highlight: yellow&quot;&gt;Function&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: blue; mso-highlight: yellow&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;Exclude&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;Functions&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&amp;#160;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span class=&quot;GramE&quot;&gt;&amp;lt;!--&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white&quot;&gt; Match attributes on any code element: &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;--&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;Attributes&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;Exclude&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;&amp;lt;!--&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white&quot;&gt;Don&#39;t forget &amp;quot;Attribute&amp;quot; at the end of the name &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;--&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;Attribute&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;^System.Diagnostics.DebuggerHiddenAttribute$&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;Attribute&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;Attribute&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;^System.Diagnostics.DebuggerNonUserCodeAttribute$&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;Attribute&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;Attribute&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;^System.Runtime.CompilerServices.CompilerGeneratedAttribute$&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;Attribute&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;Attribute&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;^System.CodeDom.Compiler.GeneratedCodeAttribute$&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;Attribute&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;Attribute&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;^System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute$&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;Attribute&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;Exclude&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;Attributes&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&amp;#160;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span class=&quot;GramE&quot;&gt;&amp;lt;!--&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white&quot;&gt; Match the path of the source files in which each method is defined: &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;--&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span lang=&quot;FR&quot; style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white; mso-ansi-language: fr&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span lang=&quot;FR&quot; style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white; mso-ansi-language: fr&quot;&gt;Sources&lt;/span&gt;&lt;span lang=&quot;FR&quot; style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white; mso-ansi-language: fr&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span lang=&quot;FR&quot; style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white; mso-ansi-language: fr&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span lang=&quot;FR&quot; style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white; mso-ansi-language: fr&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span lang=&quot;FR&quot; style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white; mso-ansi-language: fr&quot;&gt;Exclude&lt;/span&gt;&lt;/span&gt;&lt;span lang=&quot;FR&quot; style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white; mso-ansi-language: fr&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span lang=&quot;FR&quot; style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white; mso-ansi-language: fr&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span lang=&quot;FR&quot; style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white; mso-ansi-language: fr&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;&amp;lt;&lt;/span&gt;&lt;span lang=&quot;FR&quot; style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white; mso-ansi-language: fr&quot;&gt;Source&lt;/span&gt;&lt;span lang=&quot;FR&quot; style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white; mso-ansi-language: fr&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span lang=&quot;FR&quot; style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white; mso-ansi-language: fr&quot;&gt;.*\\atlmfc\\.*&lt;/span&gt;&lt;span lang=&quot;FR&quot; style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white; mso-ansi-language: fr&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span lang=&quot;FR&quot; style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white; mso-ansi-language: fr&quot;&gt;Source&lt;/span&gt;&lt;span lang=&quot;FR&quot; style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white; mso-ansi-language: fr&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span lang=&quot;FR&quot; style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white; mso-ansi-language: fr&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span lang=&quot;FR&quot; style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white; mso-ansi-language: fr&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;&amp;lt;&lt;/span&gt;&lt;span lang=&quot;FR&quot; style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white; mso-ansi-language: fr&quot;&gt;Source&lt;/span&gt;&lt;span lang=&quot;FR&quot; style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white; mso-ansi-language: fr&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span lang=&quot;FR&quot; style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white; mso-ansi-language: fr&quot;&gt;.*\\vctools\\.*&lt;/span&gt;&lt;span lang=&quot;FR&quot; style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white; mso-ansi-language: fr&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span lang=&quot;FR&quot; style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white; mso-ansi-language: fr&quot;&gt;Source&lt;/span&gt;&lt;span lang=&quot;FR&quot; style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white; mso-ansi-language: fr&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span lang=&quot;FR&quot; style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white; mso-ansi-language: fr&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span lang=&quot;FR&quot; style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white; mso-ansi-language: fr&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;&amp;lt;&lt;/span&gt;&lt;span lang=&quot;FR&quot; style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white; mso-ansi-language: fr&quot;&gt;Source&lt;/span&gt;&lt;span lang=&quot;FR&quot; style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white; mso-ansi-language: fr&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span lang=&quot;FR&quot; style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white; mso-ansi-language: fr&quot;&gt;.*\\public\\&lt;span class=&quot;SpellE&quot;&gt;sdk&lt;/span&gt;\\.*&lt;/span&gt;&lt;span lang=&quot;FR&quot; style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white; mso-ansi-language: fr&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span lang=&quot;FR&quot; style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white; mso-ansi-language: fr&quot;&gt;Source&lt;/span&gt;&lt;span lang=&quot;FR&quot; style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white; mso-ansi-language: fr&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span lang=&quot;FR&quot; style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white; mso-ansi-language: fr&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span lang=&quot;FR&quot; style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white; mso-ansi-language: fr&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;&amp;lt;&lt;/span&gt;&lt;span lang=&quot;FR&quot; style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white; mso-ansi-language: fr&quot;&gt;Source&lt;/span&gt;&lt;span lang=&quot;FR&quot; style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white; mso-ansi-language: fr&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span lang=&quot;FR&quot; style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white; mso-ansi-language: fr&quot;&gt;.*\\&lt;span class=&quot;SpellE&quot;&gt;microsoft&lt;/span&gt; &lt;span class=&quot;SpellE&quot;&gt;sdks&lt;/span&gt;\\.*&lt;/span&gt;&lt;span lang=&quot;FR&quot; style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white; mso-ansi-language: fr&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span lang=&quot;FR&quot; style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white; mso-ansi-language: fr&quot;&gt;Source&lt;/span&gt;&lt;span lang=&quot;FR&quot; style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white; mso-ansi-language: fr&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span lang=&quot;FR&quot; style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white; mso-ansi-language: fr&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span lang=&quot;FR&quot; style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white; mso-ansi-language: fr&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;&amp;lt;&lt;/span&gt;&lt;span lang=&quot;FR&quot; style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white; mso-ansi-language: fr&quot;&gt;Source&lt;/span&gt;&lt;span lang=&quot;FR&quot; style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white; mso-ansi-language: fr&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span lang=&quot;FR&quot; style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white; mso-ansi-language: fr&quot;&gt;.*\\&lt;span class=&quot;SpellE&quot;&gt;vc&lt;/span&gt;\\&lt;span class=&quot;SpellE&quot;&gt;include&lt;/span&gt;\\.*&lt;/span&gt;&lt;span lang=&quot;FR&quot; style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white; mso-ansi-language: fr&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span lang=&quot;FR&quot; style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white; mso-ansi-language: fr&quot;&gt;Source&lt;/span&gt;&lt;span lang=&quot;FR&quot; style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white; mso-ansi-language: fr&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span lang=&quot;FR&quot; style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white; mso-ansi-language: fr&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span lang=&quot;FR&quot; style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white; mso-ansi-language: fr&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span lang=&quot;FR&quot; style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white; mso-ansi-language: fr&quot;&gt;Exclude&lt;/span&gt;&lt;/span&gt;&lt;span lang=&quot;FR&quot; style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white; mso-ansi-language: fr&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span lang=&quot;FR&quot; style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white; mso-ansi-language: fr&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span lang=&quot;FR&quot; style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white; mso-ansi-language: fr&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span lang=&quot;FR&quot; style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white; mso-ansi-language: fr&quot;&gt;Sources&lt;/span&gt;&lt;span lang=&quot;FR&quot; style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white; mso-ansi-language: fr&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span lang=&quot;FR&quot; style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white; mso-ansi-language: fr&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span lang=&quot;FR&quot; style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white; mso-ansi-language: fr&quot;&gt;&lt;o:p&gt;&amp;#160;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span lang=&quot;FR&quot; style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white; mso-ansi-language: fr&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;lt;!--&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white&quot;&gt; Match the company name property in the assembly: &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;--&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;CompanyNames&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;Exclude&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;CompanyName&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;.*&lt;span class=&quot;SpellE&quot;&gt;microsoft&lt;/span&gt;.*&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;CompanyName&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;Exclude&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;CompanyNames&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&amp;#160;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span class=&quot;GramE&quot;&gt;&amp;lt;!--&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white&quot;&gt; Match the public key token of a signed assembly: &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;--&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;PublicKeyTokens&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span class=&quot;GramE&quot;&gt;&amp;lt;!--&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white&quot;&gt; Exclude Visual Studio extensions: &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;--&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;Exclude&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;PublicKeyToken&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;^B77A5C561934E089$&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;PublicKeyToken&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;PublicKeyToken&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;^B03F5F7F11D50A3A$&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;PublicKeyToken&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;PublicKeyToken&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;^31BF3856AD364E35$&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;PublicKeyToken&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;PublicKeyToken&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;^89845DCD8080CC91$&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;PublicKeyToken&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;PublicKeyToken&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;^71E9BCE111E9429C$&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;PublicKeyToken&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;PublicKeyToken&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;^8F50407C4E9E73B6$&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;PublicKeyToken&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;PublicKeyToken&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;^E361AF139669C375$&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;PublicKeyToken&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;Exclude&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;PublicKeyTokens&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&amp;#160;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span class=&quot;GramE&quot;&gt;&amp;lt;!--&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white&quot;&gt; We recommend you do not change the following values: &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;--&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;UseVerifiableInstrumentation&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;True&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;UseVerifiableInstrumentation&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;AllowLowIntegrityProcesses&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;True&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;AllowLowIntegrityProcesses&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;CollectFromChildProcesses&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;True&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;CollectFromChildProcesses&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;CollectAspDotNet&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;False&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;CollectAspDotNet&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;CodeCoverage&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;Configuration&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;DataCollector&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;DataCollectors&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160; &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;DataCollectionRunSettings&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; line-height: 115%; mso-highlight: white&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; line-height: 115%; mso-highlight: white&quot;&gt;RunSettings&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; line-height: 115%; mso-highlight: white&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;o:p&gt;&amp;#160;&lt;/o:p&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;Save this file and then in Visual Studio go to Test -&amp;gt; Test Settings and select this .&lt;span class=&quot;SpellE&quot;&gt;RunSettings&lt;/span&gt; file.&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160; &lt;/span&gt;And then run the tests.&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;If you have Visual Studio Enterprise you can automatically run the tests on every build by clicking this icon&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;text-align: center&quot; align=&quot;center&quot;&gt;&lt;span style=&quot;mso-fareast-language: en-gb; mso-no-proof: yes&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjs-C7_rHItoq9IGM8EHGpIh_MHboUfh8QgmSjRFGabnaSkicORVlxocS2m6FuLZ638Z7BT2c2it70r4yb10Kn-waNaGORyPIqSjl_FzSjp_MvoeHUiwMuXHrLOstuTVvVsqzu1PvPEnHXN/s1600-h/image2.png&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px; border-top-width: 0px&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhO4FVxt14ozR9i8mcmvEb0AMsUBQbDvUJoaWREDUmMcf-AbbcBnzw04Ip_rhXmfzruuD66OCggeLlbYiHtJR-gNHDelhIGYMnzLQQh5MmTSgK8DMaJw3Saxq33iP8sbpDOnPsYHlSM2wmQ/?imgmax=800&quot; width=&quot;144&quot; height=&quot;84&quot; /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: red&quot;&gt;We should be running the unit tests frequently and before we merge our code to the main branch.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;To use Code Coverage (again an Enterprise thing) Right click in test explorer and choose ‘Analyze Code Coverage for Selected Tests’.&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;text-align: center&quot; align=&quot;center&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzbM_Old62LtFN-b0yVlrRz6SCRue1lZakeMGAMroflRgCpNL_g0bOLtlXSmDqNcXiSXyyQvKfp4OeZ7OD400LGTzfHodnZyRV_wDHTELymJApQMGSPDaaOuk2I6QVYhvDJipKth-BBHnF/s1600-h/image5.png&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px; border-top-width: 0px&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiUqf44JMyKas31PDK7azMbnJYjqMDbu88QoZ2a0sA3Z0qUgRqhdqTDrhBntw4glXFnjELDh4HcS9hvKXTU-QaFb9tBMeJBQiq6MYOt2v1QBy3XKVwqnW5XTODyiFwhbbg0BshDUmT0aZeN/?imgmax=800&quot; width=&quot;244&quot; height=&quot;162&quot; /&gt;&lt;/a&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;All the tests will then be run and the ‘Code Coverage Results’ window will appear.&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh34WFobc2TPtLHIt6x8-dUop185pCj4prjsSDrDOxnSuchW73QFPOS3n2Qs0yRQYL7eSSbjrCd82kOwZ_P_2KbCwd70sBcW3O7sqRPSLTnQdbbXWIPSpAWb74hz26p-hADg-igszhGiUbe/s1600-h/image10.png&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; float: none; padding-top: 0px; padding-left: 0px; margin-left: auto; display: block; padding-right: 0px; border-top-width: 0px; margin-right: auto&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhE9nwYIe-EwjmY1_wyWrCBQIQsl4mxLMnKqhuQE0IOR7FkuVu7XpFWNsnbhkwk4uBy5gykBqJjQpLi9JP7yJt2Ji4VxrNxcwrjI5NiocIz5J3ZMjcFfMmxRBKRmvbJh-x5l0LwpJQUJ-0a/?imgmax=800&quot; width=&quot;689&quot; height=&quot;117&quot; /&gt;&lt;/a&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;Clicking the icon circled above will show all your code highlighted so at a glance as you navigate your code you can see what is covered by the unit tests.&lt;/p&gt;    &lt;p class=&quot;MsoListParagraphCxSpFirst&quot; style=&quot;text-indent: -18pt; mso-list: l0 level1 lfo2&quot;&gt;&lt;span style=&quot;font-family: symbol; mso-fareast-font-family: symbol; mso-bidi-font-family: symbol&quot;&gt;&lt;span style=&quot;mso-list: ignore&quot;&gt;·&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Blue = Unit tests are testing it&lt;/p&gt;    &lt;p class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;text-indent: -18pt; mso-list: l0 level1 lfo2&quot;&gt;&lt;span style=&quot;font-family: symbol; mso-fareast-font-family: symbol; mso-bidi-font-family: symbol&quot;&gt;&lt;span style=&quot;mso-list: ignore&quot;&gt;·&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Red = No tests are testing this code yet!&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;text-align: center&quot; align=&quot;center&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCfGTRZTsKsYRuIw1pM1pdCTjmss_hNw4b7HraKhw59ta04EisOEhOLs3aRPeIqvT651TNleWbLeCV_8oGnSWs3Q8mwTNpx-yuUvGJVsMtDDf2fO9GMPqAVu6XsI5SJ2REIAiqnbgz-oqF/s1600-h/image14.png&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEijR84fx4KCOFMTV7wZ_b-wS2egEISLOCXgCLNPLAU83wLG0cmKrwGm4mfFDVf1o7Np8lBbiBaQgKmfF15dtBe0g6H69b7oxUglo_xofTCfmft87g2Ni4J7iO9sbu3DXwXgUybOg43MBwE0/?imgmax=800&quot; width=&quot;502&quot; height=&quot;384&quot; /&gt;&lt;/a&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: red&quot;&gt;We should be running code Analysis before we merge to main to ensure our code is being tested.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt&quot;&gt;&lt;o:p&gt;&amp;#160;&lt;/o:p&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;Using the same .&lt;span class=&quot;SpellE&quot;&gt;RunSettings&lt;/span&gt; file on a TFS build shows this:&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbu5LvLNMyncUleVy_TPR0dibG_4IK58DGd7WNP3OdRx0mdrPlUY0ph79wZ-9pO-QOU3jC6wShe8Y05FP50GniKIvzAxO2b5ZXwdrOHKSIYNhNJZ2d9-nxZ4iKdvnxsxdFIrnTa6hZ-sKv/s1600-h/image18.png&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; float: none; padding-top: 0px; padding-left: 0px; margin-left: auto; display: block; padding-right: 0px; border-top-width: 0px; margin-right: auto&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEivko5ITlGzJV3xypZbwI3ygmvj46SwUdS6Sh5BiQezPq651xEnDp9Kw9ubKZWEHnV7vLqVdl_ivCWXmptd5fOgqk3lzEkr9nRDtmeKE-m9QCZhZ6pTM_KCbhvAE1F__gqZZhOIOY3UQwXb/?imgmax=800&quot; width=&quot;538&quot; height=&quot;71&quot; /&gt;&lt;/a&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt&quot;&gt;And in the TFS Build Summary report:&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5rFKVIseNkXa5rYCT5TLVedtsEgH_Z9XI4KiJcb0uuVTfJAy9uop5hsCKRw3WXydIl4AldWlwhJGBQGoIA2K0Ojeqe3dH26Vwxk9rxCz9vLPrHCzuKugHSL8LqwP2yYb4dVKrQHYR1X5U/s1600-h/image23.png&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; float: none; padding-top: 0px; padding-left: 0px; margin-left: auto; display: block; padding-right: 0px; border-top-width: 0px; margin-right: auto&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhn_9nYQ0aUNJtmDORDRlRBECNKKe3hPk9flGuMI8SZtrFzTr-oZY7LV2M0nt1wk39Evx1x0iNzgIUUjlP0el5Dq84zXjHxTCGsqvNlkCtECozTPYSgHdsgllS8gDvf5lsMJQl4Mjdg-KvJ/?imgmax=800&quot; width=&quot;496&quot; height=&quot;131&quot; /&gt;&lt;/a&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 9pt; line-height: 115%&quot;&gt;(Note: I only have code coverage and unit tests’ running on main branch merges.)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;/div&gt;  </content><link rel='replies' type='application/atom+xml' href='http://jonlanceley.blogspot.com/feeds/2406891161587981095/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jonlanceley.blogspot.com/2015/08/unit-testing-part-3-running-unit-tests.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2990193854398450266/posts/default/2406891161587981095'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2990193854398450266/posts/default/2406891161587981095'/><link rel='alternate' type='text/html' href='http://jonlanceley.blogspot.com/2015/08/unit-testing-part-3-running-unit-tests.html' title='Unit Testing (part 3) – Running unit tests &amp;amp; code coverage'/><author><name>Jon</name><uri>http://www.blogger.com/profile/03999374060620875716</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtN6KAyfs2XT5axA13YSBK6vG1fODGqFwkd7i3EgUB0JjSkFLFVaAZ4pbpaS_vohqo9WxkqepTFpoOWWpFhX_ozDe4BOvA-JHUiJlQBcVNk713PsbLK_Hj96vnzr2hHx0/s113/Me2.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhO4FVxt14ozR9i8mcmvEb0AMsUBQbDvUJoaWREDUmMcf-AbbcBnzw04Ip_rhXmfzruuD66OCggeLlbYiHtJR-gNHDelhIGYMnzLQQh5MmTSgK8DMaJw3Saxq33iP8sbpDOnPsYHlSM2wmQ/s72-c?imgmax=800" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2990193854398450266.post-8572412364895846222</id><published>2015-08-30T12:50:00.001+00:00</published><updated>2015-08-30T12:59:14.845+00:00</updated><category scheme="http://www.blogger.com/atom/ns#" term=".Net Routing"/><category scheme="http://www.blogger.com/atom/ns#" term="Asp.Net MVC5"/><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="Mocking &amp; Faking"/><category scheme="http://www.blogger.com/atom/ns#" term="Test Double"/><category scheme="http://www.blogger.com/atom/ns#" term="Unit Test"/><title type='text'>Unit Testing (part 2) - Faking the HttpContext and HttpContextBase</title><content type='html'>&lt;div class=&quot;WordSection1&quot;&gt;   &lt;p class=&quot;MsoNormal&quot;&gt;This is the 2&lt;sup&gt;nd&lt;/sup&gt; in a series of posts about unit testing:&lt;b style=&quot;mso-bidi-font-weight: normal&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 36pt&quot;&gt;&lt;b style=&quot;mso-bidi-font-weight: normal&quot;&gt;&lt;a href=&quot;http://jonlanceley.blogspot.co.uk/2015/08/unit-testing-part-1-without-using.html&quot; target=&quot;_blank&quot;&gt;Unit Testing (part 1) - Without using a mocking framework&lt;/a&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 36pt&quot;&gt;&lt;b style=&quot;mso-bidi-font-weight: normal&quot;&gt;Unit Testing (part 2) - Faking the &lt;span class=&quot;SpellE&quot;&gt;HttpContext&lt;/span&gt; and &lt;span class=&quot;SpellE&quot;&gt;HttpContextBase&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 36pt&quot;&gt;&lt;b style=&quot;mso-bidi-font-weight: normal&quot;&gt;&lt;a href=&quot;http://jonlanceley.blogspot.co.uk/2015/08/unit-testing-part-3-running-unit-tests.html&quot; target=&quot;_blank&quot;&gt;Unit Testing (part 3) - Running Unit Tests &amp;amp; Code Coverage&lt;/a&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;text-indent: 36pt&quot;&gt;&lt;b style=&quot;mso-bidi-font-weight: normal&quot;&gt;&lt;a href=&quot;http://jonlanceley.blogspot.co.uk/2015/08/unit-testing-part-4-faking-entity.html&quot; target=&quot;_blank&quot;&gt;Unit Testing (part 4) - Faking Entity Framework code first DbContext &amp;amp; DbSet&lt;/a&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;o:p&gt;&amp;#160;&lt;/o:p&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;There are a lot of posts on the internet about faking the http context.&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160; &lt;/span&gt;And when we have controllers / service functions / MVC routes that all make use of the &lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; line-height: 115%; mso-highlight: white&quot;&gt;HttpContext&lt;/span&gt;&lt;/span&gt; how do you fake it.&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160; &lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;This is my approach which works consistently across all my tests.&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160; &lt;/span&gt;I went down a route initially of having different ways of handling &lt;span class=&quot;GramE&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; line-height: 115%; mso-highlight: white&quot;&gt;HttpContext&lt;/span&gt;&lt;/span&gt; vs a &lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; line-height: 115%; mso-highlight: white&quot;&gt;HttpContextBase&lt;/span&gt;&lt;/span&gt;.&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160; &lt;/span&gt;And then I found way to have 1 approach so the tests are consistent.&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;o:p&gt;&amp;#160;&lt;/o:p&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;First we need a way to fake a normal &lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; line-height: 115%; mso-highlight: white&quot;&gt;HttpContext&lt;/span&gt;&lt;/span&gt;.&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span class=&quot;GramE&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;FakeHttpContext&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;HttpContext&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;span class=&quot;SpellE&quot;&gt;CreateFakeHttpContext&lt;/span&gt;()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;var&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;span class=&quot;SpellE&quot;&gt;httpRequest&lt;/span&gt; = &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;HttpRequest&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;&amp;quot;http://localhost/&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;var&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;span class=&quot;SpellE&quot;&gt;stringWriter&lt;/span&gt; = &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;StringWriter&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;var&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;span class=&quot;SpellE&quot;&gt;httpResponce&lt;/span&gt; = &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;HttpResponse&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;(&lt;span class=&quot;SpellE&quot;&gt;stringWriter&lt;/span&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;var&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;span class=&quot;SpellE&quot;&gt;httpContext&lt;/span&gt; = &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;HttpContext&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;(&lt;span class=&quot;SpellE&quot;&gt;httpRequest&lt;/span&gt;, &lt;span class=&quot;SpellE&quot;&gt;httpResponce&lt;/span&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;var&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;span class=&quot;SpellE&quot;&gt;sessionContainer&lt;/span&gt; = &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;HttpSessionStateContainer&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;&amp;quot;id&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;, &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt 72pt; line-height: normal; text-autospace: ; text-indent: 36pt; mso-layout-grid-align: none&quot;&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;SessionStateItemCollection&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;(), &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt 72pt; line-height: normal; text-autospace: ; text-indent: 36pt; mso-layout-grid-align: none&quot;&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;HttpStaticObjectsCollection&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;(), &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt 72pt; line-height: normal; text-autospace: ; text-indent: 36pt; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;10, &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt 108pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;true&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;,&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;HttpCookieMode&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;.AutoDetect&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;,&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;SessionStateMode&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;.InProc&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;SessionStateUtility&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;.AddHttpSessionStateToContext&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;httpContext&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;, &lt;span class=&quot;SpellE&quot;&gt;sessionContainer&lt;/span&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;return&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;span class=&quot;SpellE&quot;&gt;httpContext&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 115%; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; color: black; line-height: 115%&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; color: black; line-height: 115%&quot;&gt;&lt;o:p&gt;&amp;#160;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: black; mso-bidi-font-family: consolas&quot;&gt;Secondly we need a way to fake &lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;background: white; color: #2b91af; mso-highlight: white; mso-bidi-font-family: consolas&quot;&gt;HttpContextBase&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; mso-bidi-font-family: consolas&quot;&gt;.&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: black; mso-bidi-font-family: consolas&quot;&gt;MVC already have this covered with their implementation of &lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;background: white; color: #2b91af; mso-highlight: white; mso-bidi-font-family: consolas&quot;&gt;HttpContextWrapper&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; mso-bidi-font-family: consolas&quot;&gt;.&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160; &lt;/span&gt;But unfortunately even this doesn’t go quite far enough especially when you want to unit test MVC routes. But we can extend it, enter our &lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; line-height: 115%; mso-highlight: white&quot;&gt;FakeHttpContextWrapper&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; mso-bidi-font-family: consolas&quot;&gt;.&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160; &lt;/span&gt;This inherits from Microsoft’s HttpContextWrapper.&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; color: #2b91af; line-height: 115%&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: black; mso-bidi-font-family: consolas&quot;&gt;What this is going to do is allow us to create our own fake classes by extending the Microsoft ones (so we don’t have to reinvent the wheel). &lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&lt;/span&gt;And this will now let us over-ride the properties we need for unit testing. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: black; mso-bidi-font-family: consolas&quot;&gt;We first create a &lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; line-height: 115%; mso-highlight: white&quot;&gt;FakeHttpContextWrapper&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; mso-bidi-font-family: consolas&quot;&gt; which contains our &lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; line-height: 115%; mso-highlight: white&quot;&gt;FakeHttpRequestWrapper&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; mso-bidi-font-family: consolas&quot;&gt;, and could also contain a &lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; line-height: 115%; mso-highlight: white&quot;&gt;FakeHttpResponseWrapper&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; mso-bidi-font-family: consolas&quot;&gt; if we needed it. I’ve commented out the &lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; line-height: 115%; mso-highlight: white&quot;&gt;FakeHttpResponseWrapper&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; mso-bidi-font-family: consolas&quot;&gt; as I didn’t need it but it does work if you uncomment it.&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; color: #2b91af; line-height: 115%&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span class=&quot;GramE&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;FakeHttpContextWrapper&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; : &lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;HttpContextWrapper&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;FakeHttpRequestWrapper&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; _request;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white&quot;&gt;//&lt;span class=&quot;SpellE&quot;&gt;FakeHttpResponseWrapper&lt;/span&gt; _response;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;         &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;span class=&quot;SpellE&quot;&gt;FakeHttpContextWrapper&lt;/span&gt;(&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;HttpContext&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;span class=&quot;SpellE&quot;&gt;httpContext&lt;/span&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;: &lt;/span&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;base&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;httpContext&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;_request = &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;FakeHttpRequestWrapper&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;httpContext.Request&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white&quot;&gt;//_response = new &lt;span class=&quot;SpellE&quot;&gt;&lt;span class=&quot;GramE&quot;&gt;FakeHttpResponseWrapper&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;GramE&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;httpContext.Response&lt;/span&gt;);&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&amp;#160;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt 42pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;span class=&quot;SpellE&quot;&gt;FakeHttpContextWrapper&lt;/span&gt;(&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;HttpContext&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;span class=&quot;SpellE&quot;&gt;httpContext&lt;/span&gt;, &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;span class=&quot;SpellE&quot;&gt;appPath&lt;/span&gt; = &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;&amp;quot;/&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;,&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt 42pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&lt;/span&gt;&lt;span style=&quot;mso-tab-count: 4&quot;&gt;&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;/span&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160; &lt;/span&gt;&lt;span class=&quot;GramE&quot;&gt;string&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;span class=&quot;SpellE&quot;&gt;requestUrl&lt;/span&gt; = &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;&amp;quot;~/&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;span class=&quot;SpellE&quot;&gt;clientIP&lt;/span&gt; = &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;null&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;: &lt;/span&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;base&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;httpContext&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;_request = &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;FakeHttpRequestWrapper&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;httpContext.Request&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;, &lt;span class=&quot;SpellE&quot;&gt;appPath&lt;/span&gt;, &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span class=&quot;GramE&quot;&gt;requestUrl&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;SpellE&quot;&gt;clientIP&lt;/span&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white&quot;&gt;//_response = new &lt;span class=&quot;SpellE&quot;&gt;&lt;span class=&quot;GramE&quot;&gt;FakeHttpResponseWrapper&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;GramE&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;httpContext.Response&lt;/span&gt;);&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&amp;#160;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white&quot;&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white&quot;&gt; Over-ridden so we can return our &lt;span class=&quot;SpellE&quot;&gt;FakeHttpRequestWrapper&lt;/span&gt; class instead&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white&quot;&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;override&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;HttpRequestBase&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; Request&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;get&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;&lt;/span&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;return&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; _request;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&amp;#160;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;override&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;HttpResponseBase&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; Response&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;get&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white&quot;&gt;//return _response;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;&lt;/span&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;return&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;base&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;.Response&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 115%; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;background: white; mso-highlight: white; mso-bidi-font-family: consolas&quot;&gt;We then create a &lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;FakeHttpRequestWrapper&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;background: white; mso-highlight: white; mso-bidi-font-family: consolas&quot;&gt; which inherits from the Microsoft &lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;HttpRequestWrapper&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;background: white; mso-highlight: white; mso-bidi-font-family: consolas&quot;&gt;.&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160; &lt;/span&gt;This is where the magic happens as this allows us to over-ride those getter properties &lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;color: black&quot;&gt;ApplicationPath&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black&quot;&gt;, &lt;span class=&quot;SpellE&quot;&gt;AppRelativeCurrentExecutionFilePath&lt;/span&gt; and &lt;span class=&quot;SpellE&quot;&gt;UserHostAddress&lt;/span&gt; so we can implement our own logic.&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;///&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white&quot;&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white&quot;&gt; &lt;span class=&quot;GramE&quot;&gt;This&lt;/span&gt; class allows us to set additional properties that are &lt;span class=&quot;SpellE&quot;&gt;anoyingly&lt;/span&gt; null by &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white&quot;&gt; &lt;span class=&quot;GramE&quot;&gt;default&lt;/span&gt; if you just used the &lt;span class=&quot;SpellE&quot;&gt;HttpRequestWrapper&lt;/span&gt; class alone.&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white&quot;&gt; &lt;span class=&quot;GramE&quot;&gt;We&lt;/span&gt; are over-ridding the &lt;span class=&quot;SpellE&quot;&gt;ApplicationPath&lt;/span&gt; &amp;amp; &lt;span class=&quot;SpellE&quot;&gt;AppRelativeCurrentExecutionFilePath&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white&quot;&gt; as these are needed to unit test MVC routes&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white&quot;&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;FakeHttpRequestWrapper&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; : &lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;HttpRequestWrapper&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;string&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;span class=&quot;SpellE&quot;&gt;appPath&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;string&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;span class=&quot;SpellE&quot;&gt;requestUrl&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;string&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;span class=&quot;SpellE&quot;&gt;clientIP&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&amp;#160;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;span class=&quot;SpellE&quot;&gt;FakeHttpRequestWrapper&lt;/span&gt;(&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;HttpRequest&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;span class=&quot;SpellE&quot;&gt;httpRequest&lt;/span&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;: &lt;/span&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;base&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;httpRequest&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&amp;#160;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;span class=&quot;SpellE&quot;&gt;FakeHttpRequestWrapper&lt;/span&gt;(&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;HttpRequest&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;span class=&quot;SpellE&quot;&gt;httpRequest&lt;/span&gt;, &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;span class=&quot;SpellE&quot;&gt;appPath&lt;/span&gt; = &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;&amp;quot;/&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;, &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-tab-count: 5&quot;&gt;&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;/span&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;string&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;span class=&quot;SpellE&quot;&gt;requestUrl&lt;/span&gt; = &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;&amp;quot;~/&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;span class=&quot;SpellE&quot;&gt;clientIP&lt;/span&gt; = &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;null&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;: &lt;/span&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;base&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;httpRequest&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;.appPath&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; = &lt;span class=&quot;SpellE&quot;&gt;appPath&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;.requestUrl&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; = &lt;span class=&quot;SpellE&quot;&gt;requestUrl&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;.clientIP&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; = &lt;span class=&quot;SpellE&quot;&gt;clientIP&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&amp;#160;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;override&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;span class=&quot;SpellE&quot;&gt;ApplicationPath&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;get&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;&lt;/span&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;return&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;span class=&quot;SpellE&quot;&gt;appPath&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&amp;#160;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;override&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;span class=&quot;SpellE&quot;&gt;AppRelativeCurrentExecutionFilePath&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;get&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;&lt;/span&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;return&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;span class=&quot;SpellE&quot;&gt;requestUrl&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&amp;#160;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;override&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;span class=&quot;SpellE&quot;&gt;UserHostAddress&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;get&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;&lt;/span&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;return&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;span class=&quot;SpellE&quot;&gt;clientIP&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 115%; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; color: black; line-height: 115%&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: black; mso-bidi-font-family: consolas&quot;&gt;I didn’t need to fake the response but this is how you’d do it if you need to:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span class=&quot;GramE&quot;&gt;public&lt;/span&gt; class &lt;span class=&quot;SpellE&quot;&gt;FakeHttpResponseWrapper&lt;/span&gt; : &lt;span class=&quot;SpellE&quot;&gt;HttpResponseWrapper&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span class=&quot;GramE&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;SpellE&quot;&gt;FakeHttpResponseWrapper&lt;/span&gt;(&lt;span class=&quot;SpellE&quot;&gt;HttpResponse&lt;/span&gt; &lt;span class=&quot;SpellE&quot;&gt;httpResponse&lt;/span&gt;)&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;: &lt;span class=&quot;GramE&quot;&gt;base(&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;httpResponse&lt;/span&gt;)&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;{&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 115%; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; line-height: 115%; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; color: green; line-height: 115%&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; line-height: 115%; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;}&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;In this unit test you can see 2 lines that deal with setting the &lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; line-height: 115%; mso-highlight: white&quot;&gt;HttpContext&lt;/span&gt;&lt;/span&gt;.&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160; &lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;TestMethod&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;span class=&quot;SpellE&quot;&gt;ProductService_PopulateModel_IPDetectUSA&lt;/span&gt;()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;var&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;span class=&quot;SpellE&quot;&gt;clientIP&lt;/span&gt; = &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;&amp;quot;1.1.1.2&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&lt;/span&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;var&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;span class=&quot;SpellE&quot;&gt;productService&lt;/span&gt; = &lt;span class=&quot;SpellE&quot;&gt;unityContainer.Resolve&lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;IProductService&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; color: #2b91af&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&lt;/span&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;background: yellow; mso-highlight: yellow&quot;&gt;HttpContext&lt;/span&gt;&lt;span style=&quot;background: yellow; color: black; mso-highlight: yellow&quot;&gt;.Current&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: black; mso-highlight: yellow&quot;&gt; = &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: blue; mso-highlight: yellow&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: black; mso-highlight: yellow&quot;&gt; &lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: #2b91af; mso-highlight: yellow&quot;&gt;FakeHttpContext&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: black; mso-highlight: yellow&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: black; mso-highlight: yellow&quot;&gt;).&lt;span class=&quot;SpellE&quot;&gt;CreateFakeHttpContext&lt;/span&gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt 36pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;o:p&gt;&amp;#160;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; color: blue&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&lt;/span&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;background: yellow; mso-highlight: yellow&quot;&gt;var&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: black; mso-highlight: yellow&quot;&gt; &lt;span class=&quot;SpellE&quot;&gt;httpContextWrapper&lt;/span&gt; = &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: blue; mso-highlight: yellow&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: black; mso-highlight: yellow&quot;&gt; &lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: #2b91af; mso-highlight: yellow&quot;&gt;FakeHttpContextWrapper&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: black; mso-highlight: yellow&quot;&gt;(&lt;span class=&quot;SpellE&quot;&gt;httpContext&lt;/span&gt;:&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; color: black&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: #2b91af; mso-highlight: yellow&quot;&gt;HttpContext&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: black; mso-highlight: yellow&quot;&gt;.Current&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: black; mso-highlight: yellow&quot;&gt;, &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; color: black&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&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;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;background: yellow; mso-highlight: yellow&quot;&gt;clientIP&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;background: yellow; mso-highlight: yellow&quot;&gt;: &lt;span class=&quot;SpellE&quot;&gt;clientIP&lt;/span&gt;);&lt;/span&gt;&lt;span style=&quot;background: white; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&lt;/span&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;var&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; model = &lt;span class=&quot;SpellE&quot;&gt;productService.PopulateModel&lt;/span&gt;(&lt;span class=&quot;SpellE&quot;&gt;httpContextWrapper&lt;/span&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;}&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;The 1&lt;sup&gt;st&lt;/sup&gt; line sets a normal &lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; line-height: 115%; mso-highlight: white&quot;&gt;HttpContext&lt;/span&gt;.Current&lt;/span&gt; using our &lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; line-height: 115%; mso-highlight: white&quot;&gt;FakeHttpContext&lt;/span&gt;&lt;/span&gt; () method.&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160; &lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;The 2&lt;sup&gt;nd&lt;/sup&gt; line uses our &lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; line-height: 115%; mso-highlight: white&quot;&gt;FakeHttpContextWrapper&lt;/span&gt;&lt;/span&gt; method to wrap and extend the &lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; line-height: 115%; mso-highlight: white&quot;&gt;HttpContext&lt;/span&gt;.Current&lt;/span&gt; we set up on the 1&lt;sup&gt;st&lt;/sup&gt; line which is something we can now pass to MVC controllers or routes.&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;o:p&gt;&amp;#160;&lt;/o:p&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;And this is how you’d unit test an MVC route (the &lt;span class=&quot;SpellE&quot;&gt;clientIP&lt;/span&gt; and &lt;span class=&quot;SpellE&quot;&gt;requestUrl&lt;/span&gt; parameters are optional).&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;TestMethod&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;span class=&quot;SpellE&quot;&gt;Route_Account_Login&lt;/span&gt;()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;var&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; routes = &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;RouteCollection&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;RouteConfig&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;.RegisterRoutes&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;routes);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; color: #2b91af&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;background: yellow; mso-highlight: yellow&quot;&gt;HttpContext&lt;/span&gt;&lt;span style=&quot;background: yellow; color: black; mso-highlight: yellow&quot;&gt;.Current&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: black; mso-highlight: yellow&quot;&gt; = &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: blue; mso-highlight: yellow&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: black; mso-highlight: yellow&quot;&gt; &lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: #2b91af; mso-highlight: yellow&quot;&gt;FakeHttpContext&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: black; mso-highlight: yellow&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: black; mso-highlight: yellow&quot;&gt;).&lt;span class=&quot;SpellE&quot;&gt;CreateFakeHttpContext&lt;/span&gt;();&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: blue; mso-highlight: yellow&quot;&gt;var&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: black; mso-highlight: yellow&quot;&gt; &lt;span class=&quot;SpellE&quot;&gt;httpContextWrapper&lt;/span&gt; = &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: blue; mso-highlight: yellow&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: black; mso-highlight: yellow&quot;&gt; &lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: #2b91af; mso-highlight: yellow&quot;&gt;FakeHttpContextWrapper&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: black; mso-highlight: yellow&quot;&gt;(&lt;span class=&quot;SpellE&quot;&gt;httpContext&lt;/span&gt;:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt 180pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; color: black&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&lt;/span&gt;&lt;span style=&quot;mso-tab-count: 1&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: #2b91af; mso-highlight: yellow&quot;&gt;HttpContext&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: black; mso-highlight: yellow&quot;&gt;.Current&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: black; mso-highlight: yellow&quot;&gt;, &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt 180pt; line-height: normal; text-autospace: ; text-indent: 36pt; mso-layout-grid-align: none&quot;&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: black; mso-highlight: yellow&quot;&gt;requestUrl&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: black; mso-highlight: yellow&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: #a31515; mso-highlight: yellow&quot;&gt;&amp;quot;~/account/login/&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: black; mso-highlight: yellow&quot;&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;var&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;span class=&quot;SpellE&quot;&gt;routeData&lt;/span&gt; = &lt;span class=&quot;SpellE&quot;&gt;routes.GetRouteData&lt;/span&gt;(&lt;span class=&quot;SpellE&quot;&gt;httpContextWrapper&lt;/span&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&amp;#160;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white&quot;&gt;//Expected Results&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;AssertAll&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;.Execute&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;() =&amp;gt; &lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;Assert&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;.IsNotNull&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;(&lt;span class=&quot;SpellE&quot;&gt;routeData&lt;/span&gt;),&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160; &lt;/span&gt;() =&amp;gt; &lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;Assert&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;.AreEqual&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;&amp;quot;Account&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;, (&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;)&lt;span class=&quot;SpellE&quot;&gt;routeData.Values&lt;/span&gt;[&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;&amp;quot;controller&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;], &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;),&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160; &lt;/span&gt;() =&amp;gt; &lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;Assert&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;.AreEqual&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;&amp;quot;login&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;, (&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;)&lt;span class=&quot;SpellE&quot;&gt;routeData.Values&lt;/span&gt;[&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;&amp;quot;action&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;], &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;),&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160; &lt;/span&gt;() =&amp;gt; &lt;/span&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;Assert&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;.IsTrue(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;.IsNullOrWhiteSpace(routeData.Values[&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;&amp;quot;id&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;].ToString())));&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 115%; mso-highlight: white&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; color: black; line-height: 115%&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;span style=&quot;font-size: 11pt; font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;; color: black; line-height: 115%; mso-bidi-font-family: consolas; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-fareast-language: en-us; mso-ansi-language: en-gb; mso-bidi-language: ar-sa&quot;&gt;     &lt;br style=&quot;page-break-before: always; mso-special-character: line-break&quot; clear=&quot;all&quot; /&gt;&lt;/span&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: black; mso-bidi-font-family: consolas&quot;&gt;&lt;o:p&gt;&amp;#160;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: black; mso-bidi-font-family: consolas&quot;&gt;And this is how you would test an MVC controller, using the same 2 lines in yellow just without the optional parameter this time.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;TestMethod&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;span class=&quot;SpellE&quot;&gt;ProductController_CheckView&lt;/span&gt;()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span class=&quot;GramE&quot;&gt;var&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;span class=&quot;SpellE&quot;&gt;productService&lt;/span&gt; = &lt;span class=&quot;SpellE&quot;&gt;unityContainer.Resolve&lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;IProductService&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;var&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;span class=&quot;SpellE&quot;&gt;productController&lt;/span&gt; = &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;ProductController&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;(&lt;span class=&quot;SpellE&quot;&gt;productService&lt;/span&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; color: #2b91af&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;background: yellow; mso-highlight: yellow&quot;&gt;HttpContext&lt;/span&gt;&lt;span style=&quot;background: yellow; color: black; mso-highlight: yellow&quot;&gt;.Current&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: black; mso-highlight: yellow&quot;&gt; = &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: blue; mso-highlight: yellow&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: black; mso-highlight: yellow&quot;&gt; &lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: #2b91af; mso-highlight: yellow&quot;&gt;FakeHttpContext&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: black; mso-highlight: yellow&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: black; mso-highlight: yellow&quot;&gt;).&lt;span class=&quot;SpellE&quot;&gt;CreateFakeHttpContext&lt;/span&gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: blue; mso-highlight: yellow&quot;&gt;var&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: black; mso-highlight: yellow&quot;&gt; &lt;span class=&quot;SpellE&quot;&gt;httpContextWrapper&lt;/span&gt; = &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: blue; mso-highlight: yellow&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: black; mso-highlight: yellow&quot;&gt; &lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: #2b91af; mso-highlight: yellow&quot;&gt;FakeHttpContextWrapper&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: black; mso-highlight: yellow&quot;&gt;(&lt;span class=&quot;SpellE&quot;&gt;httpContext&lt;/span&gt;: &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt 252pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: #2b91af; mso-highlight: yellow&quot;&gt;HttpContext&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: black; mso-highlight: yellow&quot;&gt;.Current&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: yellow; color: black; mso-highlight: yellow&quot;&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white&quot;&gt;// Pass the fake &lt;span class=&quot;SpellE&quot;&gt;httpContext&lt;/span&gt; to the controller context&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160; &lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;productController.ControllerContext&lt;/span&gt; = &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;ControllerContext&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;httpContextWrapper&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin: 0cm 0cm 0pt 36pt; line-height: normal; text-autospace: ; text-indent: 36pt; mso-layout-grid-align: none&quot;&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;RouteData&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;), &lt;span class=&quot;SpellE&quot;&gt;productController&lt;/span&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&amp;#160;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white&quot;&gt;// Call the controller method to test&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;var&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;span class=&quot;SpellE&quot;&gt;controllerResult&lt;/span&gt; = &lt;span class=&quot;SpellE&quot;&gt;productController.Index&lt;/span&gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&amp;#160;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white&quot;&gt;// Check the view name is correct&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;Assert&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;.IsTrue&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;controllerResult&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;is&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;ViewResult&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;&amp;quot;&lt;span class=&quot;SpellE&quot;&gt;ViewResult&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;var&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; view = &lt;span class=&quot;SpellE&quot;&gt;controllerResult&lt;/span&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white&quot;&gt;as&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt; &lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;ViewResult&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;SpellE&quot;&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white&quot;&gt;Assert&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;.AreEqual&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;GramE&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;&amp;quot;Index&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;, &lt;span class=&quot;SpellE&quot;&gt;view.ViewName&lt;/span&gt;, &lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white&quot;&gt;&amp;quot;&lt;span class=&quot;SpellE&quot;&gt;ViewName&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;/div&gt;  </content><link rel='replies' type='application/atom+xml' href='http://jonlanceley.blogspot.com/feeds/8572412364895846222/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jonlanceley.blogspot.com/2015/08/unit-testing-part-2-faking-httpcontext.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2990193854398450266/posts/default/8572412364895846222'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2990193854398450266/posts/default/8572412364895846222'/><link rel='alternate' type='text/html' href='http://jonlanceley.blogspot.com/2015/08/unit-testing-part-2-faking-httpcontext.html' title='Unit Testing (part 2) - Faking the HttpContext and HttpContextBase'/><author><name>Jon</name><uri>http://www.blogger.com/profile/03999374060620875716</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtN6KAyfs2XT5axA13YSBK6vG1fODGqFwkd7i3EgUB0JjSkFLFVaAZ4pbpaS_vohqo9WxkqepTFpoOWWpFhX_ozDe4BOvA-JHUiJlQBcVNk713PsbLK_Hj96vnzr2hHx0/s113/Me2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2990193854398450266.post-500287997223574836</id><published>2015-08-30T12:47:00.001+00:00</published><updated>2015-08-30T12:55:27.000+00:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Asp.Net MVC5"/><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="Mocking &amp; Faking"/><category scheme="http://www.blogger.com/atom/ns#" term="Test Double"/><category scheme="http://www.blogger.com/atom/ns#" term="Unit Test"/><title type='text'>Unit Testing (part 1) - Without using a mocking framework</title><content type='html'>&lt;p&gt;   &lt;br /&gt;In this series of posts we are not using Moq or Microsoft Fakes or any testing framework, instead we are using the test double approach and following the rule “&lt;b&gt;do not test code you do not own”.&lt;/b&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;b&gt;Unit Testing (part 1) - Without using a mocking framework&lt;/b&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;b&gt;&lt;a href=&quot;http://jonlanceley.blogspot.co.uk/2015/08/unit-testing-part-2-faking-httpcontext.html&quot; target=&quot;_blank&quot;&gt;Unit Testing (part 2) - Faking the HttpContext and HttpContextBase&lt;/a&gt;&lt;/b&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;b&gt;&lt;a href=&quot;http://jonlanceley.blogspot.co.uk/2015/08/unit-testing-part-3-running-unit-tests.html&quot; target=&quot;_blank&quot;&gt;Unit Testing (part 3) - Running Unit Tests &amp;amp; Code Coverage&lt;/a&gt;&lt;/b&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;b&gt;&lt;a href=&quot;http://jonlanceley.blogspot.co.uk/2015/08/unit-testing-part-4-faking-entity.html&quot; target=&quot;_blank&quot;&gt;Unit Testing (part 4) - Faking Entity Framework code first DbContext &amp;amp; DbSet&lt;/a&gt;&lt;/b&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;When I asked myself what I needed to test the answer is “my business logic and any classes I wrote that are called by the business logic”. I don’t want to test making actual calls to the database or 3&lt;sup&gt;rd&lt;/sup&gt; party web services etc.&lt;/p&gt;  &lt;p&gt;I also took the view that what I wanted to test was not every class in isolation I don’t have the time at my employer to do it the purist way of mocking the in’s/outs around each class. Instead I came up with a compromise and call the controller and let the code run (as it would when running on the web site). I just fake out the 3&lt;sup&gt;rd&lt;/sup&gt; party calls so my focus of testing is on my code.&lt;/p&gt;  &lt;p&gt;Let’s see how this works:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;The MVC 5 web site controllers in my site don’t really contain any code they all reference a service function which populates the MVC model. Which keep our controllers lean. &lt;/li&gt; &lt;/ul&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;font color=&quot;#0000ff&quot;&gt;public&lt;/font&gt; ProductController(&lt;font color=&quot;#4bacc6&quot;&gt;IProductService&lt;/font&gt; productService) : &lt;font color=&quot;#0000ff&quot;&gt;base&lt;/font&gt;()&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; this.productService = productService;&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;font color=&quot;#0000ff&quot;&gt;public&lt;/font&gt; &lt;font color=&quot;#4bacc6&quot;&gt;ActionResult&lt;/font&gt; Index()&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; var model = productService.&lt;font color=&quot;#ff0000&quot;&gt;PopulateModel&lt;/font&gt;(&lt;font color=&quot;#0000ff&quot;&gt;this&lt;/font&gt;.HttpContext, ...);&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;font color=&quot;#0000ff&quot;&gt;return&lt;/font&gt; View(model.ViewTemplateToRender, model);&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt; &lt;/blockquote&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;p&gt;We make use of Interfaces (which are essential for effective unit testing). &lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Also note that the PopulateModel(this.HttpContext, …) is expecting a HttpContextBase more on that later. &lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;We use dependency injection to inject the actual concrete class at run time which matches the interface. We do this so in our unit tests we can over-ride any concrete class and replace it with a test double if we need to. The times when we would do this are when we call code that we do not own (e.g. 3&lt;sup&gt;rd&lt;/sup&gt; party web services, .Net framework code etc.). &lt;/p&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;This is where the rule &lt;b&gt;“do not test code you do not own”&lt;/b&gt; comes into its own.&lt;/p&gt;  &lt;p&gt;By &lt;u&gt;not&lt;/u&gt; following this rule you open yourself to a whole world of pain. For example why test a call to an external web service. All you need to do is test that your code is calling the correct method, passing the correct data, and getting back the correct response. But without making the actual call we’d fake it instead. This results in tests that run much faster. If you made the call to the web service that’s integration testing.&lt;/p&gt;  &lt;p&gt;Why would you test code that sets a cookie, you’ve got to fake the request / response to do it, we know it works Microsoft have tested it, and it’s been in .Net for many years. It’s actually much easier to test if you think differently and use a &lt;font color=&quot;#4bacc6&quot;&gt;CookieContainer&lt;/font&gt; class with an interface &lt;font color=&quot;#4bacc6&quot;&gt;ICookieContainer&lt;/font&gt; then I let the site use request.Cookies etc. And have a test double &lt;font color=&quot;#4bacc6&quot;&gt;FakeCookieContainer&lt;/font&gt; class that doesn’t use the request / response at all.&lt;/p&gt;  &lt;p&gt;Let’s say I had an external web service which one of my service functions calls which given the clients IP number returns the country that the IP number is located in. I do not want to make that actual call from a unit test the speed will be terrible and that’s a job for an integration test using Selenium or some other UI testing tool. But I do want to call it from my website. So I create an interface:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font color=&quot;#0000ff&quot;&gt;public interface&lt;/font&gt; &lt;font color=&quot;#4bacc6&quot;&gt;IIpFunctions&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;{&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; &lt;font color=&quot;#4bacc6&quot;&gt;Country&lt;/font&gt; GetCountry(&lt;font color=&quot;#4bacc6&quot;&gt;HttpRequestBase&lt;/font&gt; request);&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;}&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;My concrete class used by the site is going to call the GetCountry method and do the actual calling of the external web service, which would look like this (some code has been removed for simpler reading):&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font color=&quot;#0000ff&quot;&gt;public class&lt;/font&gt; &lt;font color=&quot;#4bacc6&quot;&gt;IpFunctions&lt;/font&gt; : &lt;font color=&quot;#4bacc6&quot;&gt;IIpFunctions&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;{&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; &lt;font color=&quot;#0000ff&quot;&gt;public&lt;/font&gt; &lt;font color=&quot;#4bacc6&quot;&gt;Country&lt;/font&gt; GetCountry(&lt;font color=&quot;#4bacc6&quot;&gt;HttpRequestBase&lt;/font&gt; request)&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; {&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;font color=&quot;#4bacc6&quot;&gt;String&lt;/font&gt; ip = GetClientIP(request);&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; using (&lt;font color=&quot;#4bacc6&quot;&gt;HttpClient&lt;/font&gt; client = new &lt;font color=&quot;#4bacc6&quot;&gt;HttpClient&lt;/font&gt;())&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;font color=&quot;#4bacc6&quot;&gt;HttpResponseMessage&lt;/font&gt; response = client.GetAsync(countryRequest).Result;&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; response.EnsureSuccessStatusCode();&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; countryResult = response.Content.ReadAsStringAsync().Result;&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;font color=&quot;#0000ff&quot;&gt;return&lt;/font&gt; countryRepository.GetByIso(countryResult);&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;}&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;For unit testing I just need to create a fake concrete class, both inheriting the same interface. So it passes in the same request object and gets a Country object back. But the code internally is very different.&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font color=&quot;#0000ff&quot;&gt;public class&lt;/font&gt; &lt;font color=&quot;#4bacc6&quot;&gt;FakeIpFunctions&lt;/font&gt; : &lt;font color=&quot;#4bacc6&quot;&gt;IIpFunctions&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;{&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; &lt;font color=&quot;#0000ff&quot;&gt;public&lt;/font&gt; &lt;font color=&quot;#4bacc6&quot;&gt;Country&lt;/font&gt; GetCountry(&lt;font color=&quot;#4bacc6&quot;&gt;HttpRequestBase&lt;/font&gt; request)&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; {&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;font color=&quot;#0000ff&quot;&gt;var&lt;/font&gt; clientIP = request.UserHostAddress;&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;font color=&quot;#0000ff&quot;&gt;if&lt;/font&gt; (clientIP == &amp;quot;1.1.1.1&amp;quot;)&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font color=&quot;#8fb08c&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // Fake UK IP address&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;font color=&quot;#0000ff&quot;&gt;return&lt;/font&gt; countryRepository.GetByIso(&amp;quot;GBR&amp;quot;);&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;font color=&quot;#0000ff&quot;&gt;else if&lt;/font&gt; (clientIP == &amp;quot;1.1.1.2&amp;quot;)&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font color=&quot;#8fb08c&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // Fake USA IP address&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;font color=&quot;#0000ff&quot;&gt;return&lt;/font&gt; countryRepository.GetByIso(&amp;quot;USA&amp;quot;);&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;font color=&quot;#0000ff&quot;&gt;return&lt;/font&gt; null;&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;}&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Now when I’m writing a unit test I can just pass in the IP number 1.1.1.2 as part of the request object and I know the country will be USA.&lt;/p&gt;  &lt;p&gt;My unit test would look like this:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;[&lt;font color=&quot;#4bacc6&quot;&gt;TestMethod&lt;/font&gt;]&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font color=&quot;#0000ff&quot;&gt;public void&lt;/font&gt; ProductService_PopulateModel_IPDetectUSA()&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;{&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font color=&quot;#0000ff&quot;&gt;&amp;#160;&amp;#160;&amp;#160; var&lt;/font&gt; clientIP = &amp;quot;1.1.1.2&amp;quot;;&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font color=&quot;#0000ff&quot;&gt;&amp;#160;&amp;#160;&amp;#160; var&lt;/font&gt; productService = unityContainer.Resolve&amp;lt;&lt;font color=&quot;#4bacc6&quot;&gt;IProductService&lt;/font&gt;&amp;gt;();&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font color=&quot;#4bacc6&quot;&gt;&amp;#160;&amp;#160;&amp;#160; HttpContext&lt;/font&gt;.Current = &lt;font color=&quot;#0000ff&quot;&gt;new&lt;/font&gt; &lt;font color=&quot;#4bacc6&quot;&gt;FakeHttpContext&lt;/font&gt;().CreateFakeHttpContext();&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font color=&quot;#0000ff&quot;&gt;&amp;#160;&amp;#160;&amp;#160; var&lt;/font&gt; httpContextWrapper = &lt;font color=&quot;#0000ff&quot;&gt;new&lt;/font&gt; &lt;font color=&quot;#4bacc6&quot;&gt;FakeHttpContextWrapper&lt;/font&gt;(httpContext: &lt;font color=&quot;#4bacc6&quot;&gt;HttpContext&lt;/font&gt;.Current, clientIP: clientIP);&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font color=&quot;#0000ff&quot;&gt;&amp;#160;&amp;#160;&amp;#160; var&lt;/font&gt; model = productService.PopulateModel(httpContextWrapper);&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;}&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;My dependency injection is setup so:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;p&gt;It uses the same IProductService concrete class for unit tests &lt;u&gt;and&lt;/u&gt; for the MVC web site. But within the ProductService class’s constructor it uses the IIpFunctions interface. &lt;/p&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p align=&quot;center&quot;&gt;&lt;font color=&quot;#0000ff&quot;&gt;public&lt;/font&gt; ProductService(&lt;font color=&quot;#4bacc6&quot;&gt;IIpFunctions&lt;/font&gt; ipFunctions, …)&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;p&gt;For the &lt;font color=&quot;#4bacc6&quot;&gt;IIpFunctions&lt;/font&gt; interface the dependency injection is very different, the site calls &lt;font color=&quot;#4bacc6&quot;&gt;IpFunctions&lt;/font&gt; and the unit tests call &lt;font color=&quot;#4bacc6&quot;&gt;FakeIpFunctions&lt;/font&gt;. &lt;/p&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;So I’ve followed the rule “&lt;b&gt;don’t test what you don’t own&lt;/b&gt;”. I can do the same with cookies, cache managers like Redis Cache etc. I don’t want to test third party code, so I use interfaces and create a fake test double class for unit testing with.&lt;/p&gt;  &lt;p&gt;&lt;i&gt;Note: in the above unit test example I’m starting my unit test at my ProductService not the MVC controller, there is no reason this could not be the controller but because my controllers don’t really contain any code they simply call the service layer I decided that my unit tests for the most part should start at the service layer. I’d then need just a handful of unit tests to test the controller (which would really be to just check the correct view is being returned or any viewbag values are set correctly etc.).&lt;/i&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Is this the purist way of doing unit testing&lt;/strong&gt; – No.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Is this truly a unit test where the definition of a unit = a class (e.g. you test each class in isolation and any dependencies for it are mocked / faked)&lt;/strong&gt; – No.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Isn’t this integration testing&lt;/strong&gt; – That’s a fine line and debatable but no because it’s very fast, all in memory and we don’t call 3&lt;sup&gt;rd&lt;/sup&gt; party code/services like an integration test would.&lt;/p&gt;  &lt;p&gt;Why didn’t we do the above?&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;p&gt;Because companies don’t like to invest the time in developing unit tests especially the purist way. So it’s better to have something rather than nothing. &lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Because it would take a lot longer to write and more tests are needed to get decent code coverage. &lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;It gives the same benefit; the code is tested very quickly while it’s still in Visual Studio. And we’d always follow up with integration tests once the code has been deployed to a test environment. &lt;/p&gt;   &lt;/li&gt; &lt;/ul&gt;  </content><link rel='replies' type='application/atom+xml' href='http://jonlanceley.blogspot.com/feeds/500287997223574836/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jonlanceley.blogspot.com/2015/08/unit-testing-part-1-without-using.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2990193854398450266/posts/default/500287997223574836'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2990193854398450266/posts/default/500287997223574836'/><link rel='alternate' type='text/html' href='http://jonlanceley.blogspot.com/2015/08/unit-testing-part-1-without-using.html' title='Unit Testing (part 1) - Without using a mocking framework'/><author><name>Jon</name><uri>http://www.blogger.com/profile/03999374060620875716</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtN6KAyfs2XT5axA13YSBK6vG1fODGqFwkd7i3EgUB0JjSkFLFVaAZ4pbpaS_vohqo9WxkqepTFpoOWWpFhX_ozDe4BOvA-JHUiJlQBcVNk713PsbLK_Hj96vnzr2hHx0/s113/Me2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2990193854398450266.post-3360253460574960998</id><published>2011-07-02T09:42:00.001+00:00</published><updated>2011-07-03T09:16:23.085+00:00</updated><category scheme="http://www.blogger.com/atom/ns#" term=".Net Routing"/><category scheme="http://www.blogger.com/atom/ns#" term="Asp.Net Web Forms"/><category scheme="http://www.blogger.com/atom/ns#" term="SSL"/><title type='text'>Http to Https Flipper for Asp.Net Web Forms</title><content type='html'>&lt;p&gt;This article shows how to automatically make Asp.Net Web Form sites open certain pages on the site as https by using a 301 moved permanently redirect.&amp;#160; It works with standard web forms .aspx pages and web forms using .Net Routing.&lt;/p&gt;  &lt;p&gt;This example will cover the following scenarios:&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;1.&lt;/strong&gt; If a user navigates to &lt;a href=&quot;http://www.mydomain.com/default.aspx&quot;&gt;http://www.mydomain.com/default.aspx&lt;/a&gt; then we can automatically have the URL change to be &lt;a href=&quot;https://www.mydomain.com/default.aspx&quot;&gt;https://www.mydomain.com/default.aspx&lt;/a&gt; for the default.aspx page only, other pages will remain non-secure.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;2.&lt;/strong&gt; You want all your sites web pages to always go secure (https).&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;3.&lt;/strong&gt; Allow you to control which pages go secure by using a ‘RequireSSL’ attribute (much like mvc now does).&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;4.&lt;/strong&gt; Allow you to control which pages go secure by listing them in the web.config.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;5.&lt;/strong&gt; If you have non standard ports for http and https e.g. &lt;a href=&quot;http://www.mydomain.com:8054/default.aspx&quot;&gt;http://www.mydomain.com:8054/default.aspx&lt;/a&gt; can change the URL to &lt;a href=&quot;https://www.mydomain.com:4054/default.aspx&quot;&gt;https://www.mydomain.com:4054/default.aspx&lt;/a&gt;.&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;Note the 8054 = http and 4054 = https.&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;strong&gt;6. &lt;/strong&gt;You have non standard ports as point 5 above mentions, but in your live environment the ports are masked from the user by the firewall (or some other clever piece of hardware).&amp;#160; But internally the ports are still being used by the firewall to route traffic to your site.&lt;/p&gt;  &lt;p&gt;e.g. Your web site on IIS is setup to use ports 8054(http) &amp;amp; 4054(https) but the user in their browser will see &lt;a href=&quot;http://www.mydomain.com/default.aspx&quot;&gt;http://www.mydomain.com/default.aspx&lt;/a&gt; and &lt;a href=&quot;https://www.mydomain.com/default.aspx&quot;&gt;https://www.mydomain.com/default.aspx&lt;/a&gt;.&amp;#160; In this scenario you would want to remove the port when you flip from http to https.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;Lets see some code&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;First create a new project, lets call it ‘JL.Web.Security’.&amp;#160; &lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjSPbq3nOrSGLGCyBpTOvRzaftcn41eUqvuR-lND8-EgJcQcHf_3LdxElrX7Gl8w3Kt52f7JYD66Em2hJPKCXA_8zNqn-llf4c7VmxqLny7MKLBgsTA5x2ZewIR4mAOyeVmlF3QseMpJV1q/s1600-h/SolutionStructure%25255B3%25255D.gif&quot;&gt;&lt;img style=&quot;background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto; padding-top: 0px&quot; title=&quot;SolutionStructure&quot; border=&quot;0&quot; alt=&quot;SolutionStructure&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDufyu7O1qCMsiRrrVPb0V2o-8WauLa9dLNUTt6Mbm_-0QajXTEjlxUzS1_sghPhltQOBagf3AQ76nNRPheb-TbqeLoPrTFpMVc9WshJKiX_WThWRrpa16DzUWZu8afMBgpbRSIHFl1GhF/?imgmax=800&quot; width=&quot;271&quot; height=&quot;354&quot; /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;As you add the classes below the structure of the project should end up looking like the above.&lt;/p&gt;  &lt;p&gt;Add the following 2 classes (RequireSSLAttribute.cs and RequireSSLModule.cs).&lt;/p&gt; &lt;strong&gt;RequireSSLAttribute.cs&lt;/strong&gt;   &lt;br /&gt;  &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; width=&quot;100%&quot; bgcolor=&quot;#d3d3d3&quot;&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td&gt;         &lt;p&gt;namespace JL.Web.Security            &lt;br /&gt;{             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; /// Attribute to place on classes that you want to go secure (SSL / HTTPS)             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; [AttributeUsage(AttributeTargets.Class)]             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; sealed public class RequireSSL : Attribute             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }             &lt;br /&gt;}&lt;/p&gt;       &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;With the ‘RequireSSLAttribute’&#39; you can now place this attribute on any web form code behind page and that page will always go secure e.g.    &lt;br /&gt;    &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; width=&quot;100%&quot; bgcolor=&quot;#d3d3d3&quot;&gt;&lt;tbody&gt;       &lt;tr&gt;         &lt;td&gt;           &lt;p&gt;namespace WebApplication              &lt;br /&gt;{               &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; [RequireSSL]               &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public partial class WebForm1 : System.Web.UI.Page               &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {               &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; protected void Page_Load(object sender, EventArgs e)               &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {               &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }               &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }               &lt;br /&gt;}&lt;/p&gt;         &lt;/td&gt;       &lt;/tr&gt;     &lt;/tbody&gt;&lt;/table&gt; &lt;/p&gt;  &lt;p&gt;The ‘RequireSSLModule.cs’ class below is the one that does the real work.&lt;/p&gt;  &lt;p&gt;But in summary all this class really does is create a new IHttpModule that listens for page requests. Then checks if every page should be secure and if we are not already secure then go secure (https).&amp;#160; Otherwise check if the RequireSSL attribute is on the page if it is go secure (if we are not secure already), if the attribute is not in use then check the web.config file to see if the page is listed there, if it is go secure (if we are not secure already). Otherwise go non secure (if we are currently secure).&lt;/p&gt; &lt;strong&gt;RequireSSLModule.cs&lt;/strong&gt;   &lt;br /&gt;  &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; width=&quot;100%&quot; bgcolor=&quot;#d3d3d3&quot;&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td&gt;         &lt;p&gt;namespace JL.Web.Security            &lt;br /&gt;{             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; /// HttpModule for switching between HTTP and HTTPS (HTTP &amp;lt;=&amp;gt; HTTPS)             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public class RequireSSLModule : IHttpModule             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; SecureWebPageSettings settings = null;&lt;/p&gt;          &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public void Init(HttpApplication context)            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; settings = WebConfigurationManager.GetSection(&amp;quot;secureWebPageSettings&amp;quot;) as SecureWebPageSettings;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if (settings != null &amp;amp;&amp;amp; settings.Mode != SecureWebPageMode.Off)             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {             &lt;br /&gt;&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; // The PreRequestHandlerExecute event occurs just before ASP.NET begins executing             &lt;br /&gt;&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; // a handler such as a Page.             &lt;br /&gt;&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; // In here we can acquire a reference to the currently executing ASPX Page             &lt;br /&gt;&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; context.PreRequestHandlerExecute += new EventHandler(OnPreRequestHandlerExecute);             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;          &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// Empty, but necessary when implementing IHttpModule             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public void Dispose() { }&lt;/p&gt;          &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// Switch between HTTP and HTTPS as and when necessary.             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;param name=&amp;quot;sender&amp;quot;&amp;gt;&amp;lt;/param&amp;gt;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;param name=&amp;quot;e&amp;quot;&amp;gt;&amp;lt;/param&amp;gt;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; void OnPreRequestHandlerExecute(object sender, EventArgs e)             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; bool requireSSL = false;&lt;/p&gt;          &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // obtain a reference to the ASPX Page            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; System.Web.UI.Page Page = HttpContext.Current.Handler as System.Web.UI.Page;&lt;/p&gt;          &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // if a valid Page was not found, exit            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if (Page == null)             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {             &lt;br /&gt;&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; return;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;          &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if (settings.MakeAllPagesSecure)&amp;#160;&amp;#160;&amp;#160; // All pages must be secure            &lt;br /&gt;&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; requireSSL = true;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; else             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {             &lt;br /&gt;&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; // Check if the Page is decorated with the RequireSSL attribute             &lt;br /&gt;&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; requireSSL = (Page.GetType().GetCustomAttributes(typeof(RequireSSL), true).Length &amp;gt; 0);             &lt;br /&gt;&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; if (requireSSL == false)             &lt;br /&gt;&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;br /&gt;&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; // Check the pages in the web.config to see if it is mentioned here as must be secure             &lt;br /&gt;&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; var pageName = Page.GetType().BaseType.Name;             &lt;br /&gt;&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; if (settings.Files.IndexOf(pageName) &amp;gt;= 0)             &lt;br /&gt;&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; requireSSL = true;             &lt;br /&gt;&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;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;          &lt;p&gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // check if the Page is currently using the HTTPS scheme             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; bool isSecureConnection = HttpContext.Current.ApplicationInstance.Request.IsSecureConnection;&lt;/p&gt;          &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // acquire the URI (e.g. &lt;a href=&quot;http://localhost/default.aspx)&quot;&gt;http://localhost/default.aspx)&lt;/a&gt;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Uri baseUri = HttpContext.Current.ApplicationInstance.Request.Url;&lt;/p&gt;          &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; String portToUse = String.Empty;&lt;/p&gt;          &lt;p&gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if (requireSSL &amp;amp;&amp;amp; !isSecureConnection)             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {             &lt;br /&gt;&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; // The page requires SSL and it is currently using the HTTP scheme.             &lt;br /&gt;&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; // Switch the HTTP scheme to the HTTPS scheme             &lt;br /&gt;&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; string url = baseUri.ToString().Replace(baseUri.Scheme, Uri.UriSchemeHttps);&lt;/p&gt;          &lt;p&gt;&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; ChangePort(baseUri, true, ref url);&lt;/p&gt;          &lt;p&gt;&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; // perform a 301 redirect to the secure url            &lt;br /&gt;&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; PermanentRedirect(url);             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; else if (!requireSSL &amp;amp;&amp;amp; isSecureConnection)             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {             &lt;br /&gt;&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; // The page does not require SSL and it is currently using the HTTPS scheme.             &lt;br /&gt;&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; // Switch the HTTPS scheme to the HTTP scheme             &lt;br /&gt;&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; string url = baseUri.ToString().Replace(baseUri.Scheme, Uri.UriSchemeHttp);&lt;/p&gt;          &lt;p&gt;&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; ChangePort(baseUri, false, ref url);&lt;/p&gt;          &lt;p&gt;&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; // perform a 301 redirect to the non-secure url            &lt;br /&gt;&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; PermanentRedirect(url);             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;          &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// Peforms a 301 redirect to the given url. This is the most search engine friendly             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// way of redirecting to another Page. The 301 status code means that a Page has             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// permanently moved to a new location.             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;param name=&amp;quot;url&amp;quot;&amp;gt;&amp;lt;/param&amp;gt;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; private void PermanentRedirect(string url)             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; //throw new Exception(&amp;quot;url:&amp;quot; + url);             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; HttpContext.Current.Response.Status = &amp;quot;301 Moved Permanently&amp;quot;;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; HttpContext.Current.Response.AddHeader(&amp;quot;Location&amp;quot;, url);             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;          &lt;p&gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ///&amp;#160; Change or remove the port from the url             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; private void ChangePort(Uri baseUri, Boolean useSecurePort, ref String url)             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; String portToUse = String.Empty;&lt;/p&gt;          &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // Get the current port            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; String portToFind = String.Format(&amp;quot;:{0}&amp;quot;, baseUri.Port.ToString());&lt;/p&gt;          &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if (settings != null &amp;amp;&amp;amp; settings.SecurityRemovePort)            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {             &lt;br /&gt;&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; // Config setting says to remove the port from the url so lets do that&amp;#160;&amp;#160; &lt;br /&gt;&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; url = url.Replace(portToFind, &amp;quot;&amp;quot;);             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; else             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {             &lt;br /&gt;&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; // Security setting says to leave the port in the url so we need to change it             &lt;br /&gt;&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; if (useSecurePort)             &lt;br /&gt;&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;br /&gt;&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; // If we are not on the standard port 80 we need to lookup the secure port from iis             &lt;br /&gt;&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; if (baseUri.Port != 80)             &lt;br /&gt;&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;br /&gt;&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; portToUse = LookupSecurePortFromIIS();             &lt;br /&gt;&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; String portToRepaceWith = String.Format(&amp;quot;:{0}&amp;quot;, portToUse);             &lt;br /&gt;&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; url = url.Replace(portToFind, portToRepaceWith);             &lt;br /&gt;&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;br /&gt;&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;br /&gt;&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; else             &lt;br /&gt;&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;br /&gt;&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; // If we are not on the standard secure port 443 we need to lookup the non secure port from iis             &lt;br /&gt;&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; if (baseUri.Port != 443)             &lt;br /&gt;&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;br /&gt;&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; portToUse = LookupNonSecurePortFromIIS();             &lt;br /&gt;&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; String portToRepaceWith = String.Format(&amp;quot;:{0}&amp;quot;, portToUse);             &lt;br /&gt;&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; url = url.Replace(portToFind, portToRepaceWith);             &lt;br /&gt;&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;br /&gt;&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;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;          &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; private String LookupSecurePortFromIIS()            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return LookupPortFromIIS(true);             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;          &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; private String LookupNonSecurePortFromIIS()            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return LookupPortFromIIS(false);             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;          &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// Using DirectoryServices look up in IIS the port that should be used             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// when swapping from http to https or https to http             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; private String LookupPortFromIIS(bool findHttpsPort)             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; String port = String.Empty;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; System.DirectoryServices.PropertyValueCollection serverBindings;&lt;/p&gt;          &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // Get the current website server instance            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; String websiteInstanceID = HttpContext.Current.ApplicationInstance.Request[&amp;quot;INSTANCE_ID&amp;quot;];&amp;#160; // e.g. 1646904159&lt;/p&gt;          &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // Connect to the IIS directory service for the website instance id            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; System.DirectoryServices.DirectoryEntry path = null;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if (!String.IsNullOrEmpty(settings.IISServerUsername) &amp;amp;&amp;amp; !String.IsNullOrEmpty(settings.IISServerPassword))             &lt;br /&gt;&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; path = new System.DirectoryServices.DirectoryEntry(&amp;quot;IIS://localhost/W3SVC/&amp;quot; + websiteInstanceID, settings.IISServerUsername, settings.IISServerPassword);             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; else             &lt;br /&gt;&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; path = new System.DirectoryServices.DirectoryEntry(&amp;quot;IIS://localhost/W3SVC/&amp;quot; + websiteInstanceID);&lt;/p&gt;          &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // Find the port number            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if (findHttpsPort)&amp;#160; // Get https port             &lt;br /&gt;&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; serverBindings = path.Properties[&amp;quot;SecureBindings&amp;quot;];             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; else&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; // Get http port             &lt;br /&gt;&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; serverBindings = path.Properties[&amp;quot;serverbindings&amp;quot;];&lt;/p&gt;          &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if (serverBindings.Value != null)            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {             &lt;br /&gt;&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; String bindingValue = serverBindings.Value.ToString();&lt;/p&gt;          &lt;p&gt;&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; // Just get the port number (remove everything else)            &lt;br /&gt;&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; bindingValue = bindingValue.Substring(bindingValue.IndexOf(&amp;quot;:&amp;quot;) + 1);&lt;/p&gt;          &lt;p&gt;&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; port = bindingValue.Replace(&amp;quot;:&amp;quot;, &amp;quot;&amp;quot;);            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;          &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return port;            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }             &lt;br /&gt;}&lt;/p&gt;       &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;The LookupPortFromIIS method is the one that needs the most explaining.&amp;#160; In the case when you are using non standard ports e.g. not 80 for http and not 443 for https, then in order to flip from &lt;a href=&quot;http://mydomain.com:8054&quot;&gt;http://mydomain.com:8054&lt;/a&gt; to &lt;a href=&quot;https://mydomain.com:4054&quot;&gt;https://mydomain.com:4054&lt;/a&gt; this method looks up from the IIS server what port number should be used.&amp;#160; So if you were going from http on port 8054 we would look up in IIS that we need port 4054 in order to go secure.&amp;#160; And if we were already secure we would look up that we need port 8054 to go non-secure.&amp;#160; To do this lookup into IIS we use DirectoryServices which has been tested on IIS6 and IIS7.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;And finally to support controlling which pages go secure via the web.config we need to add some configuration code. Add to this project a ‘Configuration’ directory.&amp;#160; Under the configuration directory add the following 3 classes (enums.cs, SecureWebPageFileSetting.cs and SecureWebPageSettings.cs).&lt;/p&gt; &lt;strong&gt;enums.cs&lt;/strong&gt;   &lt;br /&gt;  &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; width=&quot;100%&quot; bgcolor=&quot;#d3d3d3&quot;&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td&gt;         &lt;p&gt;namespace JL.Web.Security.Configuration            &lt;br /&gt;{             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public enum SecureWebPageMode             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// Web page security is on             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; On,&lt;/p&gt;          &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// Web page security is off             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Off             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }             &lt;br /&gt;}&lt;/p&gt;       &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;br /&gt;&lt;strong&gt;SecureWebPageFileSetting.cs&lt;/strong&gt;   &lt;br /&gt;  &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; width=&quot;100%&quot; bgcolor=&quot;#d3d3d3&quot;&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td&gt;         &lt;p&gt;namespace JL.Web.Security.Configuration            &lt;br /&gt;{             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; /// Represents an file entry in the &amp;lt;secureWebPageSettings&amp;gt;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; /// configuration section.             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public class SecureWebPageFileSetting : ConfigurationElement             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; #region Constructors             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// Creates an instance of SecureWebPageFileSetting.             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public SecureWebPageFileSetting()             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; : base()             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;          &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// Creates an instance with an initial page name.             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;param name=&amp;quot;pagename&amp;quot;&amp;gt;The page class name e.g. login (not login.aspx).&amp;lt;/param&amp;gt;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public SecureWebPageFileSetting(string pagename)             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; : this()             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Pagename = pagename;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; #endregion&lt;/p&gt;          &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// Gets or sets the path of this file setting.             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; [ConfigurationProperty(&amp;quot;pagename&amp;quot;, IsRequired = true, IsKey = true)]&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public string Pagename             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; get { return (string)this[&amp;quot;pagename&amp;quot;]; }             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; set { this[&amp;quot;pagename&amp;quot;] = value; }             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;          &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; /// Represents a collection of SecureWebPageFileSetting objects.             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public class SecureWebPageFileSettingCollection : ConfigurationElementCollection             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// Gets the element name for this collection.             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; protected override string ElementName             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; get { return &amp;quot;files&amp;quot;; }             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;          &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// Gets a flag indicating an exception should be thrown if a duplicate element             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// is added to the collection.             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; protected override bool ThrowOnDuplicate             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; get { return true; }             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;          &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// Gets the element at the specified index.             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;param name=&amp;quot;index&amp;quot;&amp;gt;The index to retrieve the element from.&amp;lt;/param&amp;gt;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;returns&amp;gt;The SecureWebPageFileSetting located at the specified index.&amp;lt;/returns&amp;gt;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public SecureWebPageFileSetting this[int index]             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; get { return (SecureWebPageFileSetting)BaseGet(index); }             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;          &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// Gets the element with the specified pagename.             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;param name=&amp;quot;pagename&amp;quot;&amp;gt;The pagename of the element to retrieve.&amp;lt;/param&amp;gt;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;returns&amp;gt;The SecureWebPageFileSetting with the specified pagename.&amp;lt;/returns&amp;gt;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public new SecureWebPageFileSetting this[string pagename]             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; get             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {             &lt;br /&gt;&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; if (pagename == null)             &lt;br /&gt;&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; throw new ArgumentNullException(&amp;quot;pagename&amp;quot;);             &lt;br /&gt;&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; else             &lt;br /&gt;&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; return (SecureWebPageFileSetting)BaseGet(pagename.ToLower(CultureInfo.InvariantCulture));             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;          &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; #region Collection Methods            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// Adds a SecureWebPageFileSetting to the collection.             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;param name=&amp;quot;fileSetting&amp;quot;&amp;gt;An initialized SecureWebPageFileSetting instance.&amp;lt;/param&amp;gt;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public void Add(SecureWebPageFileSetting fileSetting)             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; BaseAdd(fileSetting);             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;          &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// Clears all file entries from the collection.             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public void Clear()             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; BaseClear();             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;          &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// Removes a SecureWebPageFileSetting from the collection with a matching pagename as specified.             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;param name=&amp;quot;pagename&amp;quot;&amp;gt;The pagename of a SecureWebPageFileSetting to remove.&amp;lt;/param&amp;gt;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public void Remove(string pagename)             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; int Index = IndexOf(pagename);             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if (Index &amp;gt;= 0)             &lt;br /&gt;&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; BaseRemoveAt(Index);             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;          &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// Removes the SecureWebPageFileSetting from the collection at the specified index.             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;param name=&amp;quot;index&amp;quot;&amp;gt;The index of the SecureWebPageFileSetting to remove.&amp;lt;/param&amp;gt;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public void RemoveAt(int index)             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; BaseRemoveAt(index);             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; #endregion&lt;/p&gt;          &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// Creates a new element for this collection.             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;returns&amp;gt;A new instance of SecureWebPageFileSetting.&amp;lt;/returns&amp;gt;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; protected override ConfigurationElement CreateNewElement()             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return new SecureWebPageFileSetting();             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;          &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// Gets the key for the specified element.             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;param name=&amp;quot;element&amp;quot;&amp;gt;An element to get a key for.&amp;lt;/param&amp;gt;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;returns&amp;gt;A string containing the pagename of the SecureWebPageFileSetting.&amp;lt;/returns&amp;gt;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; protected override object GetElementKey(ConfigurationElement element)             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if (element != null)             &lt;br /&gt;&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; return ((SecureWebPageFileSetting)element).Pagename.ToLower(CultureInfo.InvariantCulture);             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; else             &lt;br /&gt;&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; return null;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;          &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// Returns the index of an item with the specified pagename in the collection.             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;param name=&amp;quot;pagename&amp;quot;&amp;gt;The pagename of the item to find.&amp;lt;/param&amp;gt;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;returns&amp;gt;Returns the index of the item with the pagename.&amp;lt;/returns&amp;gt;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public int IndexOf(string pagename)             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if (pagename == null)             &lt;br /&gt;&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; throw new ArgumentNullException(&amp;quot;pagename&amp;quot;);             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; else             &lt;br /&gt;&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; return this.IndexOf((SecureWebPageFileSetting)BaseGet(pagename.ToLower(CultureInfo.InvariantCulture)));             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;          &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public int IndexOf(SecureWebPageFileSetting item)            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if (item != null)             &lt;br /&gt;&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; return BaseIndexOf(item);             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; else             &lt;br /&gt;&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; return -1;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }             &lt;br /&gt;}&lt;/p&gt;       &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;br /&gt;&lt;strong&gt;SecureWebPageSettings.cs&lt;/strong&gt;   &lt;br /&gt;  &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; width=&quot;100%&quot; bgcolor=&quot;#d3d3d3&quot;&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td&gt;         &lt;p&gt;namespace JL.Web.Security.Configuration            &lt;br /&gt;{             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; /// Contains the settings of a secureWebPageSettings configuration section.             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public class SecureWebPageSettings : ConfigurationSection             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// Creates an instance of SecureWebPageSettings.             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public SecureWebPageSettings()             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; : base()             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;          &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; #region Properties            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// Gets or sets the mode indicating how the secure web page settings handled.             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; [ConfigurationProperty(&amp;quot;mode&amp;quot;, DefaultValue = SecureWebPageMode.On)]             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public SecureWebPageMode Mode             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; get { return (SecureWebPageMode)this[&amp;quot;mode&amp;quot;]; }             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; set { this[&amp;quot;mode&amp;quot;] = value; }             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;          &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// Gets the collection of file settings read from the configuration section.             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; [ConfigurationProperty(&amp;quot;files&amp;quot;)]             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public SecureWebPageFileSettingCollection Files             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; get { return (SecureWebPageFileSettingCollection)this[&amp;quot;files&amp;quot;]; }             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;          &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// Gets or sets the remove port mode.&amp;#160; This should be set to true when SSL is on a non standard port             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; [ConfigurationProperty(&amp;quot;securityRemovePort&amp;quot;, DefaultValue = false)]             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public bool SecurityRemovePort             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; get { return (bool)this[&amp;quot;securityRemovePort&amp;quot;]; }             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; set { this[&amp;quot;securityRemovePort&amp;quot;] = value; }             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;          &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// Makes all pages on the site secure, regardless of what is specified in the files section.             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; [ConfigurationProperty(&amp;quot;makeAllPagesSecure&amp;quot;, DefaultValue = false)]             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public bool MakeAllPagesSecure             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; get { return (bool)this[&amp;quot;makeAllPagesSecure&amp;quot;]; }             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; set { this[&amp;quot;makeAllPagesSecure&amp;quot;] = value; }             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;          &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// IIS Server user name use to login to directory services             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; [ConfigurationProperty(&amp;quot;iisServerUsername&amp;quot;, DefaultValue = &amp;quot;&amp;quot;)]             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public String IISServerUsername             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; get { return (String)this[&amp;quot;iisServerUsername&amp;quot;]; }             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; set { this[&amp;quot;iisServerUsername&amp;quot;] = value; }             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;          &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// IIS Server password use to login to directory services             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; [ConfigurationProperty(&amp;quot;iisServerPassword&amp;quot;, DefaultValue = &amp;quot;&amp;quot;)]             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public String IISServerPassword             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; get { return (String)this[&amp;quot;iisServerPassword&amp;quot;]; }             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; set { this[&amp;quot;iisServerPassword&amp;quot;] = value; }             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; #endregion             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }             &lt;br /&gt;}&lt;/p&gt;       &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;In our web site we configure the Http to Https flipper:&lt;/p&gt;  &lt;p&gt;Add the following line to the web.config configSections.    &lt;br /&gt;    &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; width=&quot;100%&quot; bgcolor=&quot;#d3d3d3&quot;&gt;&lt;tbody&gt;       &lt;tr&gt;         &lt;td&gt;&amp;lt;section name=&amp;quot;secureWebPageSettings&amp;quot; type=&amp;quot;JL.Web.Security.Configuration.SecureWebPageSettings, JL.Web.Security&amp;quot; /&amp;gt;&lt;/td&gt;       &lt;/tr&gt;     &lt;/tbody&gt;&lt;/table&gt; &lt;/p&gt;  &lt;p&gt;Add the following line to the web.config modules section under system.webServer.    &lt;br /&gt;    &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; width=&quot;100%&quot; bgcolor=&quot;#d3d3d3&quot;&gt;&lt;tbody&gt;       &lt;tr&gt;         &lt;td&gt;&amp;lt;add name=&amp;quot;JL.Web.Security.RequireSSLModule&amp;quot; type=&amp;quot;JL.Web.Security.RequireSSLModule&amp;quot; preCondition=&amp;quot;managedHandler&amp;quot; /&amp;gt;&lt;/td&gt;       &lt;/tr&gt;     &lt;/tbody&gt;&lt;/table&gt; &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;You can now use the ‘RequireSSLAttribute’&#39; by placing this attribute on any web form code behind page and that page will always go secure e.g.    &lt;br /&gt;    &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; width=&quot;100%&quot; bgcolor=&quot;#d3d3d3&quot;&gt;&lt;tbody&gt;       &lt;tr&gt;         &lt;td&gt;           &lt;p&gt;namespace WebApplication              &lt;br /&gt;{               &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; [RequireSSL]               &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public partial class WebForm1 : System.Web.UI.Page               &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {               &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; protected void Page_Load(object sender, EventArgs e)               &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {               &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }               &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }               &lt;br /&gt;}&lt;/p&gt;         &lt;/td&gt;       &lt;/tr&gt;     &lt;/tbody&gt;&lt;/table&gt; &lt;/p&gt;  &lt;p&gt;And in the web.config add the following to control the http to https flipper settings:    &lt;br /&gt;    &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; width=&quot;100%&quot; bgcolor=&quot;#d3d3d3&quot;&gt;&lt;tbody&gt;       &lt;tr&gt;         &lt;td&gt;           &lt;p&gt;&amp;lt;!-- SSL Configuration --&amp;gt;              &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;secureWebPageSettings mode=&amp;quot;On&amp;quot; securityRemovePort=&amp;quot;False&amp;quot; makeAllPagesSecure=&amp;quot;False&amp;quot;&amp;gt;               &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;files&amp;gt;               &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;add pagename=&amp;quot;WebForm1&amp;quot; /&amp;gt;               &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/files&amp;gt;               &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/secureWebPageSettings&amp;gt;&lt;/p&gt;         &lt;/td&gt;       &lt;/tr&gt;     &lt;/tbody&gt;&lt;/table&gt; &lt;/p&gt;  &lt;p&gt;secureWebPageSettings mode=”Off”&amp;#160;&amp;#160; - Disables the http to https flipper, which you will want to do if you are using Visual Studio’s built in web server as that does not support https.&lt;/p&gt;  &lt;p&gt;secureWebPageSettings mode =”On”&amp;#160;&amp;#160; - Enable the flipper, use this when the code is running on an IIS server.&lt;/p&gt;  &lt;p&gt;secureWebPageSettings securityRemovePort = “True”&amp;#160;&amp;#160; - This will remove the port from the URL (to be used in scenario 6 I mentioned at the top of this article).&lt;/p&gt;  &lt;p&gt;secureWebPageSettings makeAllPagesSecure = “True”&amp;#160;&amp;#160; - All pages on your site will go secure.&lt;/p&gt;  &lt;p&gt;secureWebPageSettings makeAllPagesSecure = “False”&amp;#160;&amp;#160; - Only pages using the RequireSSL attribute or those listed in the &amp;lt;files&amp;gt; section in the web.config will go secure.&amp;#160; All other pages will flip back to non-secure.&lt;/p&gt;  &lt;p&gt;In the add files section you should add a line for each page that you want to go secure.&amp;#160; The pagename is the class name of the page (as in the code behind page e.g. WebForm1)    &lt;br /&gt;    &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; width=&quot;100%&quot; bgcolor=&quot;#d3d3d3&quot;&gt;&lt;tbody&gt;       &lt;tr&gt;         &lt;td&gt;           &lt;p&gt;namespace WebApplication              &lt;br /&gt;{               &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public partial class &lt;strong&gt;WebForm1&lt;/strong&gt; : System.Web.UI.Page               &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {               &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; protected void Page_Load(object sender, EventArgs e)               &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {               &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }               &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }               &lt;br /&gt;}&lt;/p&gt;         &lt;/td&gt;       &lt;/tr&gt;     &lt;/tbody&gt;&lt;/table&gt; &lt;/p&gt;  &lt;p&gt;To test the code you will need an SSL, you can create your own on IIS6 using the SelfSSL tool that comes with the IIS6 Resource Kit that can be downloaded here: &lt;a href=&quot;http://www.microsoft.com/download/en/details.aspx?displaylang=en&amp;amp;id=17275&quot;&gt;http://www.microsoft.com/download/en/details.aspx?displaylang=en&amp;amp;id=17275&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Or on IIS7 here is a good post on setting up a self certificate: &lt;a title=&quot;http://weblogs.asp.net/scottgu/archive/2007/04/06/tip-trick-enabling-ssl-on-iis7-using-self-signed-certificates.aspx&quot; href=&quot;http://weblogs.asp.net/scottgu/archive/2007/04/06/tip-trick-enabling-ssl-on-iis7-using-self-signed-certificates.aspx&quot;&gt;http://weblogs.asp.net/scottgu/archive/2007/04/06/tip-trick-enabling-ssl-on-iis7-using-self-signed-certificates.aspx&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;And finally on IIS7 when the app pool is running in Managed Pipeline Mode = Integrated you will need to add the JL.Web.Security.RequireSSLModule to the ‘Modules’ section in IIS Manager for the website.&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuU_8wYyQPtelJZI_cR9XjBfI49sCy83gw-afMw-1dzK6WuYT2TxWtEKboeWvZ-6qy8TUlUeHhKIylbxwtGQcIYmjXI_i6bdGaVuWbfoZQp24rhqk4f2c8qyNKKm6Luus61nrjPXn41RMK/s1600-h/Modules%25255B3%25255D.gif&quot;&gt;&lt;img style=&quot;background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto; padding-top: 0px&quot; title=&quot;Modules&quot; border=&quot;0&quot; alt=&quot;Modules&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjTYiqPd_aFg5bO9QWYuIsxBp_OdszUMmhud91lRPbvdyKnUA7kSUOGjasHAa5BX8yd_f-RKCf-Wx05lgwgy_AZevvfdd_dsxygZjGxHLcfBrhNvvOxfZUxJ9j7KSmdGNZn8cIMGxUsOLRt/?imgmax=800&quot; width=&quot;761&quot; height=&quot;414&quot; /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh54fLgNPNgjnUFVuXRBn1_MLxpxEavWmUjnCJMW0Dcx-QmtjwYK_63TkxXL5F_aXW9sOWy_Esjxjjk_L-hIHr8lJUNNstqnzQLHRlQjJFtZml6BLo_WApRRLHYOsVdNUiRee4saU1pVUFN/s1600-h/AddModule%25255B4%25255D.gif&quot;&gt;&lt;img style=&quot;background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto; padding-top: 0px&quot; title=&quot;AddModule&quot; border=&quot;0&quot; alt=&quot;AddModule&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2YCUozRfCmmfkGwBxhq8TftXFjpRJpV4Szo-PcE_rP74QBMwyxksTrYfOFJpy09M38Y8K-rMf4qKmqJW3dAhbK0W0TmfcMMUKxzuoSqhbjgPn66bw6ovzjMHNse8kYVFrmEIEhgmbSOQ_/?imgmax=800&quot; width=&quot;382&quot; height=&quot;225&quot; /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Here is the &lt;a title=&quot;Http to Https Flipper (Web.Security)&quot; href=&quot;http://www.mediafire.com/?vbn7atmf407o440&quot; target=&quot;_blank&quot;&gt;source code&lt;/a&gt;&lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://jonlanceley.blogspot.com/feeds/3360253460574960998/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jonlanceley.blogspot.com/2011/07/http-to-https-flipper-for-aspnet-web.html#comment-form' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2990193854398450266/posts/default/3360253460574960998'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2990193854398450266/posts/default/3360253460574960998'/><link rel='alternate' type='text/html' href='http://jonlanceley.blogspot.com/2011/07/http-to-https-flipper-for-aspnet-web.html' title='Http to Https Flipper for Asp.Net Web Forms'/><author><name>Jon</name><uri>http://www.blogger.com/profile/03999374060620875716</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtN6KAyfs2XT5axA13YSBK6vG1fODGqFwkd7i3EgUB0JjSkFLFVaAZ4pbpaS_vohqo9WxkqepTFpoOWWpFhX_ozDe4BOvA-JHUiJlQBcVNk713PsbLK_Hj96vnzr2hHx0/s113/Me2.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDufyu7O1qCMsiRrrVPb0V2o-8WauLa9dLNUTt6Mbm_-0QajXTEjlxUzS1_sghPhltQOBagf3AQ76nNRPheb-TbqeLoPrTFpMVc9WshJKiX_WThWRrpa16DzUWZu8afMBgpbRSIHFl1GhF/s72-c?imgmax=800" height="72" width="72"/><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2990193854398450266.post-2894406884488834851</id><published>2011-06-19T08:16:00.001+00:00</published><updated>2011-06-19T08:26:22.156+00:00</updated><category scheme="http://www.blogger.com/atom/ns#" term=".Net Routing"/><category scheme="http://www.blogger.com/atom/ns#" term="Asp.Net Web Forms"/><title type='text'>Add a Permanent 301 Redirect Route Using .Net Routing 3.5</title><content type='html'>&lt;p&gt;As pages on our sites get old and replaced sometimes we need to redirect users to the newer pages.&amp;#160; You can do this in .Net Routing by setting up a new route which does a 301 (Permanent) redirect.&lt;/p&gt;  &lt;p&gt;You will need a new route handler method to do the redirect.&amp;#160; The code for this is shown below:&lt;/p&gt;  &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; bgcolor=&quot;#d3d3d3&quot;&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td&gt;         &lt;p&gt;/// &amp;lt;summary&amp;gt;            &lt;br /&gt;/// This route handler allows redirecting old urls to a new page/route name and&amp;#160; &lt;br /&gt;/// sets a permanent 301 status code (Moved Permanently)             &lt;br /&gt;/// This can be invoked from the global.asax.cs like this:             &lt;br /&gt;///&amp;#160;&amp;#160;&amp;#160;&amp;#160; The route below will redirect requests from somedirectory/A.aspx to somedirectory/login             &lt;br /&gt;///&amp;#160;&amp;#160;&amp;#160;&amp;#160; routes.Add(&amp;quot;OLDRoute1&amp;quot;, new CustomRoute(&amp;quot;somedirectory/A.aspx&amp;quot;, new PermanentRedirectRouteHandler(&amp;quot;login&amp;quot;)));             &lt;br /&gt;/// &amp;lt;/summary&amp;gt;             &lt;br /&gt;public class PermanentRedirectRouteHandler : IRouteHandler, IHttpHandler             &lt;br /&gt;{             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public PermanentRedirectRouteHandler(string virtualPath)             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; this.VirtualPath = virtualPath;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;          &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; public string VirtualPath { get; private set; }            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; private RequestContext requestContext = null;&lt;/p&gt;          &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; public IHttpHandler GetHttpHandler(RequestContext requestContext)            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; this.requestContext = requestContext;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return this;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;          &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; public bool IsReusable            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; get { return false; }             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;          &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; public void ProcessRequest(HttpContext context)            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; context.Response.StatusCode = 301;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; context.Response.AppendHeader(&amp;quot;Location&amp;quot;, VirtualPath);             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }             &lt;br /&gt;}&lt;/p&gt;       &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;While testing you might want to change the StatusCode to 302 (temporary redirect).&lt;/p&gt;  &lt;p&gt;To create a route using the PermanentRedirectRouteHandler method you would add a route like this:&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Example 1:&lt;/strong&gt;&lt;/p&gt;  &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; bgcolor=&quot;#d3d3d3&quot;&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td&gt;         &lt;p&gt;routes.Add(&amp;quot;OLDRoute1&amp;quot;, new CustomRoute(&amp;quot;A.aspx&amp;quot;, new PermanentRedirectRouteHandler(&amp;quot;login&amp;quot;)));&lt;/p&gt;       &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;The route above will redirect a request to ‘&lt;a href=&quot;http://mydomain/A.aspx&amp;rsquo;&quot;&gt;http://mydomain/A.aspx’&lt;/a&gt; to ‘&lt;a href=&quot;http://mydomain/login&quot;&gt;http://mydomain/login&lt;/a&gt;’.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Example 2:&lt;/strong&gt;&lt;/p&gt;  &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; bgcolor=&quot;#d3d3d3&quot;&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td&gt;         &lt;p&gt;routes.Add(&amp;quot;OLDRoute2&amp;quot;, new CustomRoute(&amp;quot;site1/A.aspx&amp;quot;, new PermanentRedirectRouteHandler(&amp;quot;login&amp;quot;)));&lt;/p&gt;       &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;The route above will redirect a request to ‘&lt;a href=&quot;http://mydomain/site1/A.aspx&amp;rsquo;&quot;&gt;http://mydomain/site1/A.aspx’&lt;/a&gt; to ‘&lt;a href=&quot;http://mydomain/site1/login&quot;&gt;http://mydomain/site1/login&lt;/a&gt;’.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Example 3:&lt;/strong&gt;&lt;/p&gt;  &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; bgcolor=&quot;#d3d3d3&quot;&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td&gt;         &lt;p&gt;routes.Add(&amp;quot;OLDRoute3&amp;quot;, new CustomRoute(&amp;quot;site1/B.aspx&amp;quot;, new PermanentRedirectRouteHandler(&amp;quot;/login&amp;quot;)));&lt;/p&gt;       &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;The route above will redirect a request to ‘&lt;a href=&quot;http://mydomain/site1/B.aspx&amp;rsquo;&quot;&gt;http://mydomain/site1/B.aspx’&lt;/a&gt; to ‘&lt;a href=&quot;http://mydomain/login&quot;&gt;http://mydomain/login&lt;/a&gt;’.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Example 4:&lt;/strong&gt;&lt;/p&gt;  &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; bgcolor=&quot;#d3d3d3&quot;&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td&gt;         &lt;p&gt;routes.Add(&amp;quot;OLDRoute4&amp;quot;, new CustomRoute(&amp;quot;contact-us&amp;quot;, new PermanentRedirectRouteHandler(&amp;quot;/login&amp;quot;)));&lt;/p&gt;       &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;The route above will redirect a request to ‘&lt;a href=&quot;http://mydomain/contact-us/&amp;rsquo;&quot;&gt;http://mydomain/contact-us/’&lt;/a&gt; to ‘&lt;a href=&quot;http://mydomain/login&quot;&gt;http://mydomain/login&lt;/a&gt;’.&lt;/p&gt;  &lt;p&gt;As routes are evaluated in order you should add the redirect routes to the top of your routes in the Global.asax.&lt;/p&gt;  &lt;p&gt;If you missed the first post in this series have a look at &lt;a href=&quot;http://jonlanceley.blogspot.com/2011/06/adding-net-routing-35-to-aspnet-web.html&quot; target=&quot;_blank&quot;&gt;Adding .Net Routing 3.5 to Asp.Net Web Forms&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Happy Routing!&lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://jonlanceley.blogspot.com/feeds/2894406884488834851/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jonlanceley.blogspot.com/2011/06/add-permanent-301-redirect-route-using.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2990193854398450266/posts/default/2894406884488834851'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2990193854398450266/posts/default/2894406884488834851'/><link rel='alternate' type='text/html' href='http://jonlanceley.blogspot.com/2011/06/add-permanent-301-redirect-route-using.html' title='Add a Permanent 301 Redirect Route Using .Net Routing 3.5'/><author><name>Jon</name><uri>http://www.blogger.com/profile/03999374060620875716</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtN6KAyfs2XT5axA13YSBK6vG1fODGqFwkd7i3EgUB0JjSkFLFVaAZ4pbpaS_vohqo9WxkqepTFpoOWWpFhX_ozDe4BOvA-JHUiJlQBcVNk713PsbLK_Hj96vnzr2hHx0/s113/Me2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2990193854398450266.post-7305213301521057017</id><published>2011-06-19T07:26:00.002+00:00</published><updated>2011-06-19T07:52:30.584+00:00</updated><category scheme="http://www.blogger.com/atom/ns#" term=".Net Routing"/><category scheme="http://www.blogger.com/atom/ns#" term="Asp.Net Web Forms"/><title type='text'>Route to Directories That Do Not Exist On The Disc with .Net Routing 3.5</title><content type='html'>&lt;p&gt;In my last post we added .Net Routing to web forms, you can find that post here: &lt;a href=&quot;http://jonlanceley.blogspot.com/2011/06/adding-net-routing-35-to-aspnet-web.html&quot; target=&quot;_blank&quot;&gt;Adding .Net Routing 3.5 to Asp.Net Web Forms&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;This post shows how to create a route that in the url has directories that do not exist on the disc.&amp;#160; Typically .Net will through a 404 file cannot be found error if a directory does not exist but .Net Routing allows you to say actually I’m going to accept that route because I know it maps to this location.&lt;/p&gt;  &lt;p&gt;e.g. &lt;a href=&quot;http://mydomain/site1/login/&quot;&gt;http://mydomain/site1/login/&lt;/a&gt;&amp;#160;&amp;#160; or &lt;a href=&quot;http://mydomain/site2/login&quot;&gt;http://mydomain/site2/login&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;In that example site1 &amp;amp; site2 do not exist as directories on the disc, and login is the page we want to show.&amp;#160; &lt;br /&gt;What this lets me do is have the same code running under mydomain but have different sites (which may be using different style sheets, etc).&amp;#160; The url will always look like it does above for each site, so users can easily bookmark it.&lt;/p&gt;  &lt;p&gt;This lets both sites use the same pages, without deploying the same code again or creating multiple virtual directories.&lt;/p&gt;  &lt;p&gt;How will the routes look in the Global.asax? Like this:&lt;/p&gt;  &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; bgcolor=&quot;#d3d3d3&quot;&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td&gt;public static void RegisterRoutes(RouteCollection routes)          &lt;br /&gt;{           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; // The routes:           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; routes.Add(&amp;quot;Site1Default&amp;quot;, new CustomRoute(&amp;quot;Site1&amp;quot;, new URLRouteHandler(&amp;quot;~/Login.aspx&amp;quot;)));           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; routes.Add(&amp;quot;Site2Default&amp;quot;, new CustomRoute(&amp;quot;Site2&amp;quot;, new URLRouteHandler(&amp;quot;~/Login.aspx&amp;quot;)));           &lt;br /&gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; routes.Add(“Site1” + PageIdentifier.Login.ToString(), new CustomRoute(&amp;quot;site1/login&amp;quot;, new URLRouteHandler(&amp;quot;~/Login.aspx&amp;quot;)));           &lt;br /&gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; routes.Add(“Site2” + PageIdentifier.Login.ToString(), new CustomRoute(&amp;quot;site2/login&amp;quot;, new URLRouteHandler (&amp;quot;~/Login.aspx&amp;quot;)));           &lt;br /&gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; routes.Add(“Site1” + PageIdentifier.Logout.ToString(), new CustomRoute(&amp;quot;site1/logout&amp;quot;, new URLRouteHandler(&amp;quot;~/Logout.aspx&amp;quot;)));           &lt;br /&gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; routes.Add(“Site2” + PageIdentifier.Logout.ToString(), new CustomRoute(&amp;quot;site2/logout&amp;quot;, new URLRouteHandler(&amp;quot;~/Logout.aspx&amp;quot;)));           &lt;br /&gt;} &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;The first 2 routes ‘Site1Default’ &amp;amp; ‘Site2Default’ say if a url like &lt;a href=&quot;http://mydomain/site1/%E2%80%99&quot;&gt;http://mydomain/site1/’&lt;/a&gt; is entered then by default go to the login.aspx page.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;How can I get Normal .aspx pages to work under the missing directories?&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;So far by doing the above will mean that normal aspx pages will not work with the missing site1 &amp;amp; site2 directorues e.g. &lt;a href=&quot;http://mydomain/site1/Login.aspx&amp;rsquo;&quot;&gt;http://mydomain/site1/Login.aspx’&lt;/a&gt;. This will throw a 404 file not found exception. But if you want them to work you can add a couple of extra routes at the end of your existing routes like this.&lt;/p&gt;  &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; bgcolor=&quot;#d3d3d3&quot;&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td&gt;         &lt;p&gt;routes.Add(&amp;quot;Site1ASPX&amp;quot;, new CustomRoute(&amp;quot;site1/{page}&amp;quot;, new DefaultURLRouteHandler()));&lt;/p&gt;          &lt;p&gt;routes.Add(&amp;quot;Site2ASPX&amp;quot;, new CustomRoute(&amp;quot;site2/{page}&amp;quot;, new DefaultURLRouteHandler()));&lt;/p&gt;       &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;This says everything under site1/* should be handled by the DefaultURLRouteHandler, and this route handler is expecting the {page} parameter e.g. ‘&lt;a href=&quot;http://mydomain/site1/Login.aspx&quot;&gt;http://mydomain/site1/Login.aspx&lt;/a&gt;’ in this example the {page} parameter is ‘Login.aspx’.&lt;/p&gt;  &lt;p&gt;The code for the DefaultURLRouteHandler is shown below:&lt;/p&gt;  &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; bgcolor=&quot;#d3d3d3&quot;&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td&gt;         &lt;p&gt;/// &amp;lt;summary&amp;gt;           &lt;br /&gt;/// This route handler allows standard .aspx pages to work where there are directories that do not exist on disk            &lt;br /&gt;/// e.g. somedirectory/login.aspx will reroute to login.aspx even though on disk somedirectory does not exist            &lt;br /&gt;/// This can be invoked from the global.asax.cs like this:            &lt;br /&gt;///&amp;#160;&amp;#160;&amp;#160;&amp;#160; var route = new CustomRoute(&amp;quot;somedirectory/{page}&amp;quot;, new DefaultURLRouteHandler());            &lt;br /&gt;/// &amp;lt;/summary&amp;gt;            &lt;br /&gt;public class DefaultURLRouteHandler : IRouteHandler            &lt;br /&gt;{            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public DefaultURLRouteHandler()            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;          &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; public System.Web.IHttpHandler GetHttpHandler(RequestContext requestContext)           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; string filename = requestContext.RouteData.Values[&amp;quot;page&amp;quot;] as string;&lt;/p&gt;          &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; foreach (var paramUrl in requestContext.RouteData.Values)           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; requestContext.HttpContext.Items[paramUrl.Key] = paramUrl.Value;&lt;/p&gt;          &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; try           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;font color=&quot;#ff0000&quot;&gt; var page = BuildManager.CreateInstanceFromVirtualPath(&amp;quot;~/&amp;quot; + filename, typeof(Page)) as IHttpHandler;             &lt;br /&gt;&lt;/font&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return page;            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; catch (Exception)            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; throw;            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }            &lt;br /&gt;}&lt;/p&gt;       &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;The line in red is where the magic happens.&lt;/p&gt;  &lt;p&gt;Happy routing!&lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://jonlanceley.blogspot.com/feeds/7305213301521057017/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jonlanceley.blogspot.com/2011/06/net-routing-35-route-to-directories.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2990193854398450266/posts/default/7305213301521057017'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2990193854398450266/posts/default/7305213301521057017'/><link rel='alternate' type='text/html' href='http://jonlanceley.blogspot.com/2011/06/net-routing-35-route-to-directories.html' title='Route to Directories That Do Not Exist On The Disc with .Net Routing 3.5'/><author><name>Jon</name><uri>http://www.blogger.com/profile/03999374060620875716</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtN6KAyfs2XT5axA13YSBK6vG1fODGqFwkd7i3EgUB0JjSkFLFVaAZ4pbpaS_vohqo9WxkqepTFpoOWWpFhX_ozDe4BOvA-JHUiJlQBcVNk713PsbLK_Hj96vnzr2hHx0/s113/Me2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2990193854398450266.post-1821760821842579827</id><published>2011-06-18T10:53:00.002+00:00</published><updated>2011-06-19T08:39:09.200+00:00</updated><category scheme="http://www.blogger.com/atom/ns#" term=".Net Routing"/><category scheme="http://www.blogger.com/atom/ns#" term="Asp.Net Web Forms"/><title type='text'>Adding .Net Routing 3.5 to Asp.Net Web Forms</title><content type='html'>&lt;p&gt;This article shows how to take a web forms application and enable it to use .Net Routing 3.5.&lt;/p&gt;  &lt;p&gt;Why should I do this you might ask, well as you know web forms renders urls like: &lt;a href=&quot;http://mydomain/Login.aspx&quot;&gt;http://mydomain/Login.aspx&lt;/a&gt;.&amp;#160; Which is not very friendly to a user especially when you start adding parameters.&amp;#160; &lt;/p&gt;  &lt;p&gt;Would it not be better to have the url like this: &lt;a href=&quot;http://mydomain/login/&quot;&gt;http://mydomain/login/&lt;/a&gt;. That’s nicer for the user to read and search engines will appreciate it more!&lt;/p&gt;  &lt;p&gt;You can even do things like:    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;a href=&quot;http://mydomain/log-user-in/&quot;&gt;http://mydomain/log-user-in/&lt;/a&gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;a href=&quot;http://mydomain/product/1/&quot;&gt;http://mydomain/product/1/&lt;/a&gt;&amp;#160; (which without routing would be &lt;a href=&quot;http://mydomain/Product.aspx?id=1&quot;&gt;http://mydomain/Product.aspx?id=1&lt;/a&gt;)     &lt;br /&gt;&lt;u&gt;&lt;/u&gt;&lt;/p&gt;  &lt;p&gt;&lt;u&gt;To enable .Net Routing in your web project you need to do the following:&lt;/u&gt;     &lt;br /&gt;&lt;b&gt;1.&lt;/b&gt; Add these 2 references to your web project:     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; System.Web.Routing and System.Web.Abstractions     &lt;br /&gt;Whilst System.Web.Abstractions is not needed for .Net Routing we will use it later in this post.     &lt;br /&gt;&lt;b&gt;&lt;/b&gt;    &lt;br /&gt;&lt;b&gt;2.&lt;/b&gt; Add the following to your web.config inside the &amp;lt;httpModules&amp;gt; section&lt;/p&gt;  &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; bgcolor=&quot;#d3d3d3&quot;&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td&gt;&amp;lt;!-- added to enable routing --&amp;gt;          &lt;br /&gt;&amp;lt;add name=&amp;quot;RoutingModule&amp;quot; type=&amp;quot;System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35&amp;quot;/&amp;gt; &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;e.g. &lt;/p&gt;  &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; bgcolor=&quot;#d3d3d3&quot;&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td&gt;&amp;lt;httpModules&amp;gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;add name=&amp;quot;ScriptModule&amp;quot; type=&amp;quot;System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35&amp;quot;/&amp;gt;           &lt;br /&gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;!-- added to enable routing –&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;add name=&amp;quot;RoutingModule&amp;quot; type=&amp;quot;System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35&amp;quot;/&amp;gt;           &lt;br /&gt;&amp;lt;/httpModules&amp;gt;&lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt; &lt;b&gt;&lt;/b&gt;  &lt;p&gt;&lt;b&gt;3.&lt;/b&gt; Now we need to setup the routing which is done in the Global.asax.cs file (if you do not have one you can add it by ‘Right Click –&amp;gt; Add New Item’.&lt;/p&gt;  &lt;p&gt;Add the following RegisterRoutes method to the Application_Start.    &lt;br /&gt;&lt;/p&gt;  &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; bgcolor=&quot;#d3d3d3&quot;&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td&gt;protected void Application_Start(object sender, EventArgs e)          &lt;br /&gt;{           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; // .Net Routing Start up           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; RegisterRoutes(RouteTable.Routes);           &lt;br /&gt;}&lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;Now create the RegisterRoutes method and add your routes to it like this:    &lt;br /&gt;&lt;/p&gt;  &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; bgcolor=&quot;#d3d3d3&quot;&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td&gt;public static void RegisterRoutes(RouteCollection routes)          &lt;br /&gt;{           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; // The routes:           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; routes.Add(&amp;quot;Default&amp;quot;, new CustomRoute(&amp;quot;&amp;quot;, new URLRouteHandler(&amp;quot;~/Login.aspx&amp;quot;)));           &lt;br /&gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; routes.Add(PageIdentifier.Login.ToString(), new CustomRoute(&amp;quot;login&amp;quot;, new URLRouteHandler(&amp;quot;~/Login.aspx&amp;quot;)));           &lt;br /&gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; routes.Add(PageIdentifier.Logout.ToString(), new CustomRoute(&amp;quot;logout&amp;quot;, new URLRouteHandler(&amp;quot;~/Logout.aspx&amp;quot;)));           &lt;br /&gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; routes.Add(PageIdentifier.ContactUs.ToString(), new CustomRoute(&amp;quot;contact-us&amp;quot;, new URLRouteHandler(&amp;quot;~/ContactUs.aspx&amp;quot;)));           &lt;br /&gt;} &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;To explain, the syntax of a route is essentially routes.Add(&lt;b&gt;nameOfTheRoute&lt;/b&gt;, &lt;b&gt;route&lt;/b&gt;);&lt;/p&gt;  &lt;p&gt;&lt;b&gt;nameOfTheRoute&lt;/b&gt; - is simply a string, but this is an important parameter as later on you can create a method to to find the route by using this string.&amp;#160; Which is why I like to use the PageIdentifier enum e.g.     &lt;br /&gt;&lt;/p&gt;  &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; bgcolor=&quot;#d3d3d3&quot;&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td&gt;public enum PageIdentifier : int          &lt;br /&gt;{           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Login = 1,           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Logout = 2,           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; ContactUs = 21,           &lt;br /&gt;}&lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;&lt;b&gt;route – &lt;/b&gt;this at it’s simplest contains the name of the route (which is shown in the url), and where to route to e.g. the .aspx page.&lt;/p&gt;  &lt;p&gt;Most of your routes will look something like the one below which means that ‘login’ is shown in the url (e.g. &lt;a href=&quot;http://mydomain/login%E2%80%99&quot;&gt;‘http://mydomain/login’&lt;/a&gt;) when the login.aspx page is shown.     &lt;br /&gt;&lt;/p&gt;  &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; bgcolor=&quot;#d3d3d3&quot;&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td&gt;routes.Add(PageIdentifier.Login.ToString(), new CustomRoute(&amp;quot;login&amp;quot;, new URLRouteHandler(&amp;quot;~/Login.aspx&amp;quot;))); &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;But you can also setup a default route so if now route is specified in the url (e.g. ‘&lt;a href=&quot;http://mydomain/&quot;&gt;http://mydomain/&lt;/a&gt;’) then go to the login.aspx page.&lt;/p&gt;  &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; bgcolor=&quot;#d3d3d3&quot;&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td&gt;routes.Add(&amp;quot;Default&amp;quot;, new CustomRoute(&amp;quot;&amp;quot;, new URLRouteHandler(&amp;quot;~/Login.aspx&amp;quot;))); &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;   &lt;br /&gt;&lt;b&gt;4.&lt;/b&gt; You may have noticed that we have missed something, what’s this CustomRoute and URLRouteHandler. &lt;/p&gt;  &lt;p&gt;&lt;b&gt;4.1. URLRouteHandler&lt;/b&gt;     &lt;br /&gt;In order to route our request to an .aspx page you need to create a route handler that will do this.&amp;#160; When you use the URLRouteHandler e.g.&lt;/p&gt;  &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; bgcolor=&quot;#d3d3d3&quot;&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td&gt;new URLRouteHandler(&amp;quot;~/Login.aspx&amp;quot;)&lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;the Login.aspx is the page you want displayed, the URLRouteHandler essentially creates an instance of this page and returns it.&lt;/p&gt;  &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; bgcolor=&quot;#d3d3d3&quot;&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td&gt;/// &amp;lt;summary&amp;gt;          &lt;br /&gt;/// Maps a .Net Route to an .aspx page           &lt;br /&gt;/// This can be invoked from the global.asax.cs like this:           &lt;br /&gt;/// routes.Add(&amp;quot;ContactUs&amp;quot;, new CustomRoute(&amp;quot;contact-us&amp;quot;, new URLRouteHandler(&amp;quot;~/ContactUs.aspx&amp;quot;)));           &lt;br /&gt;/// &amp;lt;/summary&amp;gt;           &lt;br /&gt;public class URLRouteHandler : IRouteHandler           &lt;br /&gt;{           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public URLRouteHandler(string virtualPath)           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; this.VirtualPath = virtualPath;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public string VirtualPath { get; private set; }           &lt;br /&gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public System.Web.IHttpHandler GetHttpHandler(RequestContext requestContext)           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; foreach (var paramUrl in requestContext.RouteData.Values)           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; requestContext.HttpContext.Items[paramUrl.Key] = paramUrl.Value;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; try           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; var page = BuildManager.CreateInstanceFromVirtualPath(VirtualPath, typeof(Page)) as IHttpHandler;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return page;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; catch (Exception)           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; throw;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;}&lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt; &lt;b&gt;&lt;/b&gt;  &lt;p&gt;   &lt;br /&gt;&lt;b&gt;4.2. CustomRoute&lt;/b&gt;     &lt;br /&gt;While you can just use the ‘Route’ class provided by .Net Routing, I found it useful to create a new CustomRoute class.&amp;#160; This class below will always render a url returned to the browser in lowercase and will append a trailing slash e.g. ‘&lt;a href=&quot;http://mydomain/login/&quot;&gt;http://mydomain/login/&lt;/a&gt;’.&amp;#160; This is useful for improving your Google search engine ranking.&lt;/p&gt;  &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; bgcolor=&quot;#d3d3d3&quot;&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td&gt;/// &amp;lt;summary&amp;gt;          &lt;br /&gt;/// Override of the .Net Routing &#39;Route&#39; class, to ensure the url returned is always lowercase and has a trailing slash.           &lt;br /&gt;/// &amp;lt;/summary&amp;gt;           &lt;br /&gt;public class CustomRoute : Route           &lt;br /&gt;{           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; #region Constructors           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public CustomRoute(string url, IRouteHandler routeHandler)           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; : base(url, routeHandler)           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public CustomRoute(string url, RouteValueDictionary defaults, IRouteHandler routeHandler)           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; : base(url, defaults, routeHandler)           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public CustomRoute(string url, RouteValueDictionary defaults, RouteValueDictionary constraints, IRouteHandler routeHandler)           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; : base(url, defaults, constraints, routeHandler)           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public CustomRoute(string url, RouteValueDictionary defaults, RouteValueDictionary constraints, RouteValueDictionary dataTokens, IRouteHandler routeHandler)           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; : base(url, defaults, constraints, dataTokens, routeHandler)           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; #endregion           &lt;br /&gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public override RouteData GetRouteData(System.Web.HttpContextBase httpContext)           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; var routeDate = base.GetRouteData(httpContext);           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return routeDate;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;&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;br /&gt;&amp;#160;&amp;#160;&amp;#160; public override VirtualPathData GetVirtualPath(RequestContext requestContext, RouteValueDictionary values)           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; VirtualPathData path = base.GetVirtualPath(requestContext, values);           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // Make sure the path returned is lowercase and has a trailing slash (SEO friendly)           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if (path != null)           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; path.VirtualPath = path.VirtualPath.ToLowerInvariant() + &amp;quot;/&amp;quot;;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return path;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;}&lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt; &lt;b&gt;&lt;/b&gt;  &lt;p&gt;   &lt;br /&gt;&lt;b&gt;5.&lt;/b&gt; Up to now the routing will work if you type the route into the url, but we also need to be able to show the routes on our website as links e.g. &amp;lt;a href=”somelinkhere”&amp;gt;click me&amp;lt;/a&amp;gt;&lt;/p&gt;  &lt;p&gt;Suppose you had this on a page:&lt;/p&gt;  &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; bgcolor=&quot;#d3d3d3&quot;&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td&gt;&amp;lt;asp:HyperLink ID=&amp;quot;LogoutHyperLink&amp;quot; runat=&amp;quot;server&amp;quot;&amp;gt;Log Out&amp;lt;/asp:HyperLink&amp;gt;&lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;and instead of the NavigateUrl being ‘Logout.aspx’ which in the browser would show up as &lt;a href=&quot;http://mydomain/Logout.aspx%E2%80%99&quot;&gt;‘http://mydomain/Logout.aspx’&lt;/a&gt; you wanted to show the route e.g. ‘&lt;a href=&quot;http://mydomain/logout/%E2%80%99&quot;&gt;http://mydomain/logout/’&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;You can do this simply by using that PageIdentifer enum I mentioned at the start of this post.&lt;/p&gt;  &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; bgcolor=&quot;#d3d3d3&quot;&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td&gt;LogoutHyperLink.NavigateUrl = LinkFactory.GetRoute(PageIdentifier.Logout.ToString());&lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;And the code for the LinkFactory class is shown below (creating this class just makes it easier to reuse later as you would want to do this for every hyperlink on your site).&lt;/p&gt;  &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; bgcolor=&quot;#d3d3d3&quot;&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td&gt;public class LinkFactory          &lt;br /&gt;{           &lt;br /&gt;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160; /// Determines the url path (route) to return based on the routeName passed in.           &lt;br /&gt;&amp;#160;&amp;#160; /// A routeName must exist in the global.asax.cs           &lt;br /&gt;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160; /// &amp;lt;param name=&amp;quot;context&amp;quot;&amp;gt;&amp;lt;/param&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160; /// &amp;lt;param name=&amp;quot;routeName&amp;quot;&amp;gt;&amp;lt;/param&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160; /// &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160; public static string GetRoute(String routeName)           &lt;br /&gt;&amp;#160;&amp;#160; {           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; var pathData = System.Web.Routing.RouteTable.Routes.GetVirtualPath(           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; null, routeName, new System.Web.Routing.RouteValueDictionary { });           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return pathData.VirtualPath;           &lt;br /&gt;&amp;#160;&amp;#160; }           &lt;br /&gt;}&lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;One final point, is all your existing .aspx pages will continue to work as they do today because .Net routing only kicks in when a page cannot be found on disc.&lt;/p&gt;  &lt;p&gt;Here is the &lt;a href=&quot;http://www.mediafire.com/?9zt97i1fe7ddmm7&quot; target=&quot;_blank&quot;&gt;source code&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;That’s it, happy routing!&lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://jonlanceley.blogspot.com/feeds/1821760821842579827/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jonlanceley.blogspot.com/2011/06/adding-net-routing-35-to-aspnet-web.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2990193854398450266/posts/default/1821760821842579827'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2990193854398450266/posts/default/1821760821842579827'/><link rel='alternate' type='text/html' href='http://jonlanceley.blogspot.com/2011/06/adding-net-routing-35-to-aspnet-web.html' title='Adding .Net Routing 3.5 to Asp.Net Web Forms'/><author><name>Jon</name><uri>http://www.blogger.com/profile/03999374060620875716</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtN6KAyfs2XT5axA13YSBK6vG1fODGqFwkd7i3EgUB0JjSkFLFVaAZ4pbpaS_vohqo9WxkqepTFpoOWWpFhX_ozDe4BOvA-JHUiJlQBcVNk713PsbLK_Hj96vnzr2hHx0/s113/Me2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2990193854398450266.post-5882346931134208377</id><published>2011-06-12T09:06:00.001+00:00</published><updated>2011-07-03T08:27:34.965+00:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Asp.Net MVC3"/><title type='text'>MVC3 RadioButtonList Helper</title><content type='html'>&lt;p&gt;An MVC 3 example which uses the Radio Button helper twice on a page to create 3 radio buttons with the first radio button helper and 2 radio buttons with the 2nd helper.&amp;#160; Both have validation to ensure 1 option is selected. And if the form fails validation the chosen radio option is preselected when the form is reshown.&lt;/p&gt;  &lt;p&gt;The radio buttons can be shown on the page horizontally or vertically.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;The Html Helper Method&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Essentially all this helper does is loop round a list that you provide it and for each item in the list creates a html radio button and a label for it.&lt;/p&gt;  &lt;p&gt;I created a new class with the following code:&lt;/p&gt;  &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; width=&quot;100%&quot; bgcolor=&quot;#d3d3d3&quot;&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td&gt;         &lt;p&gt;using System;           &lt;br /&gt;using System.Collections.Generic;            &lt;br /&gt;using System.Linq;            &lt;br /&gt;using System.Web;            &lt;br /&gt;using System.Web.Mvc;            &lt;br /&gt;using System.Web.Mvc.Html;            &lt;br /&gt;using System.Linq.Expressions;            &lt;br /&gt;using System.Text;&lt;/p&gt;          &lt;p&gt;namespace MVC3_RadioButtonList_Helper_Sample           &lt;br /&gt;{            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public static class HtmlExtensions            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public static MvcHtmlString RadioButtonForSelectList&amp;lt;TModel, TProperty&amp;gt;(            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; this HtmlHelper&amp;lt;TModel&amp;gt; htmlHelper,            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Expression&amp;lt;Func&amp;lt;TModel, TProperty&amp;gt;&amp;gt; expression,            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; IEnumerable&amp;lt;SelectListItem&amp;gt; listOfValues)            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; var metaData = ModelMetadata.FromLambdaExpression(expression, htmlHelper.ViewData);            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; var sb = new StringBuilder();&lt;/p&gt;          &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if (listOfValues != null)           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {            &lt;br /&gt;&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; // Create a radio button for each item in the list            &lt;br /&gt;&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; foreach (SelectListItem item in listOfValues)            &lt;br /&gt;&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;br /&gt;&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; // Generate an id to be given to the radio button field            &lt;br /&gt;&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; var id = string.Format(&amp;quot;{0}_{1}&amp;quot;, metaData.PropertyName, item.Value);&lt;/p&gt;          &lt;p&gt;&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; // Create and populate a radio button using the existing html helpers           &lt;br /&gt;&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; var label = htmlHelper.Label(id, HttpUtility.HtmlEncode(item.Text));            &lt;br /&gt;&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; var radio = htmlHelper.RadioButtonFor(expression, item.Value, new { id = id }).ToHtmlString();&lt;/p&gt;          &lt;p&gt;&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; // Create the html string that will be returned to the client           &lt;br /&gt;&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; // e.g. &amp;lt;input data-val=&amp;quot;true&amp;quot; data-val-required=&amp;quot;You must select an option&amp;quot; id=&amp;quot;TestRadio_1&amp;quot; name=&amp;quot;TestRadio&amp;quot; type=&amp;quot;radio&amp;quot; value=&amp;quot;1&amp;quot; /&amp;gt;&amp;lt;label for=&amp;quot;TestRadio_1&amp;quot;&amp;gt;Line1&amp;lt;/label&amp;gt;            &lt;br /&gt;&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; sb.AppendFormat(&amp;quot;&amp;lt;div class=\&amp;quot;RadioButton\&amp;quot;&amp;gt;{0}{1}&amp;lt;/div&amp;gt;&amp;quot;, radio, label);            &lt;br /&gt;&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;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;          &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return MvcHtmlString.Create(sb.ToString());           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }            &lt;br /&gt;}&lt;/p&gt;       &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;I’ve added a div around the radio button and it’s label with a class of ‘RadioButton’, this will let you in CSS position the radio button either vertically or horizontally.&amp;#160; The default is vertically:&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjs48WyIaQ1uYUtiIQklclkiw0_hU_YE31wdp6-mfbLXouMBUK7AArsgG0iHV9NK_AtFOkaMgLQrlfJtUBa3wDOJp2Q5uyoG5HLyGnLEgTtKXFJx2i3XHSHH_aLv57RKX8GLpd5wcE7KG6d/s1600-h/InitialPage%25255B3%25255D.gif&quot;&gt;&lt;img style=&quot;background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px&quot; title=&quot;InitialPage&quot; border=&quot;0&quot; alt=&quot;InitialPage&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0618gaHQjPOGdbwHsc-KSljaeQZr4kZilVhH65bNBIHJjv5i_d8ERM2EDQ9mI1Gveu2-PlXej1_sLDft0Et78RDCPoCX-OLO8v1mA7EKo4gRBs_D8mIIW0LF8kQfw572GzVi3luoR1hjF/?imgmax=800&quot; width=&quot;138&quot; height=&quot;272&quot; /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;But you can switch this to horizontal with a bit of CSS &lt;/p&gt;  &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; width=&quot;100%&quot; bgcolor=&quot;#d3d3d3&quot;&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td&gt;         &lt;p&gt;.RadioButton { float:left; }&lt;/p&gt;       &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgs1tmgPP2U-jGjNy2pvDQeOoBYjocHIkuIJ1ShMjeXqO9o8dl497n9fzsADNPTV-joIgNV4_1yEQTP7UYGn27tcBQB0egs6A6IzGi8t0ahTLDhF_z440-YpyN2c46VzvWlRvmNtv1Wb1Ce/s1600-h/InitialPageAsHorizontal%25255B3%25255D.gif&quot;&gt;&lt;img style=&quot;background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px&quot; title=&quot;InitialPageAsHorizontal&quot; border=&quot;0&quot; alt=&quot;InitialPageAsHorizontal&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhN8hnxysgLcCqctIX74L8K3sZSby9D1U3buwxIiuQCPHEq34IV8ToppZJUow7FXS6CCdg7fDb6KPGGKnutf9YjNXGc9xnyGXDadYPzueDGVFwQRGadrG0Ql31ukV18BP7BWwVUAC_g2jcr/?imgmax=800&quot; width=&quot;210&quot; height=&quot;260&quot; /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;The rest of this article shows how to use the RadioButtonForSelectList helper, you reference it in a view like this: @Html.RadioButtonForSelectList(m =&amp;gt; m.TestRadio, Model.TestRadioList) &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;The Model&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;For this example I just created an empty MVC3 application and added this model.&lt;/p&gt;  &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; width=&quot;100%&quot; bgcolor=&quot;#d3d3d3&quot;&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td&gt;         &lt;p&gt;using System;           &lt;br /&gt;using System.Collections.Generic;            &lt;br /&gt;using System.Linq;            &lt;br /&gt;using System.Web;            &lt;br /&gt;using System.ComponentModel.DataAnnotations;            &lt;br /&gt;using System.Web.Mvc;&lt;/p&gt;          &lt;p&gt;namespace MVC3_RadioButtonList_Helper_Sample.Models           &lt;br /&gt;{            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public class IndexViewModel            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public IEnumerable&amp;lt;SelectListItem&amp;gt; TestRadioList { get; set; }            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public IEnumerable&amp;lt;SelectListItem&amp;gt; TestRadioList2 { get; set; }&lt;/p&gt;          &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; [Required(ErrorMessage = &amp;quot;You must select an option for TestRadio&amp;quot;)]           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public String TestRadio { get; set; }&lt;/p&gt;          &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; [Required(ErrorMessage = &amp;quot;You must select an option for TestRadio2&amp;quot;)]           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public String TestRadio2 { get; set; }            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;          &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; public class aTest           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public Int32 ID { get; set; }            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public String Name { get; set; }            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }            &lt;br /&gt;}&lt;/p&gt;       &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;&lt;strong&gt;The Controller Action&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;I added the following to my controller to populate the model with 2 different lists one for each of the radio button helpers.&amp;#160; The first radio button help also has a default value set so the middle option (‘Line2’) will be pre-selected.&lt;/p&gt;  &lt;p&gt;I also changed the Index HttpPost method so that if validation fails the same list of radio buttons is added to the model (obviously I have duplicated the list creation code, in a live example you should create a common function).&lt;/p&gt;  &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; width=&quot;100%&quot; bgcolor=&quot;#d3d3d3&quot;&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td&gt;         &lt;p&gt;using System;           &lt;br /&gt;using System.Collections.Generic;            &lt;br /&gt;using System.Linq;            &lt;br /&gt;using System.Web;            &lt;br /&gt;using System.Web.Mvc;            &lt;br /&gt;using MVC3_RadioButtonList_Helper_Sample.Models;&lt;/p&gt;          &lt;p&gt;namespace MVC3_RadioButtonList_Helper_Sample.Controllers           &lt;br /&gt;{            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public class TestController : Controller            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; //            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // GET: /Test/            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public ActionResult Index()            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; List&amp;lt;aTest&amp;gt; list = new List&amp;lt;aTest&amp;gt;();            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; list.Add(new aTest() { ID = 1, Name = &amp;quot;Line1&amp;quot; });            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; list.Add(new aTest() { ID = 2, Name = &amp;quot;Line2&amp;quot; });            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; list.Add(new aTest() { ID = 3, Name = &amp;quot;Line3&amp;quot; });            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; SelectList sl = new SelectList(list, &amp;quot;ID&amp;quot;, &amp;quot;Name&amp;quot;);&lt;/p&gt;          &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; List&amp;lt;aTest&amp;gt; list2 = new List&amp;lt;aTest&amp;gt;();           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; list2.Add(new aTest() { ID = 1, Name = &amp;quot;test1&amp;quot; });            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; list2.Add(new aTest() { ID = 2, Name = &amp;quot;test2&amp;quot; });            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; SelectList sl2 = new SelectList(list2, &amp;quot;ID&amp;quot;, &amp;quot;Name&amp;quot;);&lt;/p&gt;          &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; var model = new IndexViewModel();           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; model.TestRadioList = sl;            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; model.TestRadioList2 = sl2;            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; model.TestRadio = &amp;quot;2&amp;quot;;&amp;#160; // Set a default value for the first radio button helper&lt;/p&gt;          &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return View(model);           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;          &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; [HttpPost]           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public ActionResult Index(IndexViewModel model, string returnUrl)            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if (ModelState.IsValid)            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {            &lt;br /&gt;&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; ModelState.AddModelError(&amp;quot;&amp;quot;, &amp;quot;Always force an error to be raised so we can test the postback sets the radio buttons to their last values.&amp;quot;);            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;          &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // If we got this far, something failed, redisplay form           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; List&amp;lt;aTest&amp;gt; list = new List&amp;lt;aTest&amp;gt;();            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; list.Add(new aTest() { ID = 1, Name = &amp;quot;Line1&amp;quot; });            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; list.Add(new aTest() { ID = 2, Name = &amp;quot;Line2&amp;quot; });            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; list.Add(new aTest() { ID = 3, Name = &amp;quot;Line3&amp;quot; });            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; SelectList sl = new SelectList(list, &amp;quot;ID&amp;quot;, &amp;quot;Name&amp;quot;);&lt;/p&gt;          &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; List&amp;lt;aTest&amp;gt; list2 = new List&amp;lt;aTest&amp;gt;();           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; list2.Add(new aTest() { ID = 1, Name = &amp;quot;test1&amp;quot; });            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; list2.Add(new aTest() { ID = 2, Name = &amp;quot;test2&amp;quot; });            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; SelectList sl2 = new SelectList(list2, &amp;quot;ID&amp;quot;, &amp;quot;Name&amp;quot;);&lt;/p&gt;          &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; model.TestRadioList = sl;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; model.TestRadioList2 = sl2;&lt;/p&gt;          &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return View(model);           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }            &lt;br /&gt;}            &lt;br /&gt;&lt;/p&gt;       &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;&lt;strong&gt;The View&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;To test the html helper I added a view that is bound to the IndexViewModel.&lt;/p&gt;  &lt;p&gt;I added a using statement so the helper method would be found by intelisence @using MVC3_RadioButtonList_Helper_Sample&lt;/p&gt;  &lt;p&gt;I added the new helper RadioButtonForSelectList and passed in the TestRadio property from the IndexViewModel which is where the selected result will be put (the radio button ID value e.g. 2). &lt;/p&gt;  &lt;p&gt;And the TestRadioList which is a list of SelectListItems for which a radio button will be created for each item in the list.&lt;/p&gt;  &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; width=&quot;100%&quot; bgcolor=&quot;#d3d3d3&quot;&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td&gt;@Html.RadioButtonForSelectList(m =&amp;gt; m.TestRadio, Model.TestRadioList)          &lt;br /&gt;@Html.ValidationMessageFor(m =&amp;gt; m.TestRadio)&lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;So the error message (as specified in the model ‘TestRadio’ property is shown when no radio button is selected I added a validation message helper.&lt;/p&gt;      &lt;p&gt;I then added a 2nd radio button helper to the form like this, which is bound to a different list and it’s return value will be in TestRadio2.&lt;/p&gt;  &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; width=&quot;100%&quot; bgcolor=&quot;#d3d3d3&quot;&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td&gt;         &lt;p&gt;@Html.RadioButtonForSelectList(m =&amp;gt; m.TestRadio2, Model.TestRadioList2)           &lt;br /&gt;@Html.ValidationMessageFor(m =&amp;gt; m.TestRadio2)&lt;/p&gt;       &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;The form below shows the validation in action:&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJ-OBS_3asrqhxn_MS-UiT97b66nZRi9sf8DSoPyEGpV6k398B8xbAL_N4pd-M8iB4_mc_0Q4cxD735Z9LD5KafUCKADgEy1KjWn3A700TwolNPz2tACZzp56XNH0x7kiv_fnGOcBj7uoL/s1600-h/ValidationAtWork%25255B3%25255D.gif&quot;&gt;&lt;img style=&quot;background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px&quot; title=&quot;ValidationAtWork&quot; border=&quot;0&quot; alt=&quot;ValidationAtWork&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh8vD-lg4elxW9JNZkbrlg-eaxanHMAOcyEz4hh8a5PzZHr9NKOv_DO8-1QjwjCPE2iZvhhJiFlpuDlcP7IT0Bm9oi8WpOGIH7aTqACvJDKhM8UKIzv3ozwO72oMm_nxeJd54gxNi3moI-I/?imgmax=800&quot; width=&quot;494&quot; height=&quot;280&quot; /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Here is the &lt;a title=&quot;MVC3 RadioButtonList Helper&quot; href=&quot;http://www.mediafire.com/?2w67qr886efpflr&quot; target=&quot;_blank&quot;&gt;source code&lt;/a&gt;.&lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://jonlanceley.blogspot.com/feeds/5882346931134208377/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jonlanceley.blogspot.com/2011/06/mvc3-radiobuttonlist-helper.html#comment-form' title='19 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2990193854398450266/posts/default/5882346931134208377'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2990193854398450266/posts/default/5882346931134208377'/><link rel='alternate' type='text/html' href='http://jonlanceley.blogspot.com/2011/06/mvc3-radiobuttonlist-helper.html' title='MVC3 RadioButtonList Helper'/><author><name>Jon</name><uri>http://www.blogger.com/profile/03999374060620875716</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtN6KAyfs2XT5axA13YSBK6vG1fODGqFwkd7i3EgUB0JjSkFLFVaAZ4pbpaS_vohqo9WxkqepTFpoOWWpFhX_ozDe4BOvA-JHUiJlQBcVNk713PsbLK_Hj96vnzr2hHx0/s113/Me2.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0618gaHQjPOGdbwHsc-KSljaeQZr4kZilVhH65bNBIHJjv5i_d8ERM2EDQ9mI1Gveu2-PlXej1_sLDft0Et78RDCPoCX-OLO8v1mA7EKo4gRBs_D8mIIW0LF8kQfw572GzVi3luoR1hjF/s72-c?imgmax=800" height="72" width="72"/><thr:total>19</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2990193854398450266.post-4373163846837447176</id><published>2010-01-13T18:28:00.001+00:00</published><updated>2010-01-13T18:28:59.018+00:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="JQuery"/><title type='text'>How to Add Parameters and Callback Functions to Your JQuery Plugins</title><content type='html'>&lt;p&gt;Today I am going to expand on the AlertMe plugin I created in the &lt;a title=&quot;Create Your First JQuery Plugin&quot; href=&quot;http://jonlanceley.blogspot.com/2010/01/create-your-first-jquery-plugin.html&quot;&gt;last article&lt;/a&gt;.&amp;#160; I will show you how to pass parameters into the plugin, and show you how to create a callback handler for your JQuery plugin. &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;1.&lt;/strong&gt;&amp;#160; Parameters can be entered one after the other as part of the function method call e.g. jQuery.fn.AlertMe = function(param1, param2, etc).&lt;/p&gt;  &lt;p&gt;But then you have to specify all those parameters when calling the function which is a problem when some of the parameters are optional!.&amp;#160; &lt;/p&gt;  &lt;p&gt;Instead what I prefer is creating a function in the plugin which will contain all the parameters.&amp;#160; It also allows setting each parameter to a default value which can later be changed/overridden by the calling client code.&lt;/p&gt;  &lt;p&gt;Below is the plugin function, note it has the same name as the main plugin code but has .defaults appended to it.&lt;/p&gt;  &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; width=&quot;100%&quot; bgcolor=&quot;#d3d3d3&quot;&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign=&quot;top&quot;&gt;jQuery.fn.AlertMe.defaults = {&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; alertText: &#39;AlertMe default text&#39;,&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; onAlert: function(alertText) { }&amp;#160; &lt;br /&gt;}; &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;The alertText line has a default set of ‘AlertMe default text’ which will be displayed in the alert box.&lt;/p&gt;  &lt;p&gt;And onAlert is a function that allows the client to specify a function that will run when the alert box is shown.    &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;2.&lt;/strong&gt; Below is the full code for the AlertMe plugin.&amp;#160; As before I placed this code in a file called ‘jquery.AlertMe.js’.&lt;/p&gt;  &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; width=&quot;100%&quot; bgcolor=&quot;#d3d3d3&quot;&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign=&quot;top&quot;&gt;(function($) {          &lt;br /&gt;&amp;#160;&amp;#160; jQuery.fn.AlertMe = function(options)           &lt;br /&gt;&amp;#160;&amp;#160; {           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; var opts = jQuery.extend({}, jQuery.fn.AlertMe.defaults, options);           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; var alertText = opts.alertText;           &lt;br /&gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; function doAlert()           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; alert( alertText );           &lt;br /&gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // Callback Handler to allow client to run some code when the alert is shown           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if (typeof opts.onAlert == &#39;function&#39;) {           &lt;br /&gt;&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; var callbackAlertText = alertText + &#39; and then changed by doAlert function callback&#39;;           &lt;br /&gt;&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; opts.onAlert.call(this, callbackAlertText);           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return this.each(function() {           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; doAlert();           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; });           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; };           &lt;br /&gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; // plugin defaults           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; jQuery.fn.AlertMe.defaults = {           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; alertText: &#39;AlertMe default text&#39;,           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; onAlert: function(alertText) { }           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; };           &lt;br /&gt;})(jQuery); &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;And below is the client html code.&lt;/p&gt;  &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; width=&quot;100%&quot; bgcolor=&quot;#d3d3d3&quot;&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign=&quot;top&quot;&gt;         &lt;p&gt;&amp;lt;html&amp;gt;            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;head&amp;gt;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;script src=&amp;quot;jquery-1.3.2.js&amp;quot; type=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;script src=&amp;quot;jquery.AlertMe.js&amp;quot; type=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/script&amp;gt; &lt;/p&gt;          &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; $(document).ready(function()             &lt;br /&gt;&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;br /&gt;&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; var myoptions = {             &lt;br /&gt;&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; alertText: &#39;AlertMe changed by client&#39;,             &lt;br /&gt;            &lt;br /&gt;&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; onAlert: function(alertText) {             &lt;br /&gt;&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; alert(alertText);             &lt;br /&gt;&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;br /&gt;&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;/p&gt;          &lt;p&gt;&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;quot;div&amp;quot;).AlertMe(myoptions);            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; });             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/script&amp;gt;             &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/head&amp;gt; &lt;/p&gt;          &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;body&amp;gt;            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;h1&amp;gt;Test&amp;lt;/h1&amp;gt; &lt;/p&gt;          &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;div&amp;gt;&amp;lt;/div&amp;gt;            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/body&amp;gt;             &lt;br /&gt;&amp;lt;/html&amp;gt;&lt;/p&gt;       &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;The main part of the above code is the part shown below:&lt;/p&gt;  &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; width=&quot;100%&quot; bgcolor=&quot;#d3d3d3&quot;&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign=&quot;top&quot;&gt;         &lt;p&gt;var myoptions = {&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; alertText: &#39;AlertMe changed by client&#39;,&amp;#160; &lt;br /&gt;            &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; onAlert: function(alertText) {&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; alert(alertText);&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }&amp;#160; &lt;br /&gt; } &lt;/p&gt;       &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;This is where we can change the default parameter values and setup our functions to handle the callback’s provided in the plugin.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;3.&lt;/strong&gt; When you run this code in a web browser a couple of alert boxes will be shown.&lt;/p&gt;  &lt;p&gt;The first alert box will say: ‘AlertMe changed by client’.&amp;#160; This is because I set the alertText option.&amp;#160; If I had not set the alertText option the default message of ‘AlertMe default text’ would have been shown.&lt;/p&gt;  &lt;p&gt;The second alert box will say:    &lt;br /&gt;&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; ‘AlertMe changed by client and then changed by doAlert function callback’.&amp;#160; &lt;/p&gt;  &lt;p&gt;The second alert box says this because the client has subscribed to the onAlert callback function and inside the plugin when the alert is shown the text returned by the onAlert function is changed which for this demo helps us see that the callback is working.&lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://jonlanceley.blogspot.com/feeds/4373163846837447176/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jonlanceley.blogspot.com/2010/01/how-to-add-parameters-and-callback.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2990193854398450266/posts/default/4373163846837447176'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2990193854398450266/posts/default/4373163846837447176'/><link rel='alternate' type='text/html' href='http://jonlanceley.blogspot.com/2010/01/how-to-add-parameters-and-callback.html' title='How to Add Parameters and Callback Functions to Your JQuery Plugins'/><author><name>Jon</name><uri>http://www.blogger.com/profile/03999374060620875716</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtN6KAyfs2XT5axA13YSBK6vG1fODGqFwkd7i3EgUB0JjSkFLFVaAZ4pbpaS_vohqo9WxkqepTFpoOWWpFhX_ozDe4BOvA-JHUiJlQBcVNk713PsbLK_Hj96vnzr2hHx0/s113/Me2.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2990193854398450266.post-5469499816720567010</id><published>2010-01-06T18:34:00.001+00:00</published><updated>2010-01-13T17:10:51.811+00:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="JQuery"/><title type='text'>Create Your First JQuery Plugin</title><content type='html'>&lt;p&gt;This article will show you how to create a simple JQuery plugin.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;1.&lt;/strong&gt; To create a jQuery plugin you should:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Name the script file as jquery.YourPluginName.js e.g. jquery.AlertMe.js. &lt;/li&gt;    &lt;li&gt;Your function must end with a semi-colon. &lt;/li&gt;    &lt;li&gt;You should use this.each as it produces compatible code. &lt;/li&gt;    &lt;li&gt;You should not use $ within the plugin unless it is aliased, you should use jQuery instead. &lt;/li&gt;    &lt;li&gt;Variables should be initialised using the var keyword. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;strong&gt;2.&lt;/strong&gt; Below is a very simple jQuery plugin.&lt;/p&gt;  &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; width=&quot;100%&quot; bgcolor=&quot;#d3d3d3&quot;&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign=&quot;top&quot;&gt;(function($) {          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; jQuery.fn.AlertMe = function() {           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return this.each(function() {           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; alert(“AlertMe”);           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; });           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; };           &lt;br /&gt;})(jQuery); &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;&lt;strong&gt;3. &lt;/strong&gt;Using a function within a JQuery plugin.&amp;#160; Below i’ve added a doAlert() function.&lt;/p&gt;  &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; width=&quot;100%&quot; bgcolor=&quot;#d3d3d3&quot;&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign=&quot;top&quot;&gt;(function($) {          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; jQuery.fn.AlertMe = function()           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; function doAlert()           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; alert(“AlertMe”);           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return this.each(function() {           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; doAlert();           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; });           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; };           &lt;br /&gt;})(jQuery);&lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;&lt;strong&gt;4. &lt;/strong&gt;Using variables within a JQuery plugin.&amp;#160; Variables should be initialised using the var keyword.&lt;/p&gt;  &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; width=&quot;100%&quot; bgcolor=&quot;#d3d3d3&quot;&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign=&quot;top&quot;&gt;(function($) {          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; jQuery.fn.AlertMe = function()           &lt;br /&gt;&amp;#160;&amp;#160; {           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; var alertText = “AlertMe”;           &lt;br /&gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; function doAlert()           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; alert( alertText );           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return this.each(function() {           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; doAlert();           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; });           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; };           &lt;br /&gt;})(jQuery);&lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;&lt;strong&gt;5. &lt;/strong&gt;Your JQuery plugin can then be called from a web page like this:&lt;/p&gt;  &lt;p&gt;Reference the JQuery library and your plugin script files in the &amp;lt;head&amp;gt; section of your page like so:&lt;/p&gt;  &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; width=&quot;100%&quot; bgcolor=&quot;#d3d3d3&quot;&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign=&quot;top&quot;&gt;&amp;lt;script src=&amp;quot;Scripts/jquery-1.3.2.js&amp;quot; type=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;          &lt;br /&gt;&amp;lt;script src=&amp;quot;Scripts/jquery.AlertMe.js&amp;quot; type=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;And on your web page you can use the plugin like this:&lt;/p&gt;  &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; width=&quot;100%&quot; bgcolor=&quot;#d3d3d3&quot;&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign=&quot;top&quot;&gt;$(&amp;quot;div&amp;quot;).AlertMe(); &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;A bigger example of using the plugin from a web page:&lt;/p&gt;  &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; width=&quot;100%&quot; bgcolor=&quot;#d3d3d3&quot;&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign=&quot;top&quot;&gt;&amp;lt;html&amp;gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;head&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;script src=&amp;quot;jquery-1.3.2.js&amp;quot; type=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;script src=&amp;quot;jquery.AlertMe.js&amp;quot; type=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;           &lt;br /&gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; $(document).ready(function() {           &lt;br /&gt;&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;quot;div&amp;quot;).AlertMe();           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; });           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/script&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/head&amp;gt;           &lt;p&gt;&lt;/p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;body&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;h1&amp;gt;Alert Me JQuery Web Page Example&amp;lt;/h1&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;div&amp;gt;&amp;lt;/div&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/body&amp;gt;           &lt;br /&gt;&amp;lt;/html&amp;gt; &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;This will attach the ‘AlertMe’ plugin to every div element on the page.&amp;#160; So for example if you had 2 divs you would see 2 alert boxes displayed.&lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://jonlanceley.blogspot.com/feeds/5469499816720567010/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jonlanceley.blogspot.com/2010/01/create-your-first-jquery-plugin.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2990193854398450266/posts/default/5469499816720567010'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2990193854398450266/posts/default/5469499816720567010'/><link rel='alternate' type='text/html' href='http://jonlanceley.blogspot.com/2010/01/create-your-first-jquery-plugin.html' title='Create Your First JQuery Plugin'/><author><name>Jon</name><uri>http://www.blogger.com/profile/03999374060620875716</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtN6KAyfs2XT5axA13YSBK6vG1fODGqFwkd7i3EgUB0JjSkFLFVaAZ4pbpaS_vohqo9WxkqepTFpoOWWpFhX_ozDe4BOvA-JHUiJlQBcVNk713PsbLK_Hj96vnzr2hHx0/s113/Me2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2990193854398450266.post-6951082344352676029</id><published>2009-12-22T17:57:00.003+00:00</published><updated>2011-06-19T08:36:02.744+00:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Asp.Net MVC"/><category scheme="http://www.blogger.com/atom/ns#" term="Asp.Net Web Forms"/><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="WCF"/><title type='text'>Convert Exceptions in WCF Services to Fault Exceptions a Client Can Use</title><content type='html'>&lt;p&gt;This article will show you how to trap an exception that occurs within a WCF service but also inform the client application of the exception so it can be handled.&amp;#160; To do this we will make use of a custom faultException.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;1.&lt;/b&gt; You need to create a fault contract for the type of fault that you want to be returned to the client via WCF.&amp;#160; Below I have created a ‘DBConcurrencyFault’ fault that tells the client when a database concurrency violation has occurred (e.g. 2 people tried to save the same record). &lt;/p&gt;  &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; bgcolor=&quot;#d3d3d3&quot;&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign=&quot;top&quot;&gt;namespace Common.Services.Faults          &lt;br /&gt;{           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; [DataContract]           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public class DBConcurrencyFault           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; [DataMember]           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public String Message { get; set; }           &lt;br /&gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; [DataMember]           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public String ExceptionType { get; set; }           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;}&lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;&lt;b&gt;2.&lt;/b&gt; Now we are going to create a new attribute that we can use to decorate our service classes with.&amp;#160; This attribute will trap any exception occurring in a WCF service and convert them into a specific fault exception.&lt;/p&gt;  &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; bgcolor=&quot;#d3d3d3&quot;&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign=&quot;top&quot;&gt;namespace Common.Services          &lt;br /&gt;{           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public class WcfErrorHandler : Attribute, IErrorHandler, IServiceBehavior           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public bool HandleError(Exception error)           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return false;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public void ProvideFault(Exception error, System.ServiceModel.Channels.MessageVersion version, ref System.ServiceModel.Channels.Message fault)           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if (fault != null)           &lt;br /&gt;&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; return;           &lt;br /&gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if (error.GetType() == typeof(System.Data.DBConcurrencyException))&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {           &lt;br /&gt;&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; // Handle Database record being written to by different users (Conncurrency Fault)           &lt;br /&gt;&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; DBConcurrencyFault databaseConcurrencyFault = new DBConcurrencyFault();           &lt;br /&gt;&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; databaseConcurrencyFault.Message = error.Message;           &lt;br /&gt;&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; databaseConcurrencyFault.ExceptionType = error.GetType().ToString();           &lt;br /&gt;&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; String faultReason = &amp;quot;Someone else has already saved this record.&amp;quot;;           &lt;br /&gt;&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; FaultException&amp;lt;DBConcurrencyFault&amp;gt; faultException = new FaultException&amp;lt;DBConcurrencyFault&amp;gt;(databaseConcurrencyFault, faultReason);           &lt;br /&gt;&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; MessageFault messageFault = faultException.CreateMessageFault();           &lt;br /&gt;&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; fault = Message.CreateMessage(version, messageFault, faultException.Action);           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; else           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {           &lt;br /&gt;&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; // Handle all other errors as standard FaultExceptions           &lt;br /&gt;&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; FaultException faultException = new FaultException(error.Message);           &lt;br /&gt;&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; MessageFault messageFault = faultException.CreateMessageFault();           &lt;br /&gt;&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; fault = Message.CreateMessage(version, messageFault, faultException.Action);           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; #region IServiceBehavior Members           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public void AddBindingParameters(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase, System.Collections.ObjectModel.Collection&amp;lt;ServiceEndpoint&amp;gt; endpoints, BindingParameterCollection bindingParameters)           &lt;br /&gt;&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;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public void ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; foreach (ChannelDispatcher disp in serviceHostBase.ChannelDispatchers)           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {           &lt;br /&gt;&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; disp.ErrorHandlers.Add(this);           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public void Validate(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)           &lt;br /&gt;&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;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; #endregion           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;}&lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;&lt;b&gt;Note:&lt;/b&gt; the ‘ProvideFault’ method contains code that determines if an exception of type ‘System.Data.DBConcurrencyException’ has occurred.&amp;#160; If one has it is converted into a ‘DBConcurrencyFault’ which is then returned to the calling client by the WCF service.&amp;#160; &lt;/p&gt;  &lt;p&gt;&lt;b&gt;3.&lt;/b&gt; Now you can either add the WcfErrorHandler attribute to all your wcf services, or you can as I have below define a base service class that all your service classes will inherit from.&lt;/p&gt;  &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; bgcolor=&quot;#d3d3d3&quot;&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign=&quot;top&quot;&gt;namespace Common.Services          &lt;br /&gt;{           &lt;br /&gt;&amp;#160;&amp;#160; [WcfErrorHandler()]           &lt;br /&gt;&amp;#160;&amp;#160; public class BaseService           &lt;br /&gt;&amp;#160;&amp;#160; {           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // Common service methods go here           &lt;br /&gt;&amp;#160;&amp;#160; }           &lt;br /&gt;} &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;&lt;b&gt;4.&lt;/b&gt; Have your service class inherit from the base service class.&amp;#160; &lt;/p&gt;  &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; bgcolor=&quot;#d3d3d3&quot;&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign=&quot;top&quot;&gt;public class MileageClaimService : BaseService, IMileageClaimService          &lt;br /&gt;{           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // Service methods go here           &lt;br /&gt;} &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;&lt;b&gt;5.&lt;/b&gt; Trap the fault exception from a web client and redirect the user to a tailored error page.    &lt;br /&gt;&amp;#160;&amp;#160; &lt;b&gt;5a.&lt;/b&gt;&amp;#160; For an Asp.Net web application you can add the exception handling code to the global.asax Application_Error method. &lt;/p&gt;  &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; bgcolor=&quot;#d3d3d3&quot;&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign=&quot;top&quot;&gt;protected void Application_Error(object sender, EventArgs e)&amp;#160; &lt;br /&gt;{&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Exception ex = Server.GetLastError().GetBaseException();&amp;#160; &lt;br /&gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if (ex.GetType() == typeof(System.ServiceModel.FaultException&amp;lt;Common.Services.Faults.DBConcurrencyFault&amp;gt;) )&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Server.ClearError();&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Response.Redirect(&amp;quot;~/Errors/ErrorDbConcurrency.aspx&amp;quot;);&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&amp;#160; &lt;br /&gt;}&lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;&amp;#160; &lt;b&gt;5b.&lt;/b&gt; From an Asp.Net MVC web application you just add a HandleError attribute to the controller with the type of DBConcurrencyFault and redirect to a specific view.&lt;/p&gt;  &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; bgcolor=&quot;#d3d3d3&quot;&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign=&quot;top&quot;&gt;[HandleError(ExceptionType = typeof(System.ServiceModel.FaultException&amp;lt;Common.Services.Faults.DBConcurrencyFault&amp;gt;),          &lt;br /&gt;View = &amp;quot;ErrorDbConcurrency&amp;quot;)]           &lt;br /&gt;[HandleError]           &lt;br /&gt;public class ClaimController : Controller           &lt;br /&gt;{           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; // Controller methods go here           &lt;br /&gt;} &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;&lt;b&gt;Note:&lt;/b&gt; There are 2 HandleError attributes, the first handles the DBConcurrencyFault and redirects to a custom error page.&amp;#160; The 2nd traps all other exceptions and redirects to the default error page.&amp;#160; The order of these 2 HandleError attributes is important.&lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://jonlanceley.blogspot.com/feeds/6951082344352676029/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jonlanceley.blogspot.com/2009/12/convert-exceptions-in-wcf-services-to.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2990193854398450266/posts/default/6951082344352676029'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2990193854398450266/posts/default/6951082344352676029'/><link rel='alternate' type='text/html' href='http://jonlanceley.blogspot.com/2009/12/convert-exceptions-in-wcf-services-to.html' title='Convert Exceptions in WCF Services to Fault Exceptions a Client Can Use'/><author><name>Jon</name><uri>http://www.blogger.com/profile/03999374060620875716</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtN6KAyfs2XT5axA13YSBK6vG1fODGqFwkd7i3EgUB0JjSkFLFVaAZ4pbpaS_vohqo9WxkqepTFpoOWWpFhX_ozDe4BOvA-JHUiJlQBcVNk713PsbLK_Hj96vnzr2hHx0/s113/Me2.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2990193854398450266.post-8778009458588833195</id><published>2009-12-18T17:55:00.002+00:00</published><updated>2011-06-19T08:49:38.641+00:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="Unity Dependency Injection"/><category scheme="http://www.blogger.com/atom/ns#" term="WCF"/><title type='text'>Constructor Dependency Injection with a WCF Service using Unity</title><content type='html'>&lt;p&gt;In a previous article I showed how to use dependency injection to specify in a config file which repository should be used by a non WCF service.&lt;/p&gt;  &lt;p&gt;This article will show how to do the same but for a WCF service.&lt;/p&gt;  &lt;p&gt;The previous article can be found &lt;a title=&quot;Constructor Dependency Injection using Unity&quot; href=&quot;http://jonlanceley.blogspot.com/2009/12/constructor-dependency-injection-using.html&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;1.&lt;/b&gt; WCF uses interfaces so the first thing we need to do is add an interface to our service to WCF enable it.&amp;#160; Since the service is called MileageClaimService I will call the interface IMileageClaimService. Below is the interface definition decorated with WCF ServiceContract and OperationContract attributes.&lt;/p&gt;  &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; bgcolor=&quot;#d3d3d3&quot;&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign=&quot;top&quot;&gt;namespace Service.Finance.Mileage.Interfaces          &lt;br /&gt;{           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; [ServiceContract(           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Name = &amp;quot;MileageClaimService&amp;quot;,           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Namespace = &amp;quot;&lt;a href=&quot;http://mycompany.com/services/finance/v1.0.0.0%22%29%5D&quot;&gt;http://mycompany.com/services/finance/v1.0.0.0&amp;quot;)]&lt;/a&gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public interface IMileageClaimService           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; [OperationContract(Name = &amp;quot;GetAllClaimsForEmployee&amp;quot;)]           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; List&amp;lt;DTO.Finance.Mileage.MileageClaim&amp;gt; GetAllClaimsForEmployee(string employeePayrollNumber);           &lt;br /&gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; [OperationContract(Name = &amp;quot;GetClaimById&amp;quot;)]           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; DTO.Finance.Mileage.MileageClaim GetClaimById(int id);           &lt;br /&gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; [OperationContract(Name = &amp;quot;GetClaimByReferenceNumber&amp;quot;)]           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; DTO.Finance.Mileage.MileageClaim GetClaimByReferenceNumber(string referenceNumber);           &lt;br /&gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; [OperationContract(Name = &amp;quot;Save&amp;quot;)]           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; [FaultContract(typeof(DBConcurrencyFault))]           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; void Save(ref DTO.Finance.Mileage.MileageClaim claim);           &lt;br /&gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; [OperationContract(Name = &amp;quot;Delete&amp;quot;)]           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; void Delete(DTO.Finance.Mileage.MileageClaim claim);           &lt;br /&gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; [OperationContract(Name = &amp;quot;SubmitClaim&amp;quot;)]           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; void SubmitClaim(DTO.Finance.Mileage.MileageClaim claim);           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;}&lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;Below I’ve added the interface and the ServiceBehavior attribute to the service.&lt;/p&gt;  &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; bgcolor=&quot;#d3d3d3&quot;&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign=&quot;top&quot;&gt;namespace Service.Finance.Mileage          &lt;br /&gt;{           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public class MileageClaimService : IMileageClaimService           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; IMileageClaimRepository _mileageClaimRepository;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; [InjectionConstructor]&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public MileageClaimService(IMileageClaimRepository&amp;#160; mileageClaimRepository)           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // Other service methods go here&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;}&lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;&lt;b&gt;2.&lt;/b&gt;&amp;#160; We need to create the Unity classes for WCF.    &lt;br /&gt;I’ve created a project called Common. In here I’m going to place the Unity WCF classes (there are 3 of them) in a directory called Services\Unity.&amp;#160; You can just copy the code to your own project as I did (thanks to dperez for helping me with this: &lt;a href=&quot;http://blogs.southworks.net/dperez/2008/11/02/unity-friends-the-wcf-service-host-side/&quot;&gt;http://blogs.southworks.net/dperez/2008/11/02/unity-friends-the-wcf-service-host-side/&lt;/a&gt;).&lt;/p&gt;  &lt;p&gt;&lt;b&gt;InjectionBehavior.cs&lt;/b&gt; &lt;/p&gt;  &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; bgcolor=&quot;#d3d3d3&quot;&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign=&quot;top&quot;&gt;using System.Collections.ObjectModel;          &lt;br /&gt;using System.ServiceModel;           &lt;br /&gt;using System.ServiceModel.Channels;           &lt;br /&gt;using System.ServiceModel.Description;           &lt;br /&gt;using System.ServiceModel.Dispatcher;           &lt;br /&gt;using Microsoft.Practices.Unity;           &lt;br /&gt;          &lt;br /&gt;// WCF Unity Injection Behavior           &lt;br /&gt;namespace Common.Services.Unity           &lt;br /&gt;{           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; /// Creates services instance by using Unity type resolution.           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public class InjectionBehavior : IServiceBehavior           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// Injection container.           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; private IUnityContainer container;           &lt;br /&gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// Initializes a new instance of the InjectionBehavior class.           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;param name=&amp;quot;container&amp;quot;&amp;gt;Injection container.&amp;lt;/param&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public InjectionBehavior(IUnityContainer container)           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; this.container = container;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// Provides the ability to pass custom data to binding elements to support the contract implementation.           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;param name=&amp;quot;serviceDescription&amp;quot;&amp;gt;The service description of the service.&amp;lt;/param&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;param name=&amp;quot;serviceHostBase&amp;quot;&amp;gt;The host of the service.&amp;lt;/param&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;param name=&amp;quot;endpoints&amp;quot;&amp;gt;The service endpoints.&amp;lt;/param&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;param name=&amp;quot;bindingParameters&amp;quot;&amp;gt;Custom objects to which binding elements have access.&amp;lt;/param&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public void AddBindingParameters(           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ServiceDescription serviceDescription,           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ServiceHostBase serviceHostBase,           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Collection&amp;lt;ServiceEndpoint&amp;gt; endpoints,           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; BindingParameterCollection bindingParameters)           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// Provides the ability to change run-time property values or insert custom extension objects such as error handlers, message or parameter interceptors, security extensions, and other custom extension objects.           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;param name=&amp;quot;serviceDescription&amp;quot;&amp;gt;The service description.&amp;lt;/param&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;param name=&amp;quot;serviceHostBase&amp;quot;&amp;gt; The host that is currently being built.&amp;lt;/param&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public void ApplyDispatchBehavior(ServiceDescription serviceDescription, System.ServiceModel.ServiceHostBase serviceHostBase)           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; foreach (var channelDispatcherBase in serviceHostBase.ChannelDispatchers)           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {           &lt;br /&gt;&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; var channelDispatcher = channelDispatcherBase as ChannelDispatcher;           &lt;br /&gt;&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; if (channelDispatcher != null)           &lt;br /&gt;&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;br /&gt;&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; foreach (var endpointDispatcher in channelDispatcher.Endpoints)           &lt;br /&gt;&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;br /&gt;&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; endpointDispatcher.DispatchRuntime.InstanceProvider = new InjectionInstanceProvider(this.container, serviceDescription.ServiceType);           &lt;br /&gt;&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;br /&gt;&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;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// Provides the ability to inspect the service host and the service description to confirm that the service can run successfully.           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;param name=&amp;quot;serviceDescription&amp;quot;&amp;gt;The service description.&amp;lt;/param&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;param name=&amp;quot;serviceHostBase&amp;quot;&amp;gt;The service host that is currently being constructed.&amp;lt;/param&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public void Validate(ServiceDescription serviceDescription, System.ServiceModel.ServiceHostBase serviceHostBase)           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;}&lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;br /&gt;&lt;b&gt;InjectionElement.cs&lt;/b&gt;   &lt;br /&gt;  &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; bgcolor=&quot;#d3d3d3&quot;&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign=&quot;top&quot;&gt;using System;          &lt;br /&gt;using System.Configuration;           &lt;br /&gt;using System.ServiceModel.Configuration;           &lt;br /&gt;using Microsoft.Practices.Unity;           &lt;br /&gt;using Microsoft.Practices.Unity.Configuration;           &lt;br /&gt;          &lt;br /&gt;// WCF Unity Injection Element           &lt;br /&gt;namespace Common.Services.Unity           &lt;br /&gt;{           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; /// Injection element class representing a behavior extension configuration tag.           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public class InjectionElement : BehaviorExtensionElement           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// Default Unity configuration section path.           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; private const string DefaultUnityConfigurationSectionPath = &amp;quot;unity&amp;quot;;           &lt;br /&gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// Initializes a new instance of the InjectionElement class.           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public InjectionElement()           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; this.UnityConfigurationSectionPath = DefaultUnityConfigurationSectionPath;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// Gets the type of behavior.           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;value&amp;gt;Behavior type.&amp;lt;/value&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public override Type BehaviorType           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; get           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {           &lt;br /&gt;&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; return typeof(InjectionBehavior);           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// Gets or sets the injection container name.           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;value&amp;gt;Container name.&amp;lt;/value&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; [ConfigurationProperty(&amp;quot;containerName&amp;quot;)]           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public string ContainerName           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; get;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; set;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// Gets or sets the Unity configuration section path to read configuration from.           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;value&amp;gt;Configuration path.&amp;lt;/value&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; [ConfigurationProperty(&amp;quot;unityConfigurationSectionPath&amp;quot;, DefaultValue = DefaultUnityConfigurationSectionPath)]           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public string UnityConfigurationSectionPath           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; get;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; set;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// Creates a behavior extension based on the current configuration settings.           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;returns&amp;gt;The behavior extension.&amp;lt;/returns&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; protected override object CreateBehavior()           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; var unitySection = ConfigurationManager.GetSection(this.UnityConfigurationSectionPath) as UnityConfigurationSection;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; IUnityContainer container = new UnityContainer();           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if (this.ContainerName == null)           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {           &lt;br /&gt;&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; unitySection.Containers.Default.Configure(container);           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; else           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {           &lt;br /&gt;&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; unitySection.Containers[this.ContainerName].Configure(container);           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return new InjectionBehavior(container);           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;}&lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;br /&gt;&lt;b&gt;InjectionInstanceProvider.cs&lt;/b&gt;   &lt;br /&gt;  &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; bgcolor=&quot;#d3d3d3&quot;&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign=&quot;top&quot;&gt;using System;          &lt;br /&gt;using System.ServiceModel;           &lt;br /&gt;using System.ServiceModel.Channels;           &lt;br /&gt;using System.ServiceModel.Dispatcher;           &lt;br /&gt;using Microsoft.Practices.Unity;           &lt;br /&gt;          &lt;br /&gt;// WCF Unity Injection Provider           &lt;br /&gt;namespace Common.Services.Unity           &lt;br /&gt;{           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; /// Injection instance provider for new service instances.           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; internal sealed class InjectionInstanceProvider : IInstanceProvider           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// Injection container.           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; private IUnityContainer container;           &lt;br /&gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// Type of the service implementation.           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; private Type instanceType;           &lt;br /&gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// Initializes a new instance of the InjectionInstanceProvider class.           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;param name=&amp;quot;container&amp;quot;&amp;gt;Injection container.&amp;lt;/param&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;param name=&amp;quot;instanceType&amp;quot;&amp;gt;Type of the service implementation.&amp;lt;/param&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public InjectionInstanceProvider(IUnityContainer container, Type instanceType)           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; this.container = container;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; this.instanceType = instanceType;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// Returns a service object given the specified System.ServiceModel.InstanceContext object.           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;param name=&amp;quot;instanceContext&amp;quot;&amp;gt;The current System.ServiceModel.InstanceContext object.&amp;lt;/param&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;param name=&amp;quot;message&amp;quot;&amp;gt;The message that triggered the creation of a service object.&amp;lt;/param&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;returns&amp;gt;The service object.&amp;lt;/returns&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public object GetInstance(InstanceContext instanceContext, Message message)           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return this.container.Resolve(this.instanceType);           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// Returns a service object given the specified System.ServiceModel.InstanceContext object.           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;param name=&amp;quot;instanceContext&amp;quot;&amp;gt;The current System.ServiceModel.InstanceContext object.&amp;lt;/param&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;returns&amp;gt;The service object.&amp;lt;/returns&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public object GetInstance(InstanceContext instanceContext)           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return this.GetInstance(instanceContext, null);           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// Called when an System.ServiceModel.InstanceContext object recycles a service object.           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;param name=&amp;quot;instanceContext&amp;quot;&amp;gt;The service&#39;s instance context.&amp;lt;/param&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;param name=&amp;quot;instance&amp;quot;&amp;gt;The service object to be recycled.&amp;lt;/param&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public void ReleaseInstance(InstanceContext instanceContext, object instance)           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; this.container.Teardown(instance);           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;}&lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;&lt;b&gt;3.&lt;/b&gt; Now we need to update the app.config file for the service project.&amp;#160; Below shows the configuration to enable the service for Unity dependency injection (it’s exactly the same as in the previous post).&lt;/p&gt;  &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; bgcolor=&quot;#d3d3d3&quot;&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign=&quot;top&quot;&gt;&amp;lt;configSections&amp;gt;          &lt;br /&gt;&amp;#160; &amp;lt;section name=&amp;quot;unity&amp;quot; type=&amp;quot;Microsoft.Practices.Unity.Configuration.UnityConfigurationSection, Microsoft.Practices.Unity.Configuration&amp;quot; /&amp;gt;           &lt;br /&gt;&amp;lt;/configSections&amp;gt;           &lt;br /&gt;          &lt;br /&gt;&amp;lt;unity&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;containers&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;container&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;types&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;type type=&amp;quot;DataAccess.Finance.Mileage.Interfaces.IMileageClaimRepository,           &lt;br /&gt;&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; DataAccess.Finance.Mileage.Interfaces&amp;quot;           &lt;br /&gt;&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; mapTo=&amp;quot;EF.DataAccess.Finance.Mileage.Repositories.MileageClaimRepository,           &lt;br /&gt;&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; EF.DataAccess.Finance.Mileage&amp;quot;/&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/types&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/container&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/containers&amp;gt;&amp;#160; &lt;br /&gt;&amp;lt;/unity&amp;gt;&lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;And below is the new configuration to enable the service for WCF using the Unity behavior. &lt;/p&gt;  &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; bgcolor=&quot;#d3d3d3&quot;&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign=&quot;top&quot;&gt;&amp;lt;system.serviceModel&amp;gt;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;extensions&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;behaviorExtensions&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;add name=&amp;quot;unity&amp;quot; type=&amp;quot;Common.Services.Unity.InjectionElement, Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null&amp;quot;/&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/behaviorExtensions&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/extensions&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;bindings&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;netTcpContextBinding&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;binding name=&amp;quot;netTcpContextBindingConfig&amp;quot; transactionFlow=&amp;quot;true&amp;quot; /&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/netTcpContextBinding&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/bindings&amp;gt;          &lt;br /&gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;services&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;service behaviorConfiguration=&amp;quot;Service.ServiceBehavior&amp;quot; name=&amp;quot;Service.Finance.Mileage.MileageClaimService&amp;quot;&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;endpoint address=&amp;quot;&amp;quot; binding=&amp;quot;netTcpContextBinding&amp;quot; bindingConfiguration=&amp;quot;netTcpContextBindingConfig&amp;quot;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; name=&amp;quot;TcpBinding_MileageClaimService&amp;quot; contract=&amp;quot;Service.Finance.Mileage.Interfaces.IMileageClaimService&amp;quot; /&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;endpoint address=&amp;quot;mex&amp;quot; binding=&amp;quot;mexTcpBinding&amp;quot; name=&amp;quot;MexTcpBinding_MileageClaimService&amp;quot;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; contract=&amp;quot;IMetadataExchange&amp;quot; /&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;host&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;baseAddresses&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;add baseAddress=&amp;quot;net.tcp://localhost:8734/Services.Finance/MileageClaimService/v1.0.0.0&amp;quot; /&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/baseAddresses&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/host&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/service&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/services&amp;gt;           &lt;br /&gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;behaviors&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;serviceBehaviors&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;behavior name=&amp;quot;Service.ServiceBehavior&amp;quot;&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;serviceMetadata httpGetEnabled=&amp;quot;false&amp;quot;/&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;serviceDebug includeExceptionDetailInFaults=&amp;quot;false&amp;quot; /&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;unity /&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/behavior&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/serviceBehaviors&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/behaviors&amp;gt;&amp;#160; &lt;br /&gt;&amp;lt;/system.serviceModel&amp;gt; &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;Note the behaviorExtensions section contains a Unity entry.&amp;#160; This points to the Unity InjectionElement class you added in the last section.&amp;#160; &lt;/p&gt;  &lt;p&gt;Also note the &amp;lt;unity /&amp;gt; line in the serviceBehaviors.&amp;#160; &lt;/p&gt;  &lt;p&gt;Both of these are critical to enabling the WCF service to use Unity dependency injection.&lt;/p&gt;  &lt;p&gt;Thats it, you can use the wcf service as you would do any wcf service by adding a service reference to your client project and calling the methods on it.&amp;#160; The repository will be injected automatically into the constructor on the service because of the behavior extensions defined in the wcf configuration.&lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://jonlanceley.blogspot.com/feeds/8778009458588833195/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jonlanceley.blogspot.com/2009/12/constructor-dependency-injection-with.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2990193854398450266/posts/default/8778009458588833195'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2990193854398450266/posts/default/8778009458588833195'/><link rel='alternate' type='text/html' href='http://jonlanceley.blogspot.com/2009/12/constructor-dependency-injection-with.html' title='Constructor Dependency Injection with a WCF Service using Unity'/><author><name>Jon</name><uri>http://www.blogger.com/profile/03999374060620875716</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtN6KAyfs2XT5axA13YSBK6vG1fODGqFwkd7i3EgUB0JjSkFLFVaAZ4pbpaS_vohqo9WxkqepTFpoOWWpFhX_ozDe4BOvA-JHUiJlQBcVNk713PsbLK_Hj96vnzr2hHx0/s113/Me2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2990193854398450266.post-2747276099102148211</id><published>2009-12-17T17:42:00.002+00:00</published><updated>2011-06-19T08:43:40.674+00:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="Design Patterns"/><category scheme="http://www.blogger.com/atom/ns#" term="Unity Dependency Injection"/><title type='text'>Constructor Dependency Injection using Unity (Enterprise Library)</title><content type='html'>&lt;p&gt;In the previous article I discussed using the repository design pattern.&amp;#160; I also showed how to use a service layer which can then call the repository data access layer.&amp;#160; This was done by specifying in code which repository to use in the constructor of the service. &lt;/p&gt;  &lt;p&gt;This article will show how to use dependency injection to specify in the web.config / app.config which repository should be used by the service.&lt;/p&gt;  &lt;p&gt;The previous article can be found &lt;a title=&quot;Using The Repository Design Pattern For Data Access Code&quot; href=&quot;http://jonlanceley.blogspot.com/2009/12/using-repository-design-pattern-for.html&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt; and you should understand this before continuing.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;1.&lt;/b&gt; You need to download &lt;a title=&quot;Enterprise Library 4.1&quot; href=&quot;http://msdn.microsoft.com/en-us/library/dd203099.aspx&quot; target=&quot;_blank&quot;&gt;Enterprise Library 4.1&lt;/a&gt; or higher which contains the dependency injection block called ‘Unity’. &lt;/p&gt;  &lt;p&gt;&lt;b&gt;2.&lt;/b&gt; You need to add references for Microsoft.Practices.Unity.Configuration.dll and Microsoft.Practices.Unity.dll to the service project.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;3.&lt;/b&gt; The only change you need to make to the service is to specify which constructor is the one that should be enabled for dependency injection.&amp;#160; You do this by using the [InjectionConstructor] attribute.     &lt;br /&gt;&lt;/p&gt;  &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; bgcolor=&quot;#d3d3d3&quot;&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign=&quot;top&quot;&gt;namespace Service.Finance.Mileage          &lt;br /&gt;{           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public class MileageClaimService           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; IMileageClaimRepository _mileageClaimRepository;           &lt;br /&gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; [InjectionConstructor]&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public MileageClaimService(IMileageClaimRepository&amp;#160; mileageClaimRepository)           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // Other service methods go here&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;} &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;&lt;b&gt;4.&lt;/b&gt; For ease of use, its useful to create a helper class to hide the Unity code that is needed to work out the repository to use for the service.&amp;#160; I’ve called the class ‘UnityDependencyInjectionHelper’ and its best to place it in a common project as it will be reused so I have a project called Common.Service.&amp;#160; You can just copy the following code:&lt;/p&gt;  &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; bgcolor=&quot;#d3d3d3&quot;&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign=&quot;top&quot;&gt;using System;          &lt;br /&gt;using System.Collections.Generic;           &lt;br /&gt;using System.Linq;           &lt;br /&gt;using System.Text;           &lt;br /&gt;using Microsoft.Practices.Unity;           &lt;br /&gt;using Microsoft.Practices.Unity.Configuration;           &lt;br /&gt;using System.Configuration;           &lt;br /&gt;          &lt;br /&gt;namespace Service.Common           &lt;br /&gt;{           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public static class UnityDependencyInjectionHelper           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; private static IUnityContainer container;           &lt;br /&gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; private static void Init()           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; container = new UnityContainer();           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; UnityConfigurationSection section = (UnityConfigurationSection)ConfigurationManager.GetSection(&amp;quot;unity&amp;quot;);           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; section.Containers.Default.Configure(container);           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public static T Resolve&amp;lt;T&amp;gt;()           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Init();           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return container.Resolve&amp;lt;T&amp;gt;();           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }          &lt;br /&gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public static T Resolve&amp;lt;T&amp;gt;(string name)           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Init();           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return container.Resolve&amp;lt;T&amp;gt;(name);           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;}&lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;&lt;b&gt;5.&lt;/b&gt; To call the service from the client you used to do this:&lt;/p&gt;  &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; bgcolor=&quot;#d3d3d3&quot;&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign=&quot;top&quot;&gt;&amp;#160;&amp;#160;&amp;#160; // Get the mileage claim repository we want to use Entity Framework or ADO.Net.&amp;#160;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; IMileageClaimRepository repository = new EF.DataAccess.Finance.Mileage.Repositories.MileageClaimRepository();&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; // Initialise the service passing in the data access repository it should use&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; MileageClaimService mileageClaimService = new MileageClaimService( repository );&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; // Call a method on the service&amp;#160;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; DTO.Finance.Mileage.MileageClaim mileageClaimService.GetClaimById( 10 ); &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;but now you would do this:&lt;/p&gt;  &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; bgcolor=&quot;#d3d3d3&quot;&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign=&quot;top&quot;&gt;mileageClaimService = Service.Common.UnityDependencyInjectionHelper.Resolve&amp;lt;Service.Finance.Mileage.MileageClaimService&amp;gt;();         &lt;br /&gt;          &lt;br /&gt;// Call a method on the service&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;DTO.Finance.Mileage.MileageClaim mileageClaimService.GetClaimById( 10 ); &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;Notice the difference here is we are not specifying the repository to use, it will be automatically injected into the constructor on the service.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;6.&lt;/b&gt; Lastly you need to add a few lines to the web.config file so the Unity Helper can find the repository.    &lt;br /&gt;&lt;b&gt;&amp;#160; 6a.&lt;/b&gt; First you need to add the Enterprise Library Unity section to the configSections.&lt;/p&gt;  &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; bgcolor=&quot;#d3d3d3&quot;&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign=&quot;top&quot;&gt;&amp;lt;configSections&amp;gt;          &lt;br /&gt;&amp;#160; &amp;lt;section name=&amp;quot;unity&amp;quot; type=&amp;quot;Microsoft.Practices.Unity.Configuration.UnityConfigurationSection, Microsoft.Practices.Unity.Configuration&amp;quot; /&amp;gt;           &lt;br /&gt;&amp;lt;/configSections&amp;gt; &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;&amp;#160; &lt;b&gt;6b.&lt;/b&gt; Next you need to add the mapping to the repository.&amp;#160; You do this by adding a Unity block with containers as shown below. You can add this straight after the &amp;lt;/configSections&amp;gt;&lt;/p&gt;  &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; bgcolor=&quot;#d3d3d3&quot;&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign=&quot;top&quot;&gt;&amp;lt;unity&amp;gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;containers&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;container&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;types&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;type type=&amp;quot;DataAccess.Finance.Mileage.Interfaces.IMileageClaimRepository,           &lt;br /&gt;&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; DataAccess.Finance.Mileage.Interfaces&amp;quot;           &lt;br /&gt;          &lt;br /&gt;&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; mapTo=&amp;quot;EF.DataAccess.Finance.Mileage.Repositories.MileageClaimRepository,           &lt;br /&gt;&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; EF.DataAccess.Finance.Mileage&amp;quot;/&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/types&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/container&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/containers&amp;gt;           &lt;br /&gt;&amp;#160; &amp;lt;/unity&amp;gt;&lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;The ‘type’ effectively says replace any occurrence of the IMileageClaimRepository interface.&amp;#160; And the mapTo effectively says with this MileageClaimRepository.&lt;/p&gt;  &lt;p&gt;If you ever needed to change the MileageClaimRepository that is being used all you need to do is change the mapTo line e.g.&lt;/p&gt;  &lt;p&gt;To change the above which is using the Entity Framework repository (EF.DataAccess…..) to use ADO.Net repository (ADO.DataAccess…..) you would end up with:&lt;/p&gt;  &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; bgcolor=&quot;#d3d3d3&quot;&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign=&quot;top&quot;&gt;&amp;lt;unity&amp;gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;containers&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;container&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;types&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;type type=&amp;quot;DataAccess.Finance.Mileage.Interfaces.IMileageClaimRepository,           &lt;br /&gt;&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; DataAccess.Finance.Mileage.Interfaces&amp;quot;           &lt;br /&gt;          &lt;br /&gt;&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; mapTo=&amp;quot;&lt;b&gt;ADO&lt;/b&gt;.DataAccess.Finance.Mileage.Repositories.MileageClaimRepository,&amp;#160; &lt;br /&gt;&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;b&gt;ADO&lt;/b&gt;.DataAccess.Finance.Mileage&amp;quot;/&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/types&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/container&amp;gt;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/containers&amp;gt;           &lt;br /&gt;&amp;#160; &amp;lt;/unity&amp;gt;&lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  </content><link rel='replies' type='application/atom+xml' href='http://jonlanceley.blogspot.com/feeds/2747276099102148211/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jonlanceley.blogspot.com/2009/12/constructor-dependency-injection-using.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2990193854398450266/posts/default/2747276099102148211'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2990193854398450266/posts/default/2747276099102148211'/><link rel='alternate' type='text/html' href='http://jonlanceley.blogspot.com/2009/12/constructor-dependency-injection-using.html' title='Constructor Dependency Injection using Unity (Enterprise Library)'/><author><name>Jon</name><uri>http://www.blogger.com/profile/03999374060620875716</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtN6KAyfs2XT5axA13YSBK6vG1fODGqFwkd7i3EgUB0JjSkFLFVaAZ4pbpaS_vohqo9WxkqepTFpoOWWpFhX_ozDe4BOvA-JHUiJlQBcVNk713PsbLK_Hj96vnzr2hHx0/s113/Me2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2990193854398450266.post-8220779804761042693</id><published>2009-12-16T15:13:00.002+00:00</published><updated>2011-06-19T08:55:00.007+00:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="Design Patterns"/><title type='text'>Using The Repository Design Pattern For Data Access Code</title><content type='html'>&lt;p&gt;In this article we will create a repository for our data base access code. The repository pattern is useful when:   &lt;br /&gt;• Some of your clients use Oracle and others use SQL Server you can create a repository for each.     &lt;br /&gt;• Your company decides to upgrade to a newer way of doing data base access.&amp;#160; &lt;/p&gt;  &lt;p&gt;You only need to create a new repository class to do it. E.g. you might have one repository for ADO.Net and one for Entity Framework data access code.   &lt;br /&gt;    &lt;br /&gt;To get started what we are going to do here is create a repository that will contain data base access code to retrieve MileageClaim information.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;1.&lt;/b&gt; First we need a Data Transfer Object (DTO). This is where the mileage claim data will be placed that we retrieve from the database.&lt;/p&gt;  &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot;&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td bgcolor=&quot;#d3d3d3&quot; valign=&quot;top&quot; width=&quot;800&quot;&gt;namespace DTO.Finance.Mileage          &lt;br /&gt;{           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public class MileageClaim           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {&amp;#160;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public int MileageClaimId { get; set; }&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public string PayrollNumber { get; set; }           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public string ReferenceNumber { get; set; }           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public int? VehicleId { get; set; }           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public int CreatedByPersonId { get; set; }           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public DateTime DateCreated { get; set; }           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public int? UpdatedByPersonId { get; set; }           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public DateTime? DateUpdated { get; set; }           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;} &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;You should place the DTO class in a separate class library project as you will reference these classes from many places. I’ve called the project DTO.Finance.Mileage.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;2.&lt;/b&gt; Define an interface for the repository. Since its going to handle mileage claim data an appropriate name is IMileageClaimRepository.&lt;/p&gt;  &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot;&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td bgcolor=&quot;#d3d3d3&quot; valign=&quot;top&quot; width=&quot;800&quot;&gt;namespace DataAccess.Finance.Mileage.Interfaces          &lt;br /&gt;{           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public interface IMileageClaimRepository           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; List&amp;lt;DTO.Finance.Mileage.MileageClaim&amp;gt; GetAllClaimsForEmployee(String employeePayrollNumber);           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; DTO.Finance.Mileage.MileageClaim GetClaimByReferenceNumber(String referenceNumber);           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; DTO.Finance.Mileage.MileageClaim GetClaimById(Int32 id);           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; void ChangeMileageClaimStatus(DTO.Finance.Mileage.MileageClaim claim, DTO.Common.Status status, String userIdentity);          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; void Save(ref DTO.Finance.Mileage.MileageClaim claim, String userIdentity);           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; void Delete(DTO.Finance.Mileage.MileageClaim claim);           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;}&lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;Again you should place these interfaces in a separate project as it makes it easier later if/when you create additional mileage claim repositories.&lt;/p&gt;  &lt;p&gt;This interface defines the methods that the repository will provide. Because it’s going to contain data base access code it will handle the standard CRUD (create, read, update, delete) methods.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;3.&lt;/b&gt; Next we need to create the actual repository.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;3.1.&lt;/b&gt; You should place these data base access classes in a separate project; I’ve called it EF.DataAccess.Finance.Mileage because this repository is going to access the database using Entity Framework. If I had another repository for ADO.Net I’d call it ADO.DataAccess.Finance.Mileage. Inside this project I place all the data base access code including the model diagrams for Entity Framework.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;3.2.&lt;/b&gt; Inside this project I place the repository class for accessing mileage claim data from the database, so I’ll call it MileageClaimRepository and place it in a Repositories folder. It will implement the IMileageClaimRepository interface.&lt;/p&gt;  &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot;&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td bgcolor=&quot;#d3d3d3&quot; valign=&quot;top&quot; width=&quot;800&quot;&gt;namespace EF.DataAccess.Finance.Mileage.Repositories          &lt;br /&gt;{           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public class MileageClaimRepository : IMileageClaimRepository           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public MileageClaimRepository()           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public List&amp;lt;DTO.Finance.Mileage.MileageClaim&amp;gt; GetAllClaimsForEmployee(String employeePayrollNumber)           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // Data base access code goes here           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public DTO.Finance.Mileage.MileageClaim GetClaimByReferenceNumber(String referenceNumber)           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // Data base access code goes here           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public DTO.Finance.Mileage.MileageClaim GetClaimById(Int32 id)           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // Data base access code goes here           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }          &lt;br /&gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public void ChangeMileageClaimStatus(DTO.Finance.Mileage.MileageClaim claim, DTO.Common.Status status, String userIdentity)           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // Data base access code goes here           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public void Save(ref DTO.Finance.Mileage.MileageClaim dtoClaim, String userIdentity)           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // Data base access code goes here           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public void Delete(DTO.Finance.Mileage.MileageClaim claim)           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // Data base access code goes here           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;} &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;&lt;b&gt;4.&lt;/b&gt; We now have our data access layer. To use this layer and to use the separation of concerns principle I’m going to add 1 more layer, a service layer.&amp;#160; Note the service contains more methods than the repository (a service layer does not have to map 1 to 1 to the repository layer).&lt;/p&gt;  &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot;&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td bgcolor=&quot;#d3d3d3&quot; valign=&quot;top&quot; width=&quot;800&quot;&gt;namespace Service.Finance.Mileage          &lt;br /&gt;{           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public class MileageClaimService           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; IMileageClaimRepository _mileageClaimRepository;          &lt;br /&gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public MileageClaimService(IMileageClaimRepository mileageClaimRepository)           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _mileageClaimRepository = mileageClaimRepository;           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public List&amp;lt;DTO.Finance.Mileage.MileageClaim&amp;gt; GetAllClaimsForEmployee(String employeePayrollNumber)           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return _mileageClaimRepository.GetAllClaimsForEmployee(employeePayrollNumber);           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public DTO.Finance.Mileage.MileageClaim GetClaimByReferenceNumber(String referenceNumber)           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return _mileageClaimRepository.GetClaimByReferenceNumber(referenceNumber);           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }          &lt;br /&gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public DTO.Finance.Mileage.MileageClaim GetClaimById(Int32 id)           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return _mileageClaimRepository.GetClaimById(id);           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&amp;#160; &lt;br /&gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public void Save(ref DTO.Finance.Mileage.MileageClaim claim)           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; String userIdentity = User.Identity.Name;           &lt;br /&gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if (claim.MileageClaimId == 0)           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {           &lt;br /&gt;&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; // It&#39;s a new claim so do some new claim stuff here           &lt;br /&gt;&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; // You could do stuff like automatically set the reference number here&amp;#160; &lt;br /&gt;&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; // Get the status object so we can set the new claim with an initial status of draft           &lt;br /&gt;&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; StatusService statusService = new StatusService();           &lt;br /&gt;&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; DTO.Common.Status status = statusService.GetStatus(           &lt;br /&gt;&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; (Int32)MileageClaimStatusTypeKeys.MileageClaim,           &lt;br /&gt;&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; (Int32) Service.Finance.Mileage.Enums.MileageClaimStatusKeys.Draft);           &lt;br /&gt;          &lt;br /&gt;&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; // We want to make sure that if one of the 2 service calls fail then           &lt;br /&gt;&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; // neither will write any data into the db so lets create a transaction.           &lt;br /&gt;&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; using (TransactionScope scope = new           &lt;br /&gt;&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; TransactionScope(TransactionScopeOption.Required))           &lt;br /&gt;&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;br /&gt;&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; // Save any changes to the claim           &lt;br /&gt;&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; _mileageClaimRepository.Save(ref claim, userIdentity);           &lt;br /&gt;          &lt;br /&gt;&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; // Change the claim status to draft           &lt;br /&gt;&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; ChangeMileageClaimStatus(claim, status);           &lt;br /&gt;          &lt;br /&gt;&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; // If no exceptions have been thrown so far then commit the transaction           &lt;br /&gt;&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; // so everything is saved to the db           &lt;br /&gt;&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; scope.Complete();           &lt;br /&gt;&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;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; else           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {           &lt;br /&gt;&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; // It’s an existing claim being edited so save any changes to the claim           &lt;br /&gt;&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; _mileageClaimRepository.Save(ref claim, userIdentity);           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public void Delete(DTO.Finance.Mileage.MileageClaim claim)           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _mileageClaimRepository.Delete(claim);           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }          &lt;br /&gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public void SubmitClaim(DTO.Finance.Mileage.MileageClaim claim)           &lt;br /&gt;&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;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // Save any changes to the claim           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Save(ref claim);&amp;#160; &lt;br /&gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // Change the claim status to submitted           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; StatusService statusService = new StatusService();           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; DTO.Common.Status status = statusService.GetStatus(           &lt;br /&gt;&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; (Int32)MileageClaimStatusTypeKeys.MileageClaim,           &lt;br /&gt;&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; (Int32)Service.Finance.Mileage.Enums.MileageClaimStatusKeys.Submitted);           &lt;br /&gt;          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ChangeMileageClaimStatus(claim, status);           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }           &lt;br /&gt;} &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;This service accepts as a parameter on the constructor an interface for an IMileageClaimRepository. When we use the service in our code we tell the service what repository it should use e.g. Entity Framework or ADO.Net repositories. &lt;/p&gt;  &lt;p&gt;Because all the repositories use the same interface they will all have the same method names that the service can call so we don’t need to change the service code at all to use different repositories.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;5.&lt;/b&gt; From a client you just need to reference the service, DTO and the repository you want to use projects.&amp;#160; Then to call a method from the client you just:&lt;/p&gt;  &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot;&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td bgcolor=&quot;#d3d3d3&quot; valign=&quot;top&quot; width=&quot;800&quot;&gt;// Get the mileage claim repository we want to use Entity Framework or ADO.Net.&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;IMileageClaimRepository repository = new EF.DataAccess.Finance.Mileage.Repositories.MileageClaimRepository();&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;// Initialise the service passing in the data access repository it should use&amp;#160;&amp;#160; &lt;br /&gt;MileageClaimService mileageClaimService = new MileageClaimService( repository );&amp;#160;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;// Call a method on the service&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;DTO.Finance.Mileage.MileageClaim mileageClaimService.GetClaimById( 10 ); &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;&lt;b&gt;Note:&lt;/b&gt; You could use dependency injection (e.g Unity) to work out automatically which repository to use based on settings in a config file and in a future article we will look at doing just that.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Note:&lt;/b&gt; You can also use wcf on the service layer with minimal code changes if you wanted to move to a 3-tier architecture, this will be covered in a future article.&lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://jonlanceley.blogspot.com/feeds/8220779804761042693/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jonlanceley.blogspot.com/2009/12/using-repository-design-pattern-for.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2990193854398450266/posts/default/8220779804761042693'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2990193854398450266/posts/default/8220779804761042693'/><link rel='alternate' type='text/html' href='http://jonlanceley.blogspot.com/2009/12/using-repository-design-pattern-for.html' title='Using The Repository Design Pattern For Data Access Code'/><author><name>Jon</name><uri>http://www.blogger.com/profile/03999374060620875716</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtN6KAyfs2XT5axA13YSBK6vG1fODGqFwkd7i3EgUB0JjSkFLFVaAZ4pbpaS_vohqo9WxkqepTFpoOWWpFhX_ozDe4BOvA-JHUiJlQBcVNk713PsbLK_Hj96vnzr2hHx0/s113/Me2.jpg'/></author><thr:total>0</thr:total></entry></feed>