Unit tests and comparing long strings or objects

June 16th, 2014

I have tested and really liked ApprovalTests with more info in the blog by Llewellyn Falco.

When the unit test fails, and only if it fails, a comparer of choice pops up (think Winmerge or similar).

Say you have a long string where, somewhere, the testing framework reports a diff; you have to sift through the whole 1000 characters and compare by eye. If the discrepancy is a space/tab or apostrof/accent you might have a very hard time to spot the diff.
Or say you have an object with 10 or so properties. The unit testing framework reports a diff and you have to iterate through the properties and maybe sub properties for two objects. Tedious and not fun even the first time. The third of 10th time you really should be looking for a better solution.

I started writing my own but dropped that project in a second for AprovalTests.

Another, not as polished, solution is from SHaack. It is an extension to a unit test framework. You have to implement your own if you have another unit testing framework of choice.

Forefront threat management gateway 2010 – the page cannot be displayed

June 10th, 2014

Error code: 500 Internal server error. The system cannot find the file specified. (2)

This error might be because of your OWA password is about to expire and there is a fault somewhere in the Exchange/OWA installation.

Screen dump of TMG reporting 500 dues to password is about to expire.

Threat management gateway 2010 with 500 error due to password is about to expire.

The remedy is to change your password which you can do at the OWA login page. There is a check box “I want to chang emy password after logging on” to use.

OWA login page

OWA login page

tags: , | categories: Miscellaneous | no comments »

Why using the disc icon as saving icon is considered good

June 10th, 2014

Regardless whether skeumorphism is good or not; a diskette icon for saving is passé.
But there is no better.

We could use a mobile phone as icon for saving as we use a mobile phone for that. And anything else.
We could have a mobile phone as icon for everything. It would be easier to remember just one icon. It would save band width as it could be cached. Support calls would be easier as we could just answer “press the button with the mobile phone icon”.


Diskette icon with CC0 license

Diskette icon, CC0 license (http://creativecommons.org/publicdomain/zero/1.0/deed.en) (fromhttp://pixabay.com/en/floppy-disk-symbol-signs-symbols-24172/)

Indoor gardening and composting

June 6th, 2014


The art of gardening without soil. Makes my geek heart vibrate.

Here is an example of how to create a solution with Ikea stuff. There are both more complex and simpler ways to accomplish this.


Instead of simple composting; first ferment and get some juice out – then compost.

With a bucket under the kitchen sink one can play with the food that wasn’t eaten. Here is a Swedish site for the stuff.

Why I don’t recommend my customers to rely on Visual studio for development.

June 5th, 2014


The only way to edit architecture and modelling with Visual studio is to buy the very expensive Ultimate edition. This means that it will be not everyone can be involved in the process of evolving the solution.


Development requires Architecting an Architecture in some way or another. This architecture is not written in stone but changes as time or business changes; we call it requirements change.

In the old days, like 20 years ago, I learned that there is an architecture phase and then a development phase. This is not considered best practice any more. Also not best practice is to have silos with Architectures and Testers and Coders and Database managers.

This is where Microsoft and Visual studio fails. Not technically but license wise.

Look at this part of a comparison chart for different Visual studio versions. It clearly explains that Architects must have the Ultimate edition and that no one but Architects are allowed to change any Architect document. (the Ultimate edition is way more expensive than the others)

Visual studio architecture blunder

Visual studio comparison fail where it shows that only Ultimate can edit architecture stuff. Original from Wikipedia.

ReAttach is a Visual studio plugin to reattach the debugger

May 9th, 2014

I have earlier, here and here, written about how to write a macro to attach the debugger to a running process as it is often faster than starting the process anew.

Lately the Visual studio plugin ReAttach has come on my radar and I have tried it with success. It remembers the last attaches you did and keeps them in a menu. Fewer key strokes and fast attaching is the result.

How I write Equals and GetHashCode in csharp

April 25th, 2014

My code is copied with pride from the net.

        /// <summary>This is standard overridden Equals method.
        /// Code is copied with pride from
        /// http://msdn.microsoft.com/en-us/library/336aedhh(v=vs.85).aspx
        /// </summary>
        /// <param name="obj"/>
        /// <returns></returns>    
        public override bool Equals(object obj)
            if (null == obj || GetType() != obj.GetType())
                return false;
            var b = (MyType)obj;
                this.Property1 == b.Property1 &&
                this.PropertyN == b.PropertyN;

        /// <summary>This is the ordinary overriden GetHashCode
        /// with code proudly copied from
        /// http://stackoverflow.com/questions/263400/what-is-the-best-algorithm-for-an-overridden-system-object-gethashcode
        /// </summary>
        /// <returns></returns>
        public override int GetHashCode()
            unchecked // Overflow is fine, just wrap
                const int Salt = 23;
                var hash = 17;
                hash = hash + Salt * Property1.GetHashCode();
                hash = hash + Salt * PropertyN.GetHashCode();
                return hash;

Unit testing private methods

March 25th, 2014

I have a dirty but simple way to unit test private methods.

I create a wrapper method that I prefix with UT_ and write a comment that is only used for unit testing.
To be honest I haven’t done this on a public API but I wouldn’t hesitate for a public-within-a-company method.

private int MyMethod( int myParameter ){

///&lt;summary&gt;This helper method is only used for unit testing. Do Not call it in normal operations.&lt;/summary&gt;
internal int UT_MyMethod( int myParameter ){
    return MyMethod( myParameter );

I use InternalsVisibleTo to make internals visible to my unit testing project.

One can play with protected methods and inheritance too.

Compile aspnet mvc views (*.cshtml)

January 26th, 2014

To make a long story short one can compile the views in asp net mvc.

It takes considerable time though so I only activate it for release compilations.

Update the build file with

&lt;MvcBuildViews Condition=" '$(Configuration)' == 'Release' "&gt;true&lt;/MvcBuildViews&gt;

Like so:

&lt;MvcBuildViews Condition=" '$(Configuration)' == 'Release' "&gt;true&lt;/MvcBuildViews&gt;

I am sorry about all &gt; and &lt; but I don’t have the time right now to make everything look pretty. Just replace &gt; with < and &lt; with > and your good to go.
Or follow the links below with the awesome formatting Stack overflow provides.

Honour those who should. Especially this answer that does the only-release trick.

The X-Y-problem

July 31st, 2013

Try to solve X.
You recognise that to solve X you must first solve Y.
You ask for help on how to solve Y.

When you really should ask for help on how to solve X.

More thorough explanation.

I have not solution to the problem but knowing it exists is a good start to avoid it.