# Friday, July 22, 2005
Microsoft Across America

Microsoft has a loaded RV that they are taking to Grand Rapids on August 2nd from 8:30 to 5:00. There's a free lunch. It's a free event, but you should RSVP.

When it came to Ann Arbor, it was mostly stuff like Exchange, Mappoint, Licensing, Small Business Server and so on. However, it was really good information and it was worth the trip to see the RV. It's got highspeed everywhere because of the really solid satelite system. It's loaded with computers, networks and everything else I'd love to have in a completely mobile office...



Friday, July 22, 2005 6:40:31 PM (GMT Standard Time, UTC+00:00)  #  Comments [0] 

# Saturday, July 16, 2005
Martin Shoemaker has a blog

It's part tech, part fun, all Martin...



Saturday, July 16, 2005 4:15:55 PM (GMT Standard Time, UTC+00:00)  #  Comments [0] 

# Friday, July 08, 2005
Obfuscation Blog on MSDN

PreEmptive Solutions, the creaters of the Dotfuscator, have a new blog and it's on MSDN.

Be sure to send them all of your great questions about how and why to obfuscate. The Dotfuscator Team loves getting good questions...



Friday, July 08, 2005 6:31:58 PM (GMT Standard Time, UTC+00:00)  #  Comments [0] 

Bill Wagner WebCast on Advanced DataBinding in .NET 2.0 Smartclients

Bill Wagner, my business partner and author of Effective C#, is doing a web cast on Monday, July 11, at 2:00 Eastern Time.



Friday, July 08, 2005 6:11:21 PM (GMT Standard Time, UTC+00:00)  #  Comments [0] 

# Monday, June 13, 2005
Drew Robbins: The Dancing DE

Update: I've cleaned up the video - see the new link below...

I did a lot of fun things last week at TechEd. One of those was a Central Region Influentials party at the NASCAR Cafe. You learn a lot of fun things about people at these parties like the fact that Drew Robbins (the Developer Evangelist from the Great Lakes Area) is quite the dancer!

btw: that's Jeff Julian there next to him.

There's even video. I especially like the name on the jersey so there's no talking his way out of this one...


Dancing DE
Monday, June 13, 2005 4:38:28 PM (GMT Standard Time, UTC+00:00)  #  Comments [0] 

DevCon 2005 Detroit

DevCon 2005 is on Thursday, June 16th! It's going to be a fun event. We've got a lot of great speakers and content. The speakers include Tim Landgrave, Steve Smith, Bill Wagner and Martin Shoemaker.

We, SRT Solutions, are the only outside Microsoft group to have 2 speakers there.

Four reasons that you should come:

1: Great speakers and great content!
2: Small crowds which mean more face time with the speakers
4: The give aways are worth more than the $99.00 that they are charging
3: Small crowds which give you a better chance to win one of the great door prizes

DevCon give aways



Monday, June 13, 2005 12:18:56 PM (GMT Standard Time, UTC+00:00)  #  Comments [0] 

# Friday, April 08, 2005
Josh Holmes, Microsoft MVP!

I’m pleased to announce that I’ve recently received the Microsoft MVP Award. This is not something that you can apply for. It came from the recommendations my peers and the people in the Microsoft Offices in Southfield for my contributions to the community. I’m honored to be recognized in this fashion and placed in the company of Tom Barnaby, Patrick Steele, Eric Maino, Martin Shoemaker, Richard Hale Shaw and all the other MVPs.

Now for those of you who know me – you’ll get a giggle out of the category because I was awarded the MVP in the C# category.

It’s also exciting because my company, SRT Solutions, now has among it’s principals a MVP (Me) and a Regional Director (Bill Wagner).



Friday, April 08, 2005 1:56:56 PM (GMT Standard Time, UTC+00:00)  #  Comments [0] 

# Monday, February 14, 2005
Speaking in Southfield, MI on Feb. 16

I'll be speaking on Unit Testing at the Febuary GANG (Great Lakes Area .NET Users Group) meeting on Feb. 16.

I'm giving the tutorial and Alex Lowe, now of Telligent Systems, is giving the main talk on Visual Studio Team Systems.



Monday, February 14, 2005 8:07:51 PM (GMT Standard Time, UTC+00:00)  #  Comments [0] 

Speaking in Lansing, MI on Feb. 17
I'll be presenting at the Greater Lansing User Group .NET on February, 17 in Lansing, Michigan. I'll be giving a presentation on Compact Framework and mobilizing your data. If you're in the area, stop by!

Monday, February 14, 2005 8:00:06 PM (GMT Standard Time, UTC+00:00)  #  Comments [0] 

# Thursday, February 10, 2005
NUnit Stands the Test - Follow up

Patrick Steele made a good point about my last post on Unit Testing. The code that I wrote just happened to use the Test keyword at the beginning of each of my methods. That’s not required. I just happed to like that convention because it reads well.

I do use the attributes and encourage everyone else to because, as Patrick also points out, TestDriven.NET and other tools don’t use it.

Look for another article on TestDriven.NET early next week.


Articles | Development
Thursday, February 10, 2005 7:33:23 PM (GMT Standard Time, UTC+00:00)  #  Comments [0] 

# Tuesday, February 01, 2005
NUnit Stands the Test

