Rory Primrose

Learn from my mistakes, you don't have time to make them yourself

View project on GitHub

Using GhostDoc to document unit test classes

To follow up on my last post about documenting unit test methods with GhostDoc, a similar concept can be applied to documenting unit test classes.

Add a custom rule under the Classes section in the GhostDoc configuration dialog.

I have used the name “Matches unit test class” and identified type names that end with “Tests”. I have entered the summary documentation with the following value:

The $(TypeName.ShortNameAsSee)
class is used to test the <see cref=”$(TypeName.Words.Verbatim.ExceptLast)” /> class.$(End)

Edit Rule dialog

This produces much nicer documentation that the default documentation provided by Visual Studio.

Read More

Using GhostDoc to document unit test methods

GhostDoc is one of the coolest tools around for Visual Studio. Sometimes it needs a little help though and unit test methods are a classic example. The format of my unit test method names usually identifies the method name, parameter list, parameter value conditions, expected outcome and end in “Test”. The default rule that GhostDoc applies to this format is fairly ugly.

For example,

Read More

Lightning fast Australian broadband

I’ve been on ADSL2+ for a few years now. Having a possible maximum speed of 24Gb is nice, but the actual floats between 5-7Gb being 3.5km from the exchange. That’s not great, but is fast enough for general net usage. Tonight however, surfing the net has been slow. Really really slow. So slow in fact, that www.speedtest.net tells me this.

Read More

SCOM event collection fails with (0x8007000E)

I have written some custom SCOM management packs that read from a database and populate event collection data (see here and here for some examples from other people). My first management pack works without any problems. The second management pack (essentially a copy of the first) fails with an out of memory exception. The Operations Manager event log on the SCOM server contains an entry that starts with the following:

Converting data batch to XML failed with error “Not enough storage is available to complete this operation.” (0x8007000E) in rule “[RuleName]”

This has been plaguing me for weeks but I now have an answer.

The definition of a collection event record includes a description field. The description field may be defined with a static value, a property bag (params) value or combination of both. The property bag value can be fully qualified (in the format of $Data/Property[@Name=’<PropertyBagItemName>’]$) or referenced by index. See here for more information.

Read More

Visual Studio Addin - CopySourceAsHtml

Ah, this is great news. A new version of CopySourceAsHtml (CSAH) has just be released with support for VS2008 after a long hiatus. CSAH is a must Visual Studio addin for any developer blogger. Get the goods here.

Read More

Testing IErrorHandler

I have previously posted (here, here and here) about using IErrorHandler to provide error handling and exception shielding in WCF services. What I haven’t discussed is how to test an implementation of this interface.

The reason for posting this is that I recently found that I had a bug in a service where un-handled exceptions weren’t being shielded from clients. This was purely because my unit tests were not validating the messages being generated for clients by the error handler.

The following method came about after a bit of research (mainly from here) and playing with code to make the solution work and easy to use. This method will assist unit testing the output of ProvideFault as it provides an easy way to extract a Fault from a Message returned by the ProvideFault method. This fault can then be tested for expected outcomes of the unit test.

Read More

Splitting up arguments with a regular expression

There have been several times when I have needed to process a string that contains a set of arguments. It always seems to be a lot of work splitting up arguments by using white space as a delimiter because you need to take into account white space that is surrounded by brackets.

Just for kicks, I tried to come up with a regular expression that would do just that. Here is the result.

[^\s"]*"[^"]*"[^\s"]*|[^\s"]+
Read More

SQLEXPRESS fails to start

I have just encountered a problem where the SQLEXPRESS instance installed on my machine was not starting. It looks like a recent windows update has failed, but also knocked out SQL Server. The event log contains the following entry:

Error 3(error not found) occurred while opening file ‘C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\master.mdf’ to obtain configuration information at startup. An invalid startup option might have caused the error. Verify your startup options, and correct or remove them if necessary.

After searching around, there seems to be lots of forum posts going back several years about this issue. The problem is that the only known solution seems to be to change the credentials of the SQLEXPRESS service account to Local System. This will then allow the service to start. Doing this through the services console presents a problem however because you can’t set the service credentials back to Network Service as you need to know the password.

Read More