<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Unit Testing on Bryan Avery</title><link>https://bryanavery.co.uk/categories/unit-testing/</link><description>Recent content in Unit Testing on Bryan Avery</description><generator>Hugo -- gohugo.io</generator><language>en-GB</language><copyright>© 2026 Bryan Avery.</copyright><lastBuildDate>Mon, 25 Jan 2021 11:26:30 +0000</lastBuildDate><atom:link href="https://bryanavery.co.uk/categories/unit-testing/index.xml" rel="self" type="application/rss+xml"/><item><title>Unit Test Boilerplate Generator</title><link>https://bryanavery.co.uk/unit-test-boilerplate-generator/</link><pubDate>Mon, 25 Jan 2021 11:26:30 +0000</pubDate><guid>https://bryanavery.co.uk/unit-test-boilerplate-generator/</guid><description>&lt;p&gt;I love this smart template generator, saves so much time and effort.&lt;/p&gt;&#10;&lt;p&gt;Generates a unit test boilerplate from a given C# class, setting up mocks for all dependencies. Right click an item in Solution Explorer and choose “Create Unit Test Boilerplate” . Supports Visual Studio Test, NUnit, xUnit and many mock frameworks.&lt;/p&gt;</description></item><item><title>Async Unit Tests</title><link>https://bryanavery.co.uk/async-unit-tests/</link><pubDate>Tue, 10 Apr 2018 07:38:55 +0000</pubDate><guid>https://bryanavery.co.uk/async-unit-tests/</guid><description>&lt;p&gt;In theory, Async unit testing seems easy, run the Async, wait until it is finished and look at the results.  But as you will find out it is not that easy.&lt;/p&gt;&#10;&lt;p&gt;Here is the official approach to Async unit testing&lt;/p&gt;</description></item><item><title>Create a subset of Unit Tests with a Playlist</title><link>https://bryanavery.co.uk/create-a-subset-of-unit-tests-with-a-playlist/</link><pubDate>Wed, 07 Mar 2018 10:48:30 +0000</pubDate><guid>https://bryanavery.co.uk/create-a-subset-of-unit-tests-with-a-playlist/</guid><description>&lt;p&gt;Visual Studio Unit Test Tools comes with another excellent feature to manage unit test as a group /subset, called as “Playlist”. A Playlist is a subset of unit test methods grouped under some category. The Playlist could be a logical subset based on modules, features, layers etc. A Playlist is useful when we want to test a particular set of test cases among all the test methods. In that case, we just create a group of those test cases which may get impacted by our current changes in the actual code, and execute them only to ensure nothing breaks.&lt;/p&gt;</description></item><item><title>Make Fake MVC Objects for testing</title><link>https://bryanavery.co.uk/make-fake-mvc-objects-for-testing/</link><pubDate>Thu, 19 Dec 2013 11:53:00 +0000</pubDate><guid>https://bryanavery.co.uk/make-fake-mvc-objects-for-testing/</guid><description>&lt;p&gt;If you need to create some Fake MVC objects for testing MVC objects then here you are:&lt;/p&gt;&#10;&lt;h2&gt;FakeControllerContext&lt;/h2&gt;&#10;&lt;pre class="brush: c-sharp;"&gt;using System.Collections.Specialized;&#10;using System.Web;&#10;using System.Web.Mvc;&#10;using System.Web.Routing;&#10;using System.Web.SessionState;&#10;&lt;p&gt;using MvcContrib.TestHelper.Fakes;&lt;/p&gt;&#10;&lt;p&gt;public class FakeControllerContext : ControllerContext&#10;{&#10;public FakeControllerContext(IController controller)&#10;: this(controller, null, null, null, null, null, null)&#10;{&#10;}&lt;/p&gt;&#10;&lt;pre&gt;&lt;code&gt;public FakeControllerContext(IController controller, HttpCookieCollection cookies)&#10; : this(controller, null, null, null, null, cookies, null)&#10;{&#10;}&#10;&#10;public FakeControllerContext(IController controller, SessionStateItemCollection sessionItems)&#10; : this(controller, null, null, null, null, null, sessionItems)&#10;{&#10;}&#10; &#10;public FakeControllerContext(IController controller, NameValueCollection formParams)&#10; : this(controller, null, null, formParams, null, null, null)&#10;{&#10;}&#10; &#10;public FakeControllerContext(IController controller, NameValueCollection formParams, NameValueCollection queryStringParams)&#10; : this(controller, null, null, formParams, queryStringParams, null, null)&#10;{&#10;}&#10; &#10;public FakeControllerContext(IController controller, string userName)&#10; : this(controller, userName, null, null, null, null, null)&#10;{&#10;}&#10; &#10;public FakeControllerContext(IController controller, string userName, string[] roles)&#10; : this(controller, userName, roles, null, null, null, null)&#10;{&#10;}&#10; &#10;public FakeControllerContext&#10; (&#10; IController controller,&#10; string userName,&#10; string[] roles,&#10; NameValueCollection formParams,&#10; NameValueCollection queryStringParams,&#10; HttpCookieCollection cookies,&#10; SessionStateItemCollection sessionItems&#10; )&#10; : base(new FakeHttpContext(new FakePrincipal(new FakeIdentity(userName), roles), formParams, queryStringParams, cookies, sessionItems), new RouteData(), (Controller)controller)&#10;{ }&#10;&lt;/code&gt;&lt;/pre&gt;&#10;&lt;p&gt;}&lt;/pre&gt;</description></item><item><title>Unit Testing a Private Method</title><link>https://bryanavery.co.uk/unit-testing-a-private-method/</link><pubDate>Tue, 17 Dec 2013 11:11:00 +0000</pubDate><guid>https://bryanavery.co.uk/unit-testing-a-private-method/</guid><description>&lt;p&gt;With Visual Studio keep changing the way you create unit tests I thought I’d document down how to test a private method the easy way.&lt;/p&gt;&#10;&lt;p&gt;Here is a simple HomeController and we want to test that the GetPageSize method return 20 in a unit test.&lt;/p&gt;</description></item></channel></rss>