Latest Microsoft Blogs

Browse by Tags

Related Posts

  • Successive Method Calls With MoQ

    One area where using MoQ is confusing is when mocking successive calls to the same method of an object. For example, I was writing some tests for legacy code where I needed to fake out multiple calls to a data reader. You remember data readers, don’t you? Here’s a snippet of the code I was testing. Ignore the map method and focus on the call to reader.Read . while (reader.Read()) { yield return map(reader); } Notice that there are multiple calls to reader.Read . The first couple times, I wanted Read to return true . The last time, it should return false . And here’s the code I hoped to write to fake this using MoQ: reader.Setup(r => r.Read()).Returns( true ); reader.Setup(r => r.Read()).Returns( true ); reader.Setup(r => r.Read()).Returns...


  • Unit Testing JavaScript with FireUnit

    I’ve been investigating different unit testing frameworks for JavaScript lately and I stumbled onto FireUnit. FireUnit is a unit testing framework created by John Resig (of well-deserved jQuery fame) and Jan Odvarko. In this blog entry, I provide a brief overview of the FireUnit testing framework. In particular, I explain how you can use FireUnit to unit test JavaScript code. Installing FireUnit FireUnit is implemented as a FireFox extension. This is both bad and good. First, the bad news. You cannot use FireUnit with Internet Explorer, Safari, Chrome, or any other browser than Mozilla Firefox. Here’s the good news. FireUnit extends Firefox with a new Test tab. This Test tab appears as an extra Firebug tab. Therefore, seeing test results is...


  • TDD Tests are not Unit Tests

    The motivation for this blog entry is to explain the nature and purpose of the tests used in Test-Driven Development. To avoid confusion, I’ll use the expression TDD test to refer to the type of test used in the context of Test-Driven Development. The goal of this blog entry is to clarify the relationship among TDD tests, unit tests, and acceptance tests. TDD Tests are not Unit Tests Let’s start with the distinction between TDD tests and unit tests. On the surface, TDD tests are very similar to unit tests. This is not surprising, since you use a unit testing framework such as Visual Studio Tests or NUnit to create both types of tests. The purpose of a unit test is to test a unit of code in isolation. For example, you might create a unit test...


  • Test-After Development is not Test-Driven Development

    Recently, I had a disagreement with a colleague over the correct way to do Test-Driven Development. This is an important disagreement because it affects the design of the ASP.NET MVC framework. According to my co-worker (let’s call him Tad), there is no difference between Test-First Development and Test-After Development “except when you write your unit tests.” Tad is a practitioner and proponent of Test-After Development. When you practice Test-After Development, you write application code first and then you write a unit test that tests the application code. From the perspective of someone who practices Test-Driven Development , this gets things backwards. I believe that it is an essential part of Test-Driven Development that you must write...


  • ASP.NET MVC Workshop Code

    Thank you everyone who came to my one day ASP.NET MVC workshop at ASP.NET Connections. We managed to build an entire Movie Database application with unit tests and a reasonably good design -- Congratulations! I've attached the Movie Database application and the demo code from the workshop below. Workshop Code Read More...


  • Speaking at ASP.NET Connections Next Week

    I will be in Orlando, Florida next week speaking at the ASP.NET Connections conference in Orlando, Florida. I'm giving 5 separate talks. I'm presenting two talks on Microsoft day: ASP.NET MVC: A New Framework for Building Web Applications ASP.NET MVC is Microsoft’s newest framework for building web applications. In this session, you learn how to take advantage of ASP.NET MVC to build loosely coupled and highly testable applications. Over the course of this session, we build a simple database-driven Web application from start to finish. You learn how to use several features of the ASP.NET MVC framework including Model Binders, Partials, and AJAX helpers. ASP.NET: Taking AJAX to the Next Level Hear how ASP.NET AJAX 4.0 makes building pure...


  • ASP.NET MVC Sample Application at www.ASP.net/MVC

    We posted a complete Contact Manager sample ASP.NET MVC Application at the www.ASP.net/mvc website. The source code is available in both C# and VB.NET. The application is intentionally simple. The goal was to provide members of the ASP.NET community with an application that they could use to quickly learn how to build new applications with ASP.NET MVC. The Contact Manager application is an address book application. The application enables you to list, create, edit, and delete contacts. I built the application over multiple iterations. With each iteration, I gradually improved the application. The goal of this multiple iteration approach was to enable you to understand the reason for each change. Iteration #1 – Create the application. In the...


  • T4 Templates: A Quick-Start Guide for ASP.NET MVC Developers

    As mentioned in our recent blog post on the ASP.NET MVC Release Candidate , our code-generation features (namely, Add Controller and Add View) now use the T4 (Text Template Transformation Toolkit) templating technology behind the scenes. Because users can customize the templates to a great extent, we wanted to make a post to bring everyone up to speed on T4. Template Locations and Template Override The Add Controller and Add View dialogs both perform code generation that use T4 templates behind the scenes. These templates can be modified to customize the generated code from these tools. You can find the templates at the following location: [Visual Studio Install Directory]\Common7\IDE\ItemTemplates\[CSharp | VisualBasic]\Web\MVC\CodeTemplates...


  • What’s New For MVC Tools in the ASP.NET MVC 1.0 Release Candidate

    The ASP.NET MVC 1.0 Release Candidate (RC) is finally out, and we wanted to give returning MVC users as well as new MVC users an overview of what the tooling in Visual Studio provides. The MVC 1.0 RC can be downloaded right now here ( Release Notes ). Please note that this release will work with both Visual Studio 2008 and Visual Web Developer Express 2008 SP1 (free download). In case you missed it, be sure to also read ScottGu’s blog post on the RC for some great information (including runtime changes!): http://weblogs.asp.net/scottgu/archive/2009/01/27/asp-net-mvc-1-0-release-candidate-now-available.aspx Project Templates The MVC installer provides project templates for use in Visual Studio. If you visit the new project dialog (File –>...


  • Speaking at Tech-Ed 2008 Hong Kong

    If you happen to be in Asia around October 8-10, I’ll be speaking at Tech-Ed Hong Kong . Come by and say hi. I’m giving three talks, one on each day. October 8 11:45 AM – 1:00 PM ASP.NET MVC - An alternative approach to building Web Applications October 9 11:00 AM – 12:15 PM Developing Data Driven Applications Using ASP.NET Dynamic Data October 10 9:30 AM – 10:45 AM Write better designed code with Test Driven Development I’m hoping to have a little time after some of my talks to go do a little sight-seeing around Hong Kong. The trip to Hong Kong is actually a side trip from Japan where my wife and kid will stay while I go and and speak at this conference. I’m looking forward to the vacation, but wish I had scheduled the vacation part after the...


Page 1 of 4 (33 items) 1 2 3 4 Next >
Microsoft Communities