Skip to content

Commit 0792992

Browse files
committed
Site generated at Mon 14 Aug 2023 17:22:48 BST
1 parent 9d75ee5 commit 0792992

31 files changed

Lines changed: 375 additions & 375 deletions

File tree

  • blog
    • 2012
      • 10
      • 11
        • 11/testing-extension-methods-with-microsoft-fakes
        • 18/why-i-love-jetbrains-teamcity-as-a-net-developer
      • 12
        • 01/writing-a-git-provider-for-windows-powershell-part-1
        • 02/better-code-analysis-with-resharper-7-contract-annotations
        • 03/writing-a-git-provider-for-windows-powershell-part-2
        • 07/writing-a-git-provider-for-windows-powershell-part-3
        • 16/things-that-trip-newbies-in-powershell
    • 2013
      • 01
        • 06/using-mailmap-to-fix-authors-list-in-git
        • 13/remembering-aaron-swartz-in-his-writings
        • 19/precompiling-razor-views-in-asp-dot-net-mvc-3
        • 20/using-typeconverters-to-get-appsettings-in-net
      • 02/18/things-that-trip-newbies-in-powershell-encodings
      • 03
        • 11/why-use-virtualenv-when-there-is-pythonbrew
        • 14
      • 06
        • 15/things-that-trip-newbies-in-powershell-pipeline-output
        • 19/building-a-debian-wheezy-vagrant-box-using-veewee
      • 08/24/using-git-at-a-hackathon-where-git-slash-slash-port-is-blocked
      • 10/20/getting-started-with-ansbile-for-a-django-project
    • 2015/11
    • 2016/01
      • 01/s3-backed-docker-registry-on-kubernetes
      • 02/git-add-only-files-already-staged
      • 03/basics-of-rolling-update-with-kubernetes
      • 04/running-webdriverio-tests-using-docker-compose
      • 19/using-multiple-worktrees-with-git
    • 2018/11/19/mlflow-model-repository-ci-cd

blog/2012/10/17/learning-by-answering-questions/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<meta content="https://stacktoheap.com/blog/2012/10/17/learning-by-answering-questions/" property="og:url">
2828

2929

30-
<meta content="2012-10-17T14:44:00+00:00" property="article:published_time">
30+
<meta content="2012-10-17T14:44:00+01:00" property="article:published_time">
3131
<meta content="https://stacktoheap.com/about/" property="article:author">
3232

3333

@@ -426,7 +426,7 @@
426426

427427
<header class="post-header">
428428
<h1 class="post-title" itemprop="name headline">Learning by answering questions</h1>
429-
<p class="post-meta"><time datetime="2012-10-17T14:44:00+00:00" itemprop="datePublished">Oct 17, 2012</time></p>
429+
<p class="post-meta"><time datetime="2012-10-17T14:44:00+01:00" itemprop="datePublished">Oct 17, 2012</time></p>
430430
</header>
431431

432432
<div class="post-content" itemprop="articleBody">

blog/2012/10/31/contract-testing-a-json-service-in-net/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ <h1 class="post-title" itemprop="name headline">Contract testing a JSON service
436436

437437
<p>A typical contract test, which are Nunit tests, looked like this:</p>
438438

439-
<figure class="highlight"><pre><code class="language-csharp" data-lang="csharp"><span class="na">[Test]</span>
439+
<figure class="highlight"><pre><code class="language-csharp" data-lang="csharp"><span class="p">[</span><span class="n">Test</span><span class="p">]</span>
440440
<span class="k">public</span> <span class="k">void</span> <span class="nf">ShouldBeAbleToValidateTheJSONServiceResponseForFunctionalityA</span><span class="p">()</span>
441441
<span class="p">{</span>
442442
<span class="k">const</span> <span class="kt">string</span> <span class="n">schemaJson</span> <span class="p">=</span> <span class="s">@"
@@ -465,7 +465,7 @@ <h1 class="post-title" itemprop="name headline">Contract testing a JSON service
465465
<span class="nf">AssertResponseIsValidSchema</span><span class="p">(</span><span class="n">schemaJson</span><span class="p">,</span> <span class="n">parameters</span><span class="p">);</span>
466466
<span class="p">}</span></code></pre></figure>
467467