Unit testing is only enjoyable and productive with the right toolset. NUnit is the foundation of this toolset. It is a unit testing framework for any .NET language.

NUnit leverages Reflection and Attributes to dynamically discover and execute your tests. The structure of a NUnit unit test is as follows.

Imports NUnit.Framework

 

<TestFixture()> _

Public Class DemoTests

    <Test()> _

    Public Sub TestGetIntegerFromConfigFile()

        'Some code that tests the desired functionality

    End Sub

End Class

 

You add the TextFixture attribute to notify NUnit that a class is a suite of tests. You add the Test attribute to mark a method as a single test case. You can have as many tests in a given test fixture as you want and as many test fixtures in a project as you want. The class that is the TestFixture has to be public and have a default constructor so that NUnit can use reflection to dynamically instantiate it. The methods decorated with the Test attribute have to be public, not take any arguments and return no values (Sub in VB.NET and void in C#) for the same reason.

The next step is to write the code that tests the desired functionality. It’s best if the tests are fairly straight forward and simple.

    <Test()> _

    Public Sub TestGetIntegerFromConfigFile()

        Dim demo As VBDemo.Demo = New VBDemo.Demo

        Dim result As Integer = _

            demo.GetFromConfigFile("MyValue", 0)

 

        Assert.AreEqual(1, result)

    End Sub

 

Assert.AreEqual is the really crucial bit of code from this test. This is one of several types of assertions. An exception of type NUnit.Framework.AssertionException is thrown if one of the assertions fails.

Assert.AreEqual(value a, value b)

Tests if b is equal to the expected value a

Assert.AreSame(reference a, reference b)

Tests if two references point to the same object in memory

Assert.IsFalse(Boolean)

Tests if the Boolean is False

Assert.IsTrue(Boolean)

Tests if the Boolean is True

Assert.IsNull(reference)

Tests if reference is Null as expected

Assert.IsNotNull(reference)

Tests if reference is something as expected

More complex tests can be accomplished with normal if statements and the Assert.Fail method.

If (Not SomeReallyComplexStatement) Then

   Assert.Fail()

End If

 

The code that this test exercises takes the name of a configuration setting and a default value. It will return the value from the configuration file or the default value. The test above assumes that the configuration file has a value as follows.

<configuration>

    <appSettings>

            <add key="MyValue" value="1" />

    </appSettings>

</configuration>

 

A small thing that I’ve discovered is that it’s helpful in cases where there is a config file that the tests are in a console application because VS.NET will manage the app.config automatically for you. In addition, if your tests are in a console application, they could be self sustaining and run whether someone has a NUnit test runner, like NUnit GUI, installed or not. You would have to call the tests from the Main of your console application. You know that the test failed when if there is a NUnit.Framework.AssertionException thrown. I have found that this is helpful in a “Clean” environment where developer tools are not allowed.

If the code is as follows.

Public Class Demo

    Public Function GetFromConfigFile( _

            ByVal settingName As String, _

            ByVal defaultValue As Integer) As Integer

 

        Return defaultValue

    End Function

End Class

 

And you run the test; the result will be as follows.

This is expected. Now you need to fix the code so that it will not result in a red bar.

Now modify the function as follows.

    Public Function GetFromConfigFile( _

            ByVal settingName As String, _

            ByVal defaultValue As Integer) As Integer

 

        Try

            Dim reader As System.Configuration.AppSettingsReader = _

                New System.Configuration.AppSettingsReader

 

            Dim resultAsObject As Object = _

                reader.GetValue(settingName, GetType(Integer))

 

            Dim result As Integer = _

                Int32.Parse(resultAsObject.ToString)

 

            Return result

        Catch ex As System.InvalidOperationException

            'Either the value didn't exist or it was not an Int32

            'Fall through to the default value below

        End Try

 

        Return defaultValue

    End Function

 

Once it is, you are rewarded with a green bar as follows.

Since the normal path is working, you need to test the alternative paths as follows.

There are a number of alternative paths that we can investigate. You can pass in garbage, Nothing (or null in C#), the name of an item that’s not an integer and so on. You could decorate the method with an additional attribute, ExpectedException, if we expected this code to throw an exception rather than handle all of its exceptions. For this example, you simply need the non existent config value and the non integer config value cases.

    <Test()> _

    Public Sub TestGetIntegerFromConfigFileNonExistant()

        Dim demo As VBDemo.Demo = New VBDemo.Demo

        Dim result As Integer = _

            demo.GetFromConfigFile("MyNonExistantValue", 0)

 

        Assert.AreEqual(0, result)

    End Sub

 

    <Test()> _

    Public Sub TestGetIntegerFromConfigFileNotAnInt()

        Dim demo As VBDemo.Demo = New VBDemo.Demo

        Dim result As Integer = _

            demo.GetFromConfigFile("MyNotAnIntValue", 0)

 

        Assert.AreEqual(0, result)

    End Sub 

Now you have a well tested function and tests that can be run over and over again.

We have covered the basics of setting up a unit test with NUnit. There are more features that we will cover in a future post. These include the ability to specify setup and teardown methods, categories of tests and suites of tests.

The code for this post can be downloaded below. It does require NUnit.


Articles | Development
Tuesday, February 01, 2005 2:35:12 PM (GMT Standard Time, UTC+00:00)  #  Comments [0]