FakeItEasy logo

The easy mocking library for .NET

// Creating a fake object is just dead easy!
// No mocks, no stubs, everything's a fake!
var lollipop = A.Fake<ICandy>();
var shop = A.Fake<ICandyShop>();
// Easily set up a call to return a value
A.CallTo(() => shop.GetTopSellingCandy()).Returns(lollipop);
// Use your fake as you would an instance of the faked type.
var developer = new SweetTooth();
developer.BuyTastiestCandy(shop);
// Asserting uses the same syntax as configuring calls.
// There's no need to learn another syntax.
A.CallTo(() => shop.BuyCandy(lollipop)).MustHaveHappened();

A .Net dynamic fake framework for creating all types of fake objects, mocks, stubs etc.

  • Easier semantics: all fake objects are just that — fakes. Usage determines whether they're mocks or stubs.
  • Context-aware fluent interface guides the developer
  • Easy to use and compatible with both C# and VB.Net.

Additional Features

  • every faked instance looks and feels like an instance of the faked type
  • helpful exception messages identify where a test went wrong
  • raising events from faked objects
  • explicit assertions, stated at the end of the test
  • type-safe faking of classes that require constructor arguments
  • automatic generation of dummy constructor arguments, if desired
  • extensible facilities for fake and dummy creation and argument formatting