468-
<p>The <code class="highlighter-rouge">AssertResponseIsValidSchema()</code> is pretty standard. It uses RestSharp to get the API response and validates the schema with a Nunit assert:</p>
468+
<p>The <code class="language-plaintext highlighter-rouge">AssertResponseIsValidSchema()</code> is pretty standard. It uses RestSharp to get the API response and validates the schema with a Nunit assert:</p>
469469

470470
<figure class="highlight"><pre><code class="language-csharp" data-lang="csharp"><span class="k">private</span> <span class="k">void</span> <span class="nf">AssertResponseIsValidSchema</span><span class="p">(</span><span class="kt">string</span> <span class="n">schemaJson</span><span class="p">,</span> <span class="n">Dictionary</span><span class="p">&lt;</span><span class="kt">string</span><span class="p">,</span> <span class="kt">object</span><span class="p">&gt;</span> <span class="n">parameters</span><span class="p">)</span>
471471
<span class="p">{</span>
@@ -478,7 +478,7 @@ <h1 class="post-title" itemprop="name headline">Contract testing a JSON service
478478
<span class="n">Assert</span><span class="p">.</span><span class="nf">That</span><span class="p">(</span><span class="n">availablity</span><span class="p">.</span><span class="nf">IsValid</span><span class="p">(</span><span class="n">schema</span><span class="p">),</span> <span class="n">Is</span><span class="p">.</span><span class="n">True</span><span class="p">);</span>
479479
<span class="p">}</span></code></pre></figure>
480480

481-
<p>The JSON schema is written as per the <a href="http://json-schema.org/">proposed draft</a> and JSON.NET’s <code class="highlighter-rouge">IsValid()</code> is used to perfom the validation itself.</p>
481+
<p>The JSON schema is written as per the <a href="http://json-schema.org/">proposed draft</a> and JSON.NET’s <code class="language-plaintext highlighter-rouge">IsValid()</code> is used to perfom the validation itself.</p>
482482

483483
<p>The contract tests are also not run along with the normal build pipeline, but in a separate flow. Since we are hitting a service, we don’t want our main builds to be affected if the service is down or to slow down the builds. The separately run tests are the right balance in making sure the contract is not broken, while making sure the external factors don’t affect the builds.</p>
484484

blog/2012/11/11/testing-extension-methods-with-microsoft-fakes/index.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
<p>Now, we can easily add a shim that replaces the actual extension method. A standard test would look like below:</p>
3131

