<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Unit Testing on dwmkerr.com</title><link>https://dwmkerr.com/categories/unit-testing/</link><description>Recent content in Unit Testing on dwmkerr.com</description><generator>Hugo -- gohugo.io</generator><language>en-uk</language><managingEditor>Dave Kerr</managingEditor><copyright>Copright &amp;copy; Dave Kerr</copyright><lastBuildDate>Mon, 25 Nov 2013 16:16:09 +0000</lastBuildDate><atom:link href="https://dwmkerr.com/categories/unit-testing/index.xml" rel="self" type="application/rss+xml"/><item><title>Introducing Practical AngularJS</title><link>https://dwmkerr.com/introducing-practical-angularjs/</link><pubDate>Mon, 25 Nov 2013 16:16:09 +0000</pubDate><guid>https://dwmkerr.com/introducing-practical-angularjs/</guid><description>&lt;p&gt;I was recently at Devoxx in Antwerp, primarily because I wanted to get involved in some of the sessions that were being hosted by guys from the AngularJS team at Google. I&amp;rsquo;ve had a chance to work a little with Backbone and KnockoutJS and had been recently deliberately holding off looking at AngularJS so I could hit the conference and workshops fresh and unencumbered with any preconceptions.&lt;/p&gt;
&lt;p&gt;The sessions were great, and since then I&amp;rsquo;ve been working on a couple of projects that use Angular. As I&amp;rsquo;ve always found writing about a topic a great way to really cement what you know about it, and to understand where the holes in your knowledge are, I&amp;rsquo;ve started a new series of articles called &amp;lsquo;&lt;a title="Practical AngularJS" href="http://www.dwmkerr.com/practical-angularjs/"&gt;Practical AngularJS&lt;/a&gt;&amp;rsquo;.&lt;/p&gt;
&lt;p&gt;This series is a little different to others I&amp;rsquo;m working on at the moment (such as the seemingly &lt;a title=".NET Shell Extensions - Shell Context Menus" href="http://www.codeproject.com/Articles/512956/NET-Shell-Extensions-Shell-Context-Menus" target="_blank"&gt;endless SharpShell articles&lt;/a&gt; and &lt;a title="Space Invaders" href="http://www.codeproject.com/Articles/681130/Learn-JavaScript-Part-2-Space-Invaders" target="_blank"&gt;Learn JavaScript&lt;/a&gt; which is taking some time) as I&amp;rsquo;m writing it on my own blog rather than on the CodeProject. The reason behind this is purely push me into getting better at handling my blog (particularly the code samples) and because the code I&amp;rsquo;m writing doesn&amp;rsquo;t need to be associated with download links and so on, it can all be in fiddles.&lt;/p&gt;
&lt;p&gt;Anyway, enough chatter - part one of Practical AngularJS is now finished. It&amp;rsquo;s a new series, so it&amp;rsquo;s early enough to have a say in where it goes, please comment and share and let me kn0w whether you find it useful, pointless, or anything in-between.&lt;/p&gt;
&lt;p&gt;As a short teaser, in &lt;a title="Practical AngularJS Part 1 – Introducing AngularJS" href="http://www.dwmkerr.com/practical-angularjs-part1" target="_blank"&gt;Practical AngularJS Part 1 - Introducing AngularJS&lt;/a&gt; we take a look at what AngularJS is, why we&amp;rsquo;d consider using it and when. We start out with a trivial task for a web application, and see how it quickly becomes a bit sluggish and painful to do certain things, then see how using AnguarJS can ease that pain, letting us focus on the important stuff and it help out with the grunt work. We take our initially messy app and make it a lot more manageable, and look into how we can with our new structure start to write unit tests for the logic.&lt;/p&gt;
&lt;p&gt;So this is the bulk of Part 1. Unless there&amp;rsquo;s a strong push for another topic, Part 2 will focus on testing. Testing is core to the development ideals of the AngularJS project and is something that it was built in mind for. We&amp;rsquo;ll look into how quickly we can write unit tests, and the flexibility that we&amp;rsquo;ve got.&lt;/p&gt;
&lt;p&gt;Rather than advocating patterns such as BDD or TDD, we&amp;rsquo;ll again shy away from theoretical discussions about what is conceptually the best paradigm and just dig in - playing with the code and seeing what works and what doesn&amp;rsquo;t. By the end of it you&amp;rsquo;ll have a good idea of the freedom you&amp;rsquo;ve got with testing - leaving it up to you to choose the pattern or process that fits your style, or the style of your team and project the best.&lt;/p&gt;</description><category>CodeProject</category></item><item><title>Getting Paths for Files in NUnit Tests</title><link>https://dwmkerr.com/getting-paths-for-files-in-nunit-tests/</link><pubDate>Thu, 02 May 2013 05:22:45 +0000</pubDate><guid>https://dwmkerr.com/getting-paths-for-files-in-nunit-tests/</guid><description>&lt;p&gt;When using NUnit, sometimes you will want to access files in the test project. These might be xml files with data, assembly references or whatever. Now typically, NUnit will actually copy the files it thinks it needs into a temporary location. This causes the problem that you can then do things like use a relative path to get files in the project. You can use manifest resource streams but sometimes this just isn&amp;rsquo;t suitable.&lt;/p&gt;
&lt;p&gt;To get the path of the root of your test project, you can use the snippet below. Make sure you call it in a unit test fixture that&amp;rsquo;s actually in your test project, not from a class referenced in another project!&lt;/p&gt;
&lt;p&gt;This class, &amp;lsquo;TestHelper&amp;rsquo; can be included in a Unit Test project to let you quickly get the path to the test project.&lt;/p&gt;
&lt;p&gt;[code lang=&amp;ldquo;csharp&amp;rdquo;]public static class TestHelper
{
public static string GetTestsPath()
{
return Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase).Replace(@&amp;quot;file:&amp;amp;quot;, string.Empty);
}
}[/code]&lt;/p&gt;</description><category>CodeProject</category></item></channel></rss>