You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<p>The <codeclass="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 <codeclass="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>
<p>The JSON schema is written as per the <ahref="http://json-schema.org/">proposed draft</a> and JSON.NET’s <codeclass="highlighter-rouge">IsValid()</code> is used to perfom the validation itself.</p>
481
+
<p>The JSON schema is written as per the <ahref="http://json-schema.org/">proposed draft</a> and JSON.NET’s <codeclass="language-plaintext highlighter-rouge">IsValid()</code> is used to perfom the validation itself.</p>
482
482
483
483
<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>
<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>
57
57
58
-
<p>The fakes generated by Fakes follow some naming conventions. Without going into the details, the original type <codeclass="highlighter-rouge">ToggledExtensions</code> is replaced with <codeclass="highlighter-rouge">Fakes.ShimToggleExtensions</code> and the <codeclass="highlighter-rouge">IsOn</code> method in it which takes in a <codeclass="highlighter-rouge">IToggled</code> ( like a normal static method would, but in this an extension method) is called <codeclass="highlighter-rouge">IsOnIToggled</code>. The shim being provided is the lambda <codeclass="highlighter-rouge">toggled => true</code>. That is return true for any <codeclass="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 <codeclass="language-plaintext highlighter-rouge">ToggledExtensions</code> is replaced with <codeclass="language-plaintext highlighter-rouge">Fakes.ShimToggleExtensions</code> and the <codeclass="language-plaintext highlighter-rouge">IsOn</code> method in it which takes in a <codeclass="language-plaintext highlighter-rouge">IToggled</code> ( like a normal static method would, but in this an extension method) is called <codeclass="language-plaintext highlighter-rouge">IsOnIToggled</code>. The shim being provided is the lambda <codeclass="language-plaintext highlighter-rouge">toggled => true</code>. That is return true for any <codeclass="language-plaintext highlighter-rouge">IToggled</code> instance. Then there is a pretty standard assert.</p>
59
59
60
60
<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 <ahref="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>
61
61
@@ -479,7 +479,7 @@ <h1 class="post-title" itemprop="name headline">Testing extension methods with M
479
479
480
480
<p>Now, we can easily add a shim that replaces the actual extension method. A standard test would look like below:</p>
@@ -505,7 +505,7 @@ <h1 class="post-title" itemprop="name headline">Testing extension methods with M
505
505
506
506
<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>
507
507
508
-
<p>The fakes generated by Fakes follow some naming conventions. Without going into the details, the original type <codeclass="highlighter-rouge">ToggledExtensions</code> is replaced with <codeclass="highlighter-rouge">Fakes.ShimToggleExtensions</code> and the <codeclass="highlighter-rouge">IsOn</code> method in it which takes in a <codeclass="highlighter-rouge">IToggled</code> ( like a normal static method would, but in this an extension method) is called <codeclass="highlighter-rouge">IsOnIToggled</code>. The shim being provided is the lambda <codeclass="highlighter-rouge">toggled => true</code>. That is return true for any <codeclass="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 <codeclass="language-plaintext highlighter-rouge">ToggledExtensions</code> is replaced with <codeclass="language-plaintext highlighter-rouge">Fakes.ShimToggleExtensions</code> and the <codeclass="language-plaintext highlighter-rouge">IsOn</code> method in it which takes in a <codeclass="language-plaintext highlighter-rouge">IToggled</code> ( like a normal static method would, but in this an extension method) is called <codeclass="language-plaintext highlighter-rouge">IsOnIToggled</code>. The shim being provided is the lambda <codeclass="language-plaintext highlighter-rouge">toggled => true</code>. That is return true for any <codeclass="language-plaintext highlighter-rouge">IToggled</code> instance. Then there is a pretty standard assert.</p>
509
509
510
510
<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 <ahref="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>
Copy file name to clipboardExpand all lines: blog/2012/11/18/why-i-love-jetbrains-teamcity-as-a-net-developer/index.html
+4-4Lines changed: 4 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -23,13 +23,13 @@
23
23
24
24
<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>
25
25
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 <codeclass="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 <codeclass="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>
27
27
28
28
<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>
<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 <codeclass="highlighter-rouge">-File</code> option or by using the <codeclass="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 <codeclass="language-plaintext highlighter-rouge">-File</code> option or by using the <codeclass="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>
@@ -451,13 +451,13 @@ <h1 class="post-title" itemprop="name headline">Why I love Jetbrains TeamCity as
451
451
452
452
<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>
453
453
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 <codeclass="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 <codeclass="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>
455
455
456
456
<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>
<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 <codeclass="highlighter-rouge">-File</code> option or by using the <codeclass="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 <codeclass="language-plaintext highlighter-rouge">-File</code> option or by using the <codeclass="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>
0 commit comments