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
1
vote
1 answer

FakeItEasy: Simple Fake not being used

I'm trying to use FakeItEasy (version 4.9.1) to create unit tests for some legacy code. I've created two unit tests, one of which works just as expected, and one very similar which doesn't work despite lots of trial and error. Here's an excerpt from…
Gustaf Liljegren
  • 311
  • 4
  • 15
1
vote
2 answers

Checking calls on multiple returned, wrapped fakes with FakeItEasy

I have two interfaces like this: public interface Store { Tx BeginTx() } public interface Tx { void Write() } And I have a method like this: void WriteALot(fakeStore) { var tx1 = fakeStore.BeginTx(); tx1.Write(); var tx2 =…
asgerhallas
  • 16,890
  • 6
  • 50
  • 68
1
vote
1 answer

FakeItEasy not verifying call for Full Framework SignalR test

I have a simple hub that I am trying to write a test for with FakeItEasy and the verification of calling the client is not passing. I have the example working in a separate project that uses MOQ and XUnit. public interface…
Kevin LaBranche
  • 20,908
  • 5
  • 52
  • 76
1
vote
1 answer

Can I tell the base class implementation to do nothing?

I'm dealing with a brownfield app. Due to high complexity and no existing tests, dependency injection is not an option at this point. This code also does not program to interfaces. So any solution I come up with has to not use DI or…
P.Brian.Mackey
  • 43,228
  • 68
  • 238
  • 348
1
vote
1 answer

Expression> vs Func in method overloading

Following 3 methods are part of a library I use, FakeItEasy: public static T Matches(this IArgumentConstraintManager scope, Func predicate, string description); public static T Matches(this IArgumentConstraintManager manager,…
mbudnik
  • 2,087
  • 15
  • 34
1
vote
1 answer

Unit Testing - faking out Dapper QueryMultipleAsync

I am using the Dapper QueryMultipleAsync to split the result of a SQL query into a number of different objects. However I am having trouble finding a way to unit test the method that this call is in. I have been using Fake it Easy to fake out…
Simon.A
  • 11
  • 3
1
vote
1 answer

How to assert MustHaveHappend(Collection.That.Contains(object)) in fake it easy

I have a course repository as follows in the Arrange A.CallTo( () => _courseClientStatusRepository.GetTnCoursesForClientStatus()).Returns(new List { new…
Ntu
  • 41
  • 4
1
vote
0 answers

NCrunch and FakeItEasy.OutAndRefParametersConfigurationExtensions

I have a codebase with NUnit test suites, which I run with both Resharper Unit Test Sessions and NCrunch. One of my test requires FakeItEasy.OutAndRefParametersConfigurationExtensions. Most of the time it works, but occasionally NCrunch fails that…
Brondahl
  • 7,402
  • 5
  • 45
  • 74
1
vote
1 answer

How to unit test if call to static logger happened

Consider a method with a try catch like this: try { person = this.personRepo.GetPerson(name); } catch (PersonException) { LogHelper.LogDebug("PersonService", "No Person found!"); } In the unit test, the personRepo is faked with…
xeraphim
  • 4,375
  • 9
  • 54
  • 102
1
vote
3 answers

How to mock out call to service in an integration test?

Let us say I want to perform an integration test on an API controller method looking like this: public async Task Get(Guid id) { try { if (id == Guid.Empty) { return new…
Jagjit Singh
  • 661
  • 9
  • 16
1
vote
3 answers

Faking Confluent .NET Kafka consumers

Environment: .NET 4.5. FakeItEasy : 4.0.0 I am trying to create a fake object of Kafka consumer, below is the syntax I use: var fakeconsumer = A.Fake>((x => x.WithArgumentsForConstructor(() => new Consumer
Nandu
  • 808
  • 7
  • 10
1
vote
1 answer

fakeXrmEasy for crm testing initialization issues

I'm trying to follow the basic tutorial for FakeXrmEasy, but I'm not sure why I'm getting errors. I installed everything that needs to be installed to mock Dynamics 365, but I'm still getting errors. I can't figure out what I'm missing, I really…
amberl
  • 81
  • 1
  • 17
1
vote
1 answer

CallTo does not work in a loop

I am trying to create a fake of an object cache class to use in a test, and I am running into strange behavior. I started with this: IObjectCache objectCache = A.Fake(); List objects = new…
Joe Schrag
  • 855
  • 8
  • 23
1
vote
1 answer

MustHaveHappened Assert always fails for an async method run on a separate thread (Task.Run)

I have a method: public class MyClass { public ILogger _logger; public async void TestLogMethod(string msg) { await Task.Run(async ()=> await _logger.Log(msg)); } } And a testcase: [Test] public async Task…
Tany
  • 1,252
  • 14
  • 30
1
vote
1 answer

Invoke event for FakeItEasy stub

I inject a stub generated with FakeItEasy to my class. At some point my class subscribes to dependency's event. I want to invoke this event afterwards as part of my test method but it does not seem to work: var restApiManager =…
SiberianGuy
  • 24,674
  • 56
  • 152
  • 266