This weekend I looked into creating facebook applications from a .NET perspective. It turns out a quick search presents loads of support starting with the Facebook Developer Toolkit (Update: Just heard version 3 was released yesterday which gives silverlight and mvc support, wow what a coincidence?) and LINQ2Facebook (Fql).

I decided to do some research and ended up created a Facebook application framework using ASP.NET MVC, Silverlight, LINQ2Facebook. I also used StoryQ to POC their BDD framework and give the community a chance to see its power.

I have created a codeplex project with the source code here:

Facebook MVC BDD Silverlight Framework

Source code sample:

public ActionResult Index()
{
	if (_service.TryAuthenticating())
	{
		user user = _service.GetCurrentUser();
		var silverlightViewModel = new SilverlightViewModel
									   {
										   ApplicatonName = "TestApp",
										   Width = "400",
										   Height = "400"
									   };

		silverlightViewModel.Params.Add("Name", user.name);
		silverlightViewModel.Params.Add("Picture", user.pic_big);

		return View(silverlightViewModel);
	}
	throw new AuthenticationException("Not allowed!");
}
[Test]
public void IndexActionShouldReturnViewModelWithCurrentLoggedInUser()
{
    var story = new Story("Index action should return a new silverlight view model");

    story.AsA("facebook application home page")
        .IWant("to receive a new silverlight view model")
        .SoThat("I can send it to the silverlight applicatioin")
        .WithScenario("Get silverlight view model")
        .Given(() => Steps.TheUserIsLoggedInWithUsername("Joe Blogs"))
        .When(() => Steps.TheUserEntersTheHomePage())
        .Then(() => Steps.EnsureTheCurrentLoggedInUserDetailsIsReceivedInTheViewModel());

    story.Assert();
}

producing output:

Story: Index action should return a new silverlight view model

As a facebook application home page
I want to receive a new silverlight view model
So that I can send it to the silverlight applicatioin

Scenario 1: Get silverlight view model
Given The user is logged in with username (Joe Blogs) Passed
When The user enters the home page Passed
Then Ensure the current logged in user details is received in the view model Passed