• February 2024
    M T W T F S S
  • Latest Posts

  • Latest Comments

  • Archives

Posts Tagged ‘Unit Testing’

Unit Testing HandleErrorAttribute

Code Analysis doesn’t like the former MVC pattern of using a catch for all errors when updating a model. I wanted to use the HandleError attribute to deal with errors, but how should I unit test it? There are several keys to having the HandleError attribute work: Must decorate the Action with [HandleError] Must have […]

SmtpClient.Dispose() Bummer

Headline: You will need to put in some try/catch logic when you call dispose on the SmtpClient. I was working on getting rid of some of my code analysis warnings – “Warning    10    CA2000 : Microsoft.Reliability : In method ‘AccountMembershipService.SendActivationEmail(HttpContextBase, string, Guid, string, string)’, object ‘client’ is not disposed along all exception paths. Call System.IDisposable.Dispose […]

Silverlight 5 Announcement

I was glad to see Scott Guthrie’s blog post Announcing Silverlight 5 posted last Thursday. If you have read my recent posts you know there are many points of Silverlight that have disappointed me. As someone that only has 64-bit computers, believes in TDD (Test Driven Development), and appreciates the MVVM (Model-View-ViewModel) pattern, Silverlight seems […]

MVC Team Should Rule

Headline: I don’t think I’ve seen a team more focused on testability at Microsoft than the ASP.NET MVC (Model-View-Controller) team. I sure hope their unit testing philosophy starts to influence other teams more. Entity Framework If you use any of the patterns for the Entity Framework (one of the early versions of .NET 4.0 that […]

No Silverlight Unit Test Integration with TFS?

Well, the excitement of the last post lasted about 18 seconds. Now I need to slog through this post about “Integrating Silverlight Unit Tests into Build Process”. Must Use Silverlight Unit Tests In the last post I was doing unit testing with a regular unit test project. That integrates with TFS (Team Foundation Server) quite […]

Reusable Library Naming

I plan to call my projects KarlZ.Silverlight.* while the assemblies they produce will be called KarlZ.*. Then I’ll link from the Silverlight project to the existing files in the normal .NET projects. The Problem – Different CLRs I’d like to use both MVC (Model-View-Controller) and Silverlight presentation tiers. My development and test environment for MVC […]

Unit Testing a Very Simple ViewResult in MVC

Technorati Tags: Unit Testing,MVC,VS 2010 I have a view that really only provides content, is there a quick way to test that it exists? What’s the Assert? There’s really not much to unit test if you have a page that has only HTML in a MVC (Model-View-Controller) project. And to some extent, if you had […]

Unit Testing CodeSmith Insight

Technorati Tags: Unit Testing,MVC,Moq,CodeSmith,Insight As anyone that knows me knows, I use test driven development. So when I put together a Feedback page in my MVC (Model-View-Controller) site I started with my test. What should the test be? Let’s start with the User Story : As a site user (anonymous or logged in) I want […]

Unit Test Authorize Attribute

Technorati Tags: Unit Testing,ASP.NET,MVC,VS 2010 Story: I want to write a unit test to ensure that the Authorize attribute is applied to a controller ActionResult or ViewResult so that security is tested. Here is the test: Unit Test [TestMethod] public void PreviousSiteUserConversion_Authorization_Attributes_Have_Been_Applied() {     // Arrange     MethodInfo varietalMethod = typeof(AdminController).GetMethod("PreviousSiteUserConversion", new Type[] { });       // […]

MVC – The Start

Technorati Tags: ASP.NET,MVC,Code Analysis,Unit Testing This shows my initial setup of an MVC 2 RC 2 application. Using Visual Studio 2010 RC I selected File –> New –> Project… then under Visual C#, Web, I selected the ASP.NET MVC 2 Web Application. Then when I click OK I get the following dialog. Since I’m a […]