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

FakeItEasy does not allow to setup value to return

I cannot understand why FakeItEasy does not allow me to set return value for public method with parameters. The code: var fakeInstanse = A.Fake(); A.CallTo(() => fakeInstanse.Method(param1, param1)); The Method is the public one, accepts…
shytikov
  • 9,155
  • 8
  • 56
  • 103
3
votes
1 answer

FakeItEasy DbSet / IQueryable - Entity Framework 6

I was wondering if anyone had a similar example to this post for FakeItEasy (original post is here. I have been trying to find the correct setup, but could not get it right. I could not find any examples online. I am beginning to teach myself unit…
jmzagorski
  • 1,135
  • 18
  • 42
3
votes
3 answers

Partial Mocking/Faking in Unit Testing

I have a question about FakeItEasy (or other mock objects since I belive they are pretty similiar). The following is my puesdocode: public class Service { public void CheckService() { ... Status status; if…
Kyle
  • 406
  • 7
  • 20
3
votes
2 answers

Using FakeItEasy with Linq Expression Parameter

I am trying to use learn how to use FakeItEasy, and wanted to try using it with some data access code from an old project I have access to. While the basics of FIE seemed pretty easy, and I was able to get simple cases working, this one has me…
ADent
  • 35
  • 1
  • 3
3
votes
2 answers

Rhino Mocks 'Expect' with FakeItEasy

I have a database manipulating object as a dependency of my UUT (Unit Under Test). Therefore, I want to make it as a strict mock, because I also want to make sure that the UUT does not call any other methods that can result db change. In rhino…
Kornél Regius
  • 2,989
  • 5
  • 30
  • 39
3
votes
1 answer

FakeItEasy Reset calls to an object

I use fake it easy to generate fakes for my object. Now I test if some of the methods on the fake objects where called. The thing is I want for each unit test to reset the state of the fake back to original state. I need this because I generate the…
Alecu
  • 2,627
  • 3
  • 28
  • 51
3
votes
1 answer

Does CallBaseMethod () works for virtual property in FakeItEasy?

I have simple class public class Simple { public virtual int VirtualProperty { get; set; } } When i run (FakeItEasy.1.13.1) var strict = A.Fake(options => options.Strict()); A.CallTo(() =>…
dskalski
  • 31
  • 1
3
votes
2 answers

FakeItEasy ReturnsLazily with out parameter

I'm new to using FakeItEasy and rather stuck at my first attempt. The interface i want to fake has a method like this: byte[] ReadFileChunk(string path,int offset,int count,out long size); I would like to see how the arguments are passed on, so I'm…
3
votes
2 answers

Test project scans my controllers twice

I've created a github repo for this specific post which can be found at https://github.com/CrazyInCode/WebApiNServiceBus What I'm trying to do is to write tests for my WebApi application. In my specs tests I'm... Creating a HttpClient to consume…
2
votes
3 answers

FakeItEasy callback implementation

How do I translate this moq code: fooMoq.Setup(x => x.SayHello("xxx")).Returns("hello").Callback((string name) => { Assert.AreEqual(name, "xxx"); }); into FakeItEasy?
Hagai Cohen
  • 111
  • 1
  • 3
  • 10
2
votes
2 answers

Fake MongoDB collection with FakeItEasy in C#

I'm trying to write unit tests for my .NET Core API's service layer with NUnit and FakeItEasy and I have troubles with faking the connection to Mongo. The service is from the Microsoft documentation with small changes. Here is my…
cs.kali
  • 198
  • 12
2
votes
1 answer

Error while testing my async function using XUNIT in c# .net core

I have convereted my IEnumerable function into a (public async Task) however im having issues fixing my unit test for that specific part. Im using fakeiteasy to mock my data, and assert that my result.count == 1 after fetching my data. However…
2
votes
1 answer

How to mock AsyncPolicyWrap or AsyncPolicy in .Net Core using FakeItEasy

I have a code like this (I have to test a repo, you'll see the code below) public class SomeClass { public AsyncPolicyWrap PropName { get; } public SomeClass(...) { PropName =…
2
votes
1 answer

Why does calling AutoFake.Provide() wipe out fakes already configured with A.CallTo()?

Why does calling fake.Provide() wipe out fakes already configured with A.CallTo()? Is this a bug? I'm trying to understand a problem I've run into with Autofac.Extras.FakeItEasy (aka AutoFake). I have a partial solution, but I don't understand…
Katie Kilian
  • 6,815
  • 5
  • 41
  • 64
2
votes
1 answer

Strict fake forces event subcriptions to be configured in FakeItEasy 7.0

When I am using strict fake with event handlers subscriptions, those are reported as not configured in FakeItEasy 7.0. When fake is strict, an exception is thrown - 'Call to unconfigured method of strict fake: IFoo.add_MyEvent(value:…
Petr Behenský
  • 620
  • 1
  • 6
  • 17