Martyn

Martyn Bullerwell's Blog

A New NUnit - xUnit.NET

As the .NET framework has moved on significantly since the introduction NUnit, the new framework needs to be more inline with the newer releases of the .NET framework, namely .NET 3.5 in Visual Studio 2008.  NUnit was widely accepted to support test driven development and became the defacto standard for test driven development, however lacked much support for other testing such as automated acceptance testing.  With this in mind XUnit has been developed which is a new testing framework, built upon NUnit.

Downloads are available here: xUnit.net

You will need .NET 2.0 or above, to install as it will not work on .Net 1.x, however you do not need visual studio!

Some Key Improvements include:

  • No Set up or Tear Down - This is no longer required although can be implemented, is now seen as an un-required overhead.
  • No Expected Exception
  • Aspect-Like Functionality - Support for example, to rollback database changes during testing
  • Reduction in custom attributes - such as TextFixture, SetUp, TearDown, ExpectedException and TestFixtureSetUp and Down.
  • Use of .NET 2.0 Generics - Allows more concise Assertions
  • Use of  .NET 2.0 Ananomys Delegates
  • Console based Test Runner (Unfortunately NO GUI yet...)
  • Assert extensibility - Allows custom comparers to be written, allowing for example, a Date comparer
  • Method extensibility - see  http://shareandenjoy.saff.net/2006/12/new-paper-practice-of-theories.html.
  • Class extensability - the definiation of Run test can be extended.

All in all it xUnit seems to have been stripped down form NUnit, however leveraging the .NET framework enhancements will make this new framework more extensible, and allow a more diverse range of automated testing and test driven development.

Dev Connection Conference

November 5-8, 2007
Mandalay Bay Resort and Casino -Las Vegas

Celebrating the release of Visual Studio 2008 (ORCA), and introducing SQL Server 2008 and Windows Server 2008.

Co-located with SQL Server Connections will be: Microsoft® ASP.NET Connections, Visual Studio Connections and SharePoint Connections.

 

Register here

XML and LINQ

LINQ and XML can be used to construct, write and read XML in any .NET language.  It simplifies XML reading and writing WITHOUT using XPATH or XSLT.  Don't get me wrong, this does not replace legacy functions from the XML class library, merely overlaps the functionality and eases development. One aspect of LINQ to XML is that it supports writing Query Expressions and can be combined with any of the other LINQ technologies to create or use XML data as a source or destination format.

Creating a new XML file with LINQ, some key elements and required:

XDocument
XElement
XAttribute

We can build an XML document using the following syntax

XElement xml = new XElement("Albums",
                        new XElement("Album",
                        new XAttribute("albumId", "2"),
                        new XElement("artistName", "Dave Matthews"),
                        new XElement("yearReleased", "2000")
                    ),
                    new XElement("Album",
                        new XAttribute("albumId", "3"),
                        new XElement("artistName", "John Mayer"),
                        new XElement("yearReleased", "2003")
                    )
                );
 
Console.WriteLine(xml);

 

Which in turn will produce:

 

<Albums>
  <Album albumId="2">
    <artistName>Dave Mathews</artistName>
    <yearReleased>2000</yearReleased>
  </Album>
  <Album albumId="3">
    <artistName>John Meyer</artistName>
    <yearReleased>2003</yearReleased>
  </Album>
</Albums>

 

Later we will dscuss how we can read and query against XML data.

LINQ Examples

Now available on MSDN, there are 101 LINQ examples.  This showcases how simple it can be to integrate LINQ within your future application. 

The List is Broken down into separate operations, however its all you need to get up and running with LINQ and ORCAS.

Check it out here: 101 LINQ Samples

LINQ

The LINQ Project is fast becoming one of the most anticipated integrated technologies in Visual Studio 2008 (ORCAS).  LINQ is simply a set of extensions to the .NET framework that encompass language-integrated query, set, and transform operations. It extends C# and Visual Basic with native language syntax for queries and provides class libraries to take advantage of these capabilities.

Microsoft have seen that the next big challenge in programming technology is to reduce the complexity of accessing and integrating information that is not natively defined using OO technology. The two most common sources of non-OO information are relational databases and XML.

Put simply, the new extensions, allow you to easily perform database type queries directly in code! Standard query operators allow queries to be applied to any IEnumerable<T> based information source. 

Here are some sample snippets, taken straight from Microsoft's web site...

 

using System;
using System.Linq;
using System.Collections.Generic;

class app

{
static void Main()

{
  string[] names = { "Burke", "Connor", "Frank",
 "Everett", "Albert", "George",
 "Harris", "David" };

    IEnumerable<string> query = from s in names
    where s.Length == 5
    orderby s
    select s.ToUpper();

   foreach (string item in query)  Console.WriteLine(item);
 }
}

As you can see in this very simple snippet of code, the idea is to mimic syntax of T-SQL, and if it is as good as it looks so far we may have a lot more to say on it....

