Saturday 4 May 2013

Fix for NServiceBus testing.

Looks like the issue I had with NSB testing may not have been the Unobtrusive messages.

What I’ve ended up having to do is this.

   1:  MessageConventionExtensions.IsMessageTypeAction =
   2:                  t => t.Namespace != null && t.Namespace.EndsWith("Messages") && !t.Namespace.StartsWith("NServiceBus");
   3:  Test.Initialize();

Making ConfigurationElementCollection strongly typed.

I was getting annoyed with ConfigurationElementCollection returning IEnumerable and not IEnumerable<T>, after some Googling I came across this post on StackOverflow http://stackoverflow.com/questions/7991252/read-web-config-section-to-list.

Basically you implement IEnumerable<T> and in GetEnumerator do this

   1:   public new IEnumerator<T> GetEnumerator()
   2:   {
   3:      return this.OfType<T>().GetEnumerator();
   4:   }



No more casting when you want to use Linq on the ConfigurationElementCollection Thumbs up