Design your own Visual Studio Theme

16 Mar 2009 In: C# 3.5, Hong Kong

http://www.frickinsweet.com/tools/Theme.mvc.aspx

Sweeeeeeeeeeeeeeeeeeeeeeeet!

Dave the Ninja


Update:

This fix is included in the current release of MVC-Contrib.

I have been using the MVCContrib RouteTestingExtensions today for the first time and they have been working really well.... that is until I started writing a custom route that returns a complex type to the RouteValueDictionary.

The tests that I had assumed would work and pass were like the following:

    [TestFixture, Category("Routing")]
    public class When_Url_to_route_is_dynamic_with_trailing_slash_and_no_html_extension : DynamicContentRouteSpecification
    {
        public override void Given()
        {
            base.Given();
            currentUrl = "~/business/something/";
            dynamicUrl = new DynamicUrl(currentUrl.Substring(2));
        }

        [Test]
        public void Then_the_current_url_should_map_to_DynamicContentController_Render_action()
        {
            route.ShouldMapTo<DynamicContentController>(a => a.Render(dynamicUrl));
        }
    }

In my code sample above the DynamicUrl is a class that wraps additional logic around the passed in url, and I have a ToString() method on it that simply returns the original url value.

This test kept blowing up, and after looking at the tests and code from MVCContrib I found the code that was causing all of the problems.

        public static object GetValue(this RouteValueDictionary routeValues, string key)
        {
            foreach(var routeValueKey in routeValues.Keys)
            {
                if(string.Equals(routeValueKey, key, StringComparison.InvariantCultureIgnoreCase))
                    return routeValues[routeValueKey] as String;
            }

            return null;
        }

This GetValue method within the RouteTestingExtensions would work as expected until the return "as String".  As we know "as String" returns a string if it can be converted or null if it can not.

To resolve this issue I amended the MVCContrib code to the following:

        public static object GetValue(this RouteValueDictionary routeValues, string key)
        {
            foreach(var routeValueKey in routeValues.Keys)
            {
                if(string.Equals(routeValueKey, key, StringComparison.InvariantCultureIgnoreCase))
                    return routeValues[routeValueKey].ToString();
            }

            return null;
        }

After making the changes and running the MVCContrib tests, they all passed.

I then re-built and referenced the new assembly builds in my project and HAZZA! my tests started passing.

I have uploaded the patch and you can download it here

If anyone has any feedback on this, or if I have gone about using the helper the wrong way please leave me a comment.

David the Ninja

 

 


What can I say about this film? 

IF IT IS THE LAST THING YOU DO ON THIS EARTH, WATCH THIS MOVIE!

I was doubled over laughing the whole way through, director Takashi Miike has done an amazing job once again directing this master piece!

IMDB: http://www.imdb.com/title/tt0304262/

I think I have a new favourite movie!

Ninja


Learn a new language every year....

5 Mar 2009 In: Ruby, Ruby on Rails

 ..or thats what they say anyways 

I have decided that this years programming language that I am going to learn is Ruby / Ruby on Rails.  I have just bought Agile Web Development with Rails: Second Edition from the Pragmatic Programmers.

I have only had time to glance through the book but it seems excellent so far, real life examples and what looks like full rails programming reference.

I am looking to start properly coding my first app in rails within the next week or two so I will blog on my experiences.

I am also learning Cantonese which is proving to be possible but very difficult 

@ dgi  p.s CMS part 4 is coming soon, ive not forgotten about you 

 

Dave the Ninja

 


.Net Developer Roles, Competitive Salary

3 Mar 2009 In: C# 3.5, Jobs, MVC.net

Want a job?

We are looking for a number of .Net developers, both senior and junior, to join our team developing exciting products in the digital identity and communications arena.  You should be happy working for a cutting edge, dynamic, fast moving company.

 
Developers must be able to demonstrate the following skills and experience:
  • Experience with c# and asp.NET.
  • A strong grasp of object-oriented design.
  • Ability to produce quality code across all layers of a web application stack.
  • 3+ years development experience on commercial or open source projects.
 
Experience in any of the following areas will prove advantageous:
  • OpenID
  • Information Cards (CardSpace)
  • ASP.NET / MVC.NET
  • TDD
  • NHibernate
  • Castle Project
 
Interested?
Send your CV to: recruitment@netidme.com, including an indication of your salary expectation.
 
Location:
East Kilbride, Scotland, United Kingdom
 
Please Note:
All prospective employees must undergo disclosure checking with www.disclosurescotland.co.uk
 

NO 3RD PARTY REFERRALS PLEASE 


About this blog

Dave the Ninja is an Alt.net practitioner from Glasgow in Scotland (UK). He rants about all things from coding to Kung Fu with some swearing thrown in for good measure.

Dave the Ninja has been programming professionally with Microsoft technologies for the past 9 years starting and is now working primarily with C# 3.5, MVC.net and Resharper.

Dave the Ninja has been practicing Chinese internal arts for the past 15 and a half years, mainly Taiji Quan, Neijia Quan , Chi Na and Qigong.

I have joined Anti-IF Campaign

My Communities/Projects

Flickr PhotoStream


Sponsors