Unit Testing this .browsers file?

Mar 31, 2009 at 2:10 PM

Excellent! Thats sounds like something I was waiting for :-) How could I introduce it into our existing solution.

We are using WURFL right now for our mobile device detection. We have a DeviceDectionService that returns the capabilities of the device. The User Agent string is used for deciding which device is requesting.
We have a bunch of Unit Tests implemented in a Visual Studio test project.

I would like to use the .Browsers file for the Mobile Device detection.

  • But how would I be able to run my unit tests without an ASP.NET webpage?
  • How could I write a service that detects the device/browser by the User Agent string?

Anyone solved this already?

Apr 1, 2009 at 4:58 PM
Edited Apr 1, 2009 at 5:03 PM


     When you say service are you talking about a web service such as WCF/SOAP? Unfortunately I haven’t yet tried to unit test the .browser data directly but I’d imagine a mocking framework such as MOQ (http://code.google.com/p/moq/) or one of the others listed here: http://www.mockframeworks.com/ could provide the means to do so. 

Consuming the data within a web service is fairly straightforward. First you need to drop in the .browser file into the App_Browser\Mobile directory of your webservice like so:


Now in your Web Method you can access the capabilities through HttpContext.Current.Request.Browser

Hope this helps,


May 25, 2009 at 8:41 PM

I have published the new version of Apache Mobile Filter, now the filter is give to you the information of capabilities as apache environment.
Now you can develope in any language (php,jsp, ruby etc.) and have the information of mobile capability.

Read more info here: http://www.idelfuschini.it/it/apache-mobile-filter-v2x.html