Unity in a webAPI project

I have just created a proof of concept for a client where I demo how to configure Microsoft's Unity DI container to resolve the API controllers and their dependencies.

The code is available in this github repository.

The concepts that I tried to showcase are

How to configure Unity in OWINHow to do automatic registration of IObject->Object references.How to use an injectionFactory to resolve object that depedn on dynamic data.Different Lifetime managersContainer Controlled (Singleton)Per Resolve (Once per request)Transient (Once per call)Unit testing an application with dependenciesAbstracting away the HttpContext from the controller, which is useful for unit testing.
Take a look and comment in the blog or in the repo..

Testing Exceptions in Nunit 4.7

I am getting in TDD a lot, and of course, when thinking in border cases, you'll end up throwing exceptions, And you'd want to see ith they get thrown. With Nunit 4.7 the thing is that If, for example, you're testing that some parameter is null, when you decorate your test with [ExpectedException] it eventually gets thrown, but You'll never know what piece of code actually did it...
So, I created this little R# snippet to test excxeptions in a more granular way:
[Test] public void $TestName$() { try { $Code$ } catch (Exception e) { Assert.That(e, Is.TypeOf(typeof($ExpectedException$))); $END$ return; } Assert.Fail("Did Not Throw the Exception."); }
For example, if you want to test if a parameter is null before you excercise some code, you could have a test like this:

[Test] public void Intermediary_ParamOneCannotBeNull() { try { new Intermediary(null, null); } catch(Exception e) { Assert.That(e, Is.TypeOf(typeof(ArgumentNullException…

Alt.NET in Colombia

I recently found @jorgegamba, which has been very active on VAN meetings for hispanic community.

He is also from Colombia and share the same interest on making Alt.Net widespread on Colombia.

He is trying to build a community for Colombian programmers who want to grow as agile .net programmers. I beleive is a very good initiative and I'm planning on supporting his idea any way possible.

Adelante Jorge!

Debugging Sharepoint Applications

When developing sharepoint apps, it becomes a pain in the neck to know what process to lint to (via debug-attach process) because it usually has many w3wp process running, and knowing which is the one you need is usually a trial-and-error thing.

Spence Harbar has a very handy application called Application Pool Manager which lets you do several things:

1. Reset application pools, which is faster than iisreset.
2. Show the list of application pools running
3. Establish which application pool has which process ID associated, and refresh it if someone else recycled them (i.e. VSeWSS)

This way, by just having a look at the tool's menu, you can know for sure what process ID you need to attach to!

Firefox add-ins I use

I love the customization FF can give you!! I have a lot of add-ons installed, preety useful for all my work and browsing time:
All in one gestures :
Lets you have mouse gestures to control your browser
erases all browsing info from a session (useful when browsing in sites that can install sw in your machine)
Developer toolbar... lets you analyze your HTML and http traffic
DL manager, I use it with FlashGet to manage my dls, it even let you DL Toutube moveies!!!
Google Gears:
With this addon I can work Google docs, Gmail, Calendar offline!!
Google Toolbar:
the classic one!
IE Tab:
Lets you open a page in FF using the engine of IE.MileWideBack:
allows you to navigate and close tabs using the left margin of your browser.
capture screenshots of your pages
shows you all open tabs in a vertical toolbar, showing a thumbnail of the page. you can even browse back and foth without having to switch to that tab.
Web Developer Toolbar:
Lots of goodies for We…

My WinVista looks like a Mac :)

Hi. In Dec/january, working with Zemoga, I got a Mac. I loved the OSX. hated not having right-clic on the trackpad, the different keys for common Office tasks, different default behaviours, but it was a nice experience.

I prefer Win though, and since XP is so nineties, I upgraded to Vista busoiness 64 bit.

In order to be more Mac-alike, I found some tools very nice:


It emulates MacOSX toolbar very well..... I like it, and I'll like it more when it supports X64 OS

This tool makes switching application just like in Mac. small thumbnails of all your windows, and you sleect the one yo like....

with these apps, I feel I have a Next-get OS UI!!!
Let's see what Win7 can add to this....

Nant and VS2008

I've been reading a lot on CI (Continuous Integration) lately, and I am following the trend, using nant over msbuild.
Nant is a great tool, but it doesn't have a way to build a VS2008 solution. It just breaks.
Since it's very annoying to downgrade fom .net 3.5 to .net 2.0 (big fan of var type, workflow development OOTB, planning to get started on lambda expressions, and other nifty features) and I think is too difficult to keep the project in sync with the build script, providing I'm developing using TDD, so my only options seemed to learn MSBuild, which I don't like entirely, or to install VS on the build machine and use exec to call devenv and build the solution.

I finally found a shortcut: in fact, I have to use exec, but to call MSBuild (wihich comes with .net SDK) to have it complie the solution! this have worked perfectly. My only concern is what wooill happen when I start automating build with cruiseControl...... Let's see what happens!!