32-
<figure class="highlight"><pre><code class="language-csharp" data-lang="csharp"><span class="na">[TestFixture]</span>
32+
<figure class="highlight"><pre><code class="language-csharp" data-lang="csharp"><span class="p">[</span><span class="n">TestFixture</span><span class="p">]</span>
3333
<span class="k">public</span> <span class="k">class</span> <span class="nc">ToggledFeatureTests</span>
3434
<span class="p">{</span>
3535
<span class="p">[</span><span class="n">Test</span><span class="p">]</span>
@@ -55,7 +55,7 @@
5555

5656
<p>The shims have to be used with a ShimsContext using block as seen in the test code above. When the context is disposed, the method intercepts are reset to normalcy.</p>
5757

58-
<p>The fakes generated by Fakes follow some naming conventions. Without going into the details, the original type <code class="highlighter-rouge">ToggledExtensions</code> is replaced with <code class="highlighter-rouge">Fakes.ShimToggleExtensions</code> and the <code class="highlighter-rouge">IsOn</code> method in it which takes in a <code class="highlighter-rouge">IToggled</code> ( like a normal static method would, but in this an extension method) is called <code class="highlighter-rouge">IsOnIToggled</code>. The shim being provided is the lambda <code class="highlighter-rouge">toggled =&gt; true</code>. That is return true for any <code class="highlighter-rouge">IToggled</code> instance. Then there is a pretty standard assert.</p>
58+
<p>The fakes generated by Fakes follow some naming conventions. Without going into the details, the original type <code class="language-plaintext highlighter-rouge">ToggledExtensions</code> is replaced with <code class="language-plaintext highlighter-rouge">Fakes.ShimToggleExtensions</code> and the <code class="language-plaintext highlighter-rouge">IsOn</code> method in it which takes in a <code class="language-plaintext highlighter-rouge">IToggled</code> ( like a normal static method would, but in this an extension method) is called <code class="language-plaintext highlighter-rouge">IsOnIToggled</code>. The shim being provided is the lambda <code class="language-plaintext highlighter-rouge">toggled =&gt; true</code>. That is return true for any <code class="language-plaintext highlighter-rouge">IToggled</code> instance. Then there is a pretty standard assert.</p>
5959

6060
<p>There are some disadvantages with Microsoft Fakes. First and foremost, it might lead to bad code. In certain situations,tools like this help you to test code without having to make severe changes to it (like wrapping static method calls in a class ) or designing it in a complicated way just to support testing. But like already mentioned, most of the times, untestable code indicates something much deeper - code smells, bad design etc. You need to make a conscious decision when to use these feature of Microsoft Fakes. Secondly, Fakes requires Visual Studio Ultimate. Last, when using shims, the tests fail when running from Resharper ( 7.0 ) provided runner. This is a huge deal as my entire team uses Resharper and the tests must pass with the runner. There is a <a href="http://youtrack.jetbrains.com/issue/RSRP-328377">bug filed with JetBrains</a> and I am hoping it will be fixed soon. If you use the Nunit Test adpater and the VS 2012 Test runner, the tests pass, however.</p>
6161

@@ -479,7 +479,7 @@ <h1 class="post-title" itemprop="name headline">Testing extension methods with M
479479

480480
<p>Now, we can easily add a shim that replaces the actual extension method. A standard test would look like below:</p>
481481

482-
<figure class="highlight"><pre><code class="language-csharp" data-lang="csharp"><span class="na">[TestFixture]</span>
482+
<figure class="highlight"><pre><code class="language-csharp" data-lang="csharp"><span class="p">[</span><span class="n">TestFixture</span><span class="p">]</span>
483483
<span class="k">public</span> <span class="k">class</span> <span class="nc">ToggledFeatureTests</span>
484484
<span class="p">{</span>
485485
<span class="p">[</span><span class="n">Test</span><span class="p">]</span>
@@ -505,7 +505,7 @@ <h1 class="post-title" itemprop="name headline">Testing extension methods with M
505505

506506
<p>The shims have to be used with a ShimsContext using block as seen in the test code above. When the context is disposed, the method intercepts are reset to normalcy.</p>
507507

508-
<p>The fakes generated by Fakes follow some naming conventions. Without going into the details, the original type <code class="highlighter-rouge">ToggledExtensions</code> is replaced with <code class="highlighter-rouge">Fakes.ShimToggleExtensions</code> and the <code class="highlighter-rouge">IsOn</code> method in it which takes in a <code class="highlighter-rouge">IToggled</code> ( like a normal static method would, but in this an extension method) is called <code class="highlighter-rouge">IsOnIToggled</code>. The shim being provided is the lambda <code class="highlighter-rouge">toggled =&gt; true</code>. That is return true for any <code class="highlighter-rouge">IToggled</code> instance. Then there is a pretty standard assert.</p>
508+
<p>The fakes generated by Fakes follow some naming conventions. Without going into the details, the original type <code class="language-plaintext highlighter-rouge">ToggledExtensions</code> is replaced with <code class="language-plaintext highlighter-rouge">Fakes.ShimToggleExtensions</code> and the <code class="language-plaintext highlighter-rouge">IsOn</code> method in it which takes in a <code class="language-plaintext highlighter-rouge">IToggled</code> ( like a normal static method would, but in this an extension method) is called <code class="language-plaintext highlighter-rouge">IsOnIToggled</code>. The shim being provided is the lambda <code class="language-plaintext highlighter-rouge">toggled =&gt; true</code>. That is return true for any <code class="language-plaintext highlighter-rouge">IToggled</code> instance. Then there is a pretty standard assert.</p>
509509

510510
<p>There are some disadvantages with Microsoft Fakes. First and foremost, it might lead to bad code. In certain situations,tools like this help you to test code without having to make severe changes to it (like wrapping static method calls in a class ) or designing it in a complicated way just to support testing. But like already mentioned, most of the times, untestable code indicates something much deeper - code smells, bad design etc. You need to make a conscious decision when to use these feature of Microsoft Fakes. Secondly, Fakes requires Visual Studio Ultimate. Last, when using shims, the tests fail when running from Resharper ( 7.0 ) provided runner. This is a huge deal as my entire team uses Resharper and the tests must pass with the runner. There is a <a href="http://youtrack.jetbrains.com/issue/RSRP-328377">bug filed with JetBrains</a> and I am hoping it will be fixed soon. If you use the Nunit Test adpater and the VS 2012 Test runner, the tests pass, however.</p>
511511

blog/2012/11/18/why-i-love-jetbrains-teamcity-as-a-net-developer/index.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@
2323

2424
<p>What makes it even better is the amazing support for .NET. I find other tools severely lacking when it comes to .NET. As a .NET developer and DevOps person, I just love TeamCity. The attention and thought given by the developers in providing .NET related features is just amazing. There have been times when I was trying to see if TeamCity can do something and there would soon be a smile on my face when I realize that yes, it can. While TeamCity offers a plethora of features for the .NET develper / project, here I highlight my most favorite. These definitely make TeamCity indispensible as a CI server for a .NET project.</p>
2525

26-
<p><strong>Nuget Feed Server</strong> - This is something I was not really expecting. When we thought about using in-house Nuget packages in our projects, we started exploring options for hosting a Nuget feed. Setting up a Nuget server is not a big deal. You can even point towards a filesystem folder. We can write scripts that will copy the packages from the build and put it in a path where a feed application can pick it up and expose it. That is when I came across the fact that Teamcity itself can act as a feed server ( and the aforementioned smile was to be found on my face again.) All you have to do is, just artifact a <code class="highlighter-rouge">.nupkg</code> file like you would normally do in a Build configuration and voilà ! The package is available in the feed!</p>
26+
<p><strong>Nuget Feed Server</strong> - This is something I was not really expecting. When we thought about using in-house Nuget packages in our projects, we started exploring options for hosting a Nuget feed. Setting up a Nuget server is not a big deal. You can even point towards a filesystem folder. We can write scripts that will copy the packages from the build and put it in a path where a feed application can pick it up and expose it. That is when I came across the fact that Teamcity itself can act as a feed server ( and the aforementioned smile was to be found on my face again.) All you have to do is, just artifact a <code class="language-plaintext highlighter-rouge">.nupkg</code> file like you would normally do in a Build configuration and voilà ! The package is available in the feed!</p>
2727

2828
<p><strong>TeamCity Powershell Runner</strong> - Next comes the Powershell runner. While you can easily run any custom command from TeamCity, and hence can run powershell script and commands, having a runner for it makes for quick and easy setup.</p>
2929

3030
<p><img src="https://stacktoheap.com/images/teamcity-powershell.png" alt="TeamcityPowershell" /></p>
3131

32-
<p>Again, the runner is not a simple task that would just call Powershell and lets you specify a file that you want to run. You can specify if you want to use the 32-bit or 64-bit console. You can can specify a path to a file or specify the powershell source itself directly ( when you do the latter, you can also reference teamcity properties and those will be directly substituted in the source.) You can specify if the script is to be executed with Powershell by passing the <code class="highlighter-rouge">-File</code> option or by using the <code class="highlighter-rouge">-Command</code> option and pass in the script through stdin. Effectively, the runner covers all scenarios that you may want to use Powershell with. The setup is easy, clear and powerful.</p>
32+
<p>Again, the runner is not a simple task that would just call Powershell and lets you specify a file that you want to run. You can specify if you want to use the 32-bit or 64-bit console. You can can specify a path to a file or specify the powershell source itself directly ( when you do the latter, you can also reference teamcity properties and those will be directly substituted in the source.) You can specify if the script is to be executed with Powershell by passing the <code class="language-plaintext highlighter-rouge">-File</code> option or by using the <code class="language-plaintext highlighter-rouge">-Command</code> option and pass in the script through stdin. Effectively, the runner covers all scenarios that you may want to use Powershell with. The setup is easy, clear and powerful.</p>
3333

3434
<p><img src="https://stacktoheap.com/images/teamcity-runners.PNG" alt="TeamCityRunners" /></p>
3535

@@ -451,13 +451,13 @@ <h1 class="post-title" itemprop="name headline">Why I love Jetbrains TeamCity as
451451

452452
<p>What makes it even better is the amazing support for .NET. I find other tools severely lacking when it comes to .NET. As a .NET developer and DevOps person, I just love TeamCity. The attention and thought given by the developers in providing .NET related features is just amazing. There have been times when I was trying to see if TeamCity can do something and there would soon be a smile on my face when I realize that yes, it can. While TeamCity offers a plethora of features for the .NET develper / project, here I highlight my most favorite. These definitely make TeamCity indispensible as a CI server for a .NET project.</p>
453453

454-
<p><strong>Nuget Feed Server</strong> - This is something I was not really expecting. When we thought about using in-house Nuget packages in our projects, we started exploring options for hosting a Nuget feed. Setting up a Nuget server is not a big deal. You can even point towards a filesystem folder. We can write scripts that will copy the packages from the build and put it in a path where a feed application can pick it up and expose it. That is when I came across the fact that Teamcity itself can act as a feed server ( and the aforementioned smile was to be found on my face again.) All you have to do is, just artifact a <code class="highlighter-rouge">.nupkg</code> file like you would normally do in a Build configuration and voilà ! The package is available in the feed!</p>
454+
<p><strong>Nuget Feed Server</strong> - This is something I was not really expecting. When we thought about using in-house Nuget packages in our projects, we started exploring options for hosting a Nuget feed. Setting up a Nuget server is not a big deal. You can even point towards a filesystem folder. We can write scripts that will copy the packages from the build and put it in a path where a feed application can pick it up and expose it. That is when I came across the fact that Teamcity itself can act as a feed server ( and the aforementioned smile was to be found on my face again.) All you have to do is, just artifact a <code class="language-plaintext highlighter-rouge">.nupkg</code> file like you would normally do in a Build configuration and voilà ! The package is available in the feed!</p>
455455

456456
<p><strong>TeamCity Powershell Runner</strong> - Next comes the Powershell runner. While you can easily run any custom command from TeamCity, and hence can run powershell script and commands, having a runner for it makes for quick and easy setup.</p>
457457

458458
<p><img src="https://stacktoheap.com/images/teamcity-powershell.png" alt="TeamcityPowershell" /></p>
459459

460-
<p>Again, the runner is not a simple task that would just call Powershell and lets you specify a file that you want to run. You can specify if you want to use the 32-bit or 64-bit console. You can can specify a path to a file or specify the powershell source itself directly ( when you do the latter, you can also reference teamcity properties and those will be directly substituted in the source.) You can specify if the script is to be executed with Powershell by passing the <code class="highlighter-rouge">-File</code> option or by using the <code class="highlighter-rouge">-Command</code> option and pass in the script through stdin. Effectively, the runner covers all scenarios that you may want to use Powershell with. The setup is easy, clear and powerful.</p>
460+
<p>Again, the runner is not a simple task that would just call Powershell and lets you specify a file that you want to run. You can specify if you want to use the 32-bit or 64-bit console. You can can specify a path to a file or specify the powershell source itself directly ( when you do the latter, you can also reference teamcity properties and those will be directly substituted in the source.) You can specify if the script is to be executed with Powershell by passing the <code class="language-plaintext highlighter-rouge">-File</code> option or by using the <code class="language-plaintext highlighter-rouge">-Command</code> option and pass in the script through stdin. Effectively, the runner covers all scenarios that you may want to use Powershell with. The setup is easy, clear and powerful.</p>
461461

462462
<p><img src="https://stacktoheap.com/images/teamcity-runners.PNG" alt="TeamCityRunners" /></p>
463463

0 commit comments

Comments
 (0)