An open API service indexing awesome lists of open source software.

https://github.com/prabirshrestha/facebook.moq

Moq helpers for Facebook C# SDK
https://github.com/prabirshrestha/facebook.moq

Last synced: 2 months ago
JSON representation

Moq helpers for Facebook C# SDK

Awesome Lists containing this project

README

        

# Facebook.Moq

## Overview
Facebook.Moq is a helper file aimed to ease unit testing for
[Facebook C# SDK](http://facebooksdk.codeplex.com).

## Requirements

* Moq
* Facebook C# SDK >= v5.0.25
* .NET 4.0 (client profile supported too)

You can use any unit testing library such as MSTests, XUnit.Net or NUnit with Facebook.Moq

# NuGet
Facebook.Moq can also be installed via NuGet.

Install-Package Facebook.Moq

# Usage
Either copy and add FacebookMock.cs file to your project or using NuGet to install Facebook.Moq.

### Create a Mock instance of FacebookClient

var mockFb = new Mock { CallBase = true };

Make sure to set the CallBase to true as Facebook.Moq is highly dependent on CallBase being enabled.
Shorthand for the above code is

var mockFb = FacebookMock.New();

### Return particular json result for any requests.

mockFb
.FbSetup()
.ReturnsJson("{\"id\":\"4\",\"name\":\"Mark Zuckerberg\",\"first_name\":\"Mark\",\"last_name\":\"Zuckerberg\",\"link\":\"http:\\/\\/www.facebook.com\\/zuck\",\"username\":\"zuck\",\"gender\":\"male\",\"locale\":\"en_US\"}");

var fb = mockFb.Object;

dynamic result = fb.Get("/4");

Assert.Equal("Mark Zuckerberg", result.name);

## License
Facebook.Moq is intended to be used in both open-source and commercial environments.

Facebook.Moq is licensed under Microsoft Public License (MS-PL).