Home / ASP.NET Weblogs

Latest Microsoft Blogs

Browse by Tags

Related Posts

  • Building an HTML5 App with ASP.NET

    I’m teaching several JavaScript and ASP.NET workshops over the next couple of months (thanks everyone!) and I thought it would be useful for my students to have a really easy to use JavaScript reference. I wanted a simple interactive JavaScript reference and I could not find one so I decided to put together one of my own. I decided to use the latest features of JavaScript, HTML5 and jQuery such as local storage, offline manifests, and jQuery templates. What could be more appropriate than building a JavaScript Reference with JavaScript? You can try out the application by visiting: http://Superexpert.com/JavaScriptReference Because the app takes advantage of several advanced features of HTML5, it won’t work with Internet Explorer 6 (but really...


  • Integrating JavaScript Unit Tests with Visual Studio

    Modern ASP.NET web applications take full advantage of client-side JavaScript to provide better interactivity and responsiveness. If you are building an ASP.NET application in the right way, you quickly end up with lots and lots of JavaScript code. When writing server code, you should be writing unit tests. One big advantage of unit tests is that they provide you with a safety net that enable you to safely modify your existing code – for example, fix bugs, add new features, and make performance enhancements -- without breaking your existing code. Every time you modify your code, you can execute your unit tests to verify that you have not broken anything. For the same reason that you should write unit tests for your server code, you should write...


  • Moq Sequences Revisited

    A while back I wrote about mocking successive calls to the same method which returns a sequence of objects. Read that post for more context. In that post, I had written up an implementation, but quickly was won over by a better extension method implementation from Fredrik Kalseth . public static class MoqExtensions { public static void ReturnsInOrder<T, TResult>( this ISetup<T, TResult> setup, params TResult[] results) where T : class { setup.Returns( new Queue<TResult>(results).Dequeue); } } As good as this extension method is, I was able to improve on it today during a coding session. I was writing some code where I needed the second call to the same method to throw an exception and realized this extension wouldn’t allow...


  • 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...


Page 1 of 4 (36 items) 1 2 3 4 Next >

Archives