prabirshrestha / FacebookSharp

Facebook Graph API for .Net
Other
30 stars 15 forks source link

Unit Testing + Dependency Injection with ASP.NET MVC Canvas application #19

Open BenBach opened 13 years ago

BenBach commented 13 years ago

I am planning on developing an ASP.NET MVC application inside a Facebook Canvas.

I already used your framework in another application and think it's awesome.

But this time i really want to build on top of a clean architecture. So i want to use Dependency Injection (Ninject) and Unit Testing(as much as possible)

Right now i trying around with the CanvasIFrameApplication Sample. I would love to convert and to move most of the Facebook stuff in my domain class libary

I am wondering if it's a good idea to place the Facebook Context Stuff inside a Controller or if there a way to separete concerns

Maybe you have some suggestions or experiences using your Framework with DI and Unit Testing?

EDIT: I uploaded a Repository. ( https://github.com/BenBach/FaceStartingKit ) My goal is to create kind of a Starting Application to start developing an Facebook ASP.NET MVC Application using some useful frameworks like your framework, Ninject or NUnit.

I just started but i somehow want to develop a starting point for all my further application which is fully unit testable and uses Dependency Injection.

Would be of great help, Ben

prabirshrestha commented 13 years ago

sorry for the late reply. i have been quite busy working on merging FacebookSharp with Facebook C# SDK. you can read the details about it at http://ntotten.com/2010/11/the-state-of-net-facebook-development/

incase you are using FacebookSharp.Extensions you might not be able to mock the static classes. i think at the moment, I only know of TypeMock Isolator supporting mocking static methods.

You might be interested in looking at these links.

http://www.clariusconsulting.net/blogs/kzu/archive/2009/02/19/Makingextensionmethodsamenabletomocking.aspx http://stackoverflow.com/questions/562129/how-do-i-use-moq-to-mock-an-extension-method http://stackoverflow.com/questions/2295960/mocking-extension-methods-with-moq

As for the FacebookContext i would basically place it inside the Controller. The library has not be specifically designed to support DI. we will be planning to make this easier in the future (merged) version of the library. one the DI is done, it would be easier to do unit testing too.