I'm sure there will be more to come!

ORCAS CTP..... What's in it?

 

The March CTP release of ORCAS (Visual Studio 2008) incorporates a number of new and exciting technologies, as well as enhancing some of the older greats.   The current release of the IDE implements tools and functionality supporting LINQ (Microsoft's .NET Extensions, Language Integration Query), AJAX, Windows Presentation Foundation (codenamed CIDER), Windows Communication Foundation, Windows Workflow Foundation and the .NET framework 3.5 (downloaded separately).  According to Microsoft the latest framework will support applications built in .NET 2.0 and 3.0.  Further to this raft of newly integrated features, it also extends role-based and Team System collaboration features.

Traditionally, Microsoft offers a Go Live license at beta 2, and that will almost certainly be the case here. Microsoft have saturated the market with new capabilities, and many of these platforms and technologies represent the culmination of years of work.

More on LINQ and ORCAS in coming posts...

Microsoft Silverlight

Microsoft Silverlight is to be introduced with Visual Studio 2008, and supports C#, VB and AJAX, and will integrate with current web technologies. 

Silverlight has been compared with Flash many a time, and it seems that is likely to come down to adoption of Silverlight.  Currently flash is the obvious choice for bringing multi media experiences to the web, and applications that run on a web platform. 

What we will be looking into is the potential use of Silverlight in business applications.  We will be keeping an eye on Silverlight and its potential use within business applications.

However, given the full integration with the CLR and ability to code in C#, the usages of Silverlight could be endless.  Here are a few Items to consider:

  1. WMV Playback on PC and Mac, Supports full-screen 720p video offers seamless transitions between full-screen and windowed mode without losing your position in the video
  2. Separates markup (XAML) from code, Silverlight provides a familiar web metaphor for designers and developers.
  3. Silverlight and HTML integrate seamlessly together. overlay HTML elements on top of Silverlight content. 
  4. Embed XAML directly into your HTML pages; There are only three steps necessary to add animation or media:
    1. Include a standard JavaScript file in your HTML header;
    2. Call a function to create the Silverlight object anywhere on the screen;
    3. Add some XAML content (an animation, some media) for runtime delivery.
  5. Full runtime interactivity with Silverlight content. The contents of the XAML file can be completely server-generated, to contain information populated from a database. There's nothing that you can only create or manipulate at design-time.
  6. Silverlight is around 1MB download on a PC, it supports Windows XP and above, with Windows 2000 support to come.
  7. Silverlight is blindingly fast; you can play many videos simultaneously without stuttering or dropping frames
  8. Silverlight is both client- and server-agnostic. No need for any Microsoft software on the server - you can deliver a great Silverlight experience from an Apache / Linux server to a Mac OS 10.4 client.
  9. Silverlight is almost 100% upward compatible with WPF. Animation, 2D vector graphics, media, text - they're all present in Silverlight and the concepts you've learnt in WPF carry forward

Visual Studio - Cross Application Forms Authentication

On a recent application development for one of our clients, I was faced with having to support a preview that is available on the live site to restricted authors, that were allowed to author content.  The main issue was that the application that manages the content uses forms authentication for all users, however the front end does not require any authentication.  To allow this authentication to occur a few things must be set in both applications:

Firstly the machine key set in the WEB.Config must match on both applications, and must have the validation type set.

<machineKey validationKey="xxx" decryptionKey="xx" validation="SHA1" />

Also the Forms Autheication set up must have the same name in the Web.config.

<forms loginUrl="login.aspx" name=".ASPXFORMSAUTH"  protection="All"  path="/" timeout="30" />

Also it is advised that both applications share the same application pool. and that the user restrictions are set in the web.config to meet your specific user access requirements.

More to come on this on Monday!

Visual Studio 2008 and Javascript Intellisense

Visual Studio 2008 (Codname ORCA) has intorduced a new feature to aid with Web development, official release date has not yet been announced, however a BETA 2 is due to released later this year. 

One of the most publicied, and simplistic enhancement to the Visual Studio 2008 enviroment is the somple introduction of intellisensce with Javascript. 

You can read more about this here and here.

Visual Studio 2008 - ORCAS - Beta 1

Orcas has been officially named as Visual Studio 2008, and can be oficailly downloaded as a BETA from here:  Microsoft Download Site

This BETA is on a time trial until March 13, 2008 and available in English and Japanese.

Visual Studio 2008 will use and Updated version of C# (v3.0 and VB 9.0), as well as an updated .NET framework up to v3.5, however the CLR will remain the same as in Visual Studio 2005, CLR v2.0.

The IDE itself is no great leap from 2005, and is merely a superset of VS2005.  Integration with the forthcoming Silverlight and better integration between numerours platforms.

Keep an Eye here for further updates, news and progress with Visual Studio 2008.