Questions tagged [fakeiteasy]

A .NET package to create fake objects, mocks, stubs for testing.

The following description is taken from the FakeItEasy homepage:

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.
359 questions
3
votes
1 answer

Assert that a call was not made with any generic parameters using FakeItEasy

Disclaimer - this is not the same question as How to use FakeItEasy to assert a method was not called Explanation I have a piece of code which registers stuff with an IOC container, and I can use FakeItEasy in my tests to ensure that registrations…
Jay
  • 9,561
  • 7
  • 51
  • 72
3
votes
2 answers

Create class and auto-initialize dependencies with FakeItEasy

Is it possible to create a class under test with FakeItEasy, where all dependencies that are declared in the constructor are initialized automatically with fakes? Imagine the class: public class Inserting { public Inserting( …
Alexander Pacha
  • 9,187
  • 3
  • 68
  • 108
3
votes
2 answers

How to set the return value of multiple generic functions with FakeItEasy?

I am writing unit tests using Autofixture and FakeItEasy for little tasks that are talking to the database through NHibernate. My test cases also include scenarios where a given object is not found in the database, and therefore I'd like to emulate…
blas3nik
  • 1,381
  • 11
  • 21
3
votes
1 answer

A.CallTo(...).ReturnsLazily(...) throws "The specified object is not recognized as a fake object."

In C# I used to write var provider = A.Fake(); A.CallTo(() => provider.Fetch()).ReturnsLazily(call => data[0]); container.Register(() => provider); to capture calls to Fetch(). When I've tried the same with F# let provider =…
Alex Netkachov
  • 13,172
  • 6
  • 53
  • 85
3
votes
1 answer

FakeItEasy ReturnLazily with more than 4 arguments method

With FakeItEasy, I want to fake an interface method to return some custom list, the method has more than 4 arguments, signature of method is this: IList FindAll(DateTime dateFrom, DateTime dateTill, Guid locationId, Gender gender, int…
3
votes
1 answer

Why does this simple MSpec test return inconclusive?

I am using Mspec with FakeItEasy and I keep getting inconclusive test results. I tried commenting out my fake setup code and even the actual invocation of the method under test. I'm also unable to debug the test. I also just tried a simple test like…
Adam
  • 4,590
  • 10
  • 51
  • 84
3
votes
1 answer

FakeItEasy - Having an interface fake inherit from abstract while both share same interface inheritance

I have an interface public interface IInterface { void DoSomething(); } Another interface public interface IOtherInterface : IInterface { } An abstract class public abstract class AbstractClass : IInterface { public void DoSomething() { …
johnildergleidisson
  • 2,087
  • 3
  • 30
  • 50
3
votes
1 answer

How can I Fake Base Class method using FakeItEasy

Am trying to use FakeItEasy. I have a particular scenario for which either am unable to understand how to test or is not possible using FakeItEasy Lets say I have a base class and derived class which look like this public class BaseClass { …
Karthik Balasubramanian
  • 1,127
  • 4
  • 13
  • 36
3
votes
1 answer

Using FakeItEasy, is it possible to create a dummy object of a type that takes generic type parameters

I have the following test: [Fact] public void StartProgram_CallsZoneProgramStart() { var zone = A.Fake(); zone.StartProgram(); A.CallTo(() => zone.ZoneProgram.Start(null,…
Anshul
  • 1,302
  • 3
  • 15
  • 36
3
votes
2 answers

FakeItEasy, Fake a parents virtual method from the child class

I am trying to fake a call to a parents public virtual validate method from the child without success (using FakeItEasy. I have a base class that validates simple commands for similar command classes (I have reduced the code for simplicity sake): …
jmzagorski
  • 1,135
  • 18
  • 42
3
votes
1 answer

How to register dependencies that are not defined explicitly as Strict using AutoFixture with FakeItEasy?

I use AutoFixture with FakeItEasy when I need to test a class with many dependencies, but I ned to mock only some of them. All the rest of dependencies I prefer mocking with Strict() option of FakeItEasy. In order to make my test more clean, I would…
Boris Modylevsky
  • 3,029
  • 1
  • 26
  • 42
3
votes
2 answers

FakeItEasy throws ExpectationException

I have a problem mocking an interface with an (async) method. The Interface looks like this: public interface IDataAccessLayer { Task ExistsUserAsync(string username, CancellationToken cancellationToken); Task
Jörg Battermann
  • 4,044
  • 5
  • 42
  • 79
3
votes
1 answer

Can't fire event from FakeItEasy mock in unit test

I am using Test Driven Development to develop a simple application using Xamarin Studio on Mac OS X. I'm using NUnit as the test harness and FakeItEasy for mocking. I've developed an object that fires an event, and I want to test that another object…
Tron Thomas
  • 871
  • 7
  • 20
3
votes
1 answer

Using FakeItEasy A.CallTo with Instance MethodInfo without the instance

I am trying to test a method that has a using statement that creates a new concrete instance of the IDisposable type. To do this I am trying to fake a private method that is executed in the constructor of an IDisposable type. I could change the code…
wavydavy
  • 369
  • 3
  • 8
3
votes
1 answer

FakeItEasy AssignsOutAndRefParameters - lazily?

I'm trying to fake a call to a method with an out parameter, with a ReturnsLazily with some basic logic in it. Ideally, I could assign a value via AssignsOutAndRefParameters based on the ReturnsLazily. However, AssignsOutAndRefParameters only…
Crutt
  • 524
  • 5
  • 9