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
- Host: GitHub
- URL: https://github.com/prabirshrestha/facebook.moq
- Owner: prabirshrestha
- License: other
- Created: 2011-06-23T05:17:14.000Z (almost 14 years ago)
- Default Branch: master
- Last Pushed: 2023-12-15T08:20:47.000Z (over 1 year ago)
- Last Synced: 2025-03-29T09:05:08.588Z (3 months ago)
- Language: C#
- Homepage:
- Size: 3.72 MB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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 isvar 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).