Skip to content

{ Tag Archives } unit testing

Designing for Problems Too Big to Test

In this post, I will show an example of where using unit testing as a design methodology does not work, and how to produce a design for correct code anyway. There is no single design methodology which works for all problems, so it’s useful to have a variety of tools at your disposal.
This post is [...]

Also tagged ,

Testing Cross Cutting Concerns

So imagine you’ve been asked to implement the following requirement:
When a to-do list item is marked as complete, the CompletedOn date time property shall be set to the current time.
That doesn’t sound so hard to implement, but how can I test it? I don’t know precisely what the value of the CompletedOn property "should be" [...]

Also tagged , ,

Unit Testing Html Helpers for ASP.NET MVC

Html helpers for ASP.NET MVC are static extension methods, which frequently reference the ViewContext and  HttpContext. Combined, this can make unit testing a bit tricky. Let’s write a new Html helper using a test-first methodology. Let’s start with a prototype function:

        public static MvcHtmlString MyTable(this HtmlHelper helper, MyModel model, IDictionary<string, object> htmlAttributes)
            return MvcHtmlString.Empty;

I’ve added just enough code here to get the prototype to compile. Now let’s write [...]

Also tagged , , , ,

Columbus Give Camp

This past weekend I, along with around 50 other local geeks, volunteered three days of my time to build web applications for eight different Columbus-area nonprofits. Columbus Give Camp is based on a similar series of events in Michigan. The Columbus Give Camp was hosted by Quick Solutions, who, conveniently, are located five floors above [...]

Also tagged , , ,

Using jqGrid with ASP.NET MVC: Understanding LINQ Errors

If you spend enough time with the PagedList class that I’ve been using for paging in the method which supplies data to jqGrid, it’s a near-certainty that sooner or later you will see a LINQ error with Count in the call stack. The error may seem confusing, because it has nothing to do with Count. [...]

Also tagged , , , , ,

SQLDA missing or incorrect version, or incorrect number/type of variables

The error in the title comes from InterBase. Actually, the full error is:
[DataDirect][ODBC InterBase driver][InterBase]Dynamic SQL Error, SQL error code = -804, SQLDA missing or incorrect version, or incorrect number/type of variables.
I’ve seen this error before when the wrong InterBase client (gds32.dll) version was loaded by the application, or when the wrong number of variables [...]

Also tagged , , , ,

Testing Is a Legitimate Use Case

How should you unit test private methods? It depends. Some say you shouldn’t do it at all. Others say you should test everything. Who is right?
The problem that I have with a statement like, "Don’t test private methods," is that it is a circular argument. That a method is private implies that you don’t want [...]

Also tagged

How to Unit Test a Data Module

Data modules are unit tested in exactly the same way that you would unit test any other piece of code. That is, by refactoring the code to be tested in such a way as to separate it from code not relevant to the test. But since people occasionally seem to find this confusing, perhaps a practical example is in order.

Also tagged

Moq and MvcMockHelpers

I’m working on some unit tests for an ASP.NET MVC application I’m developing.  One of the tests ensures that if I construct a URL using Html.ActionLink that the URL which is returned, when fed into the routing system, becomes a correct representation of the route data used to build the URL originally.  I’ll discuss this [...]

Also tagged , ,

Bad Behavior has blocked 978 access attempts in the last 7 days.