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
2
votes
1 answer

Faking an nHibernate session with FakeItEasy

I would like to inject a fake nHibernate session into my repository using FakeItEasy, then return a list of objects that are predefined within my test. Does anyone have experience doing this? Here is the example test: [TestFixture] public class…
jdscolam
  • 988
  • 8
  • 20
2
votes
1 answer

Fake internal calls of a SUT with FakeItEasy

I have a small C# class that handles printing. I want to create (n)unit tests for this class, using fakeItEasy. How can I fake the internal calls of this class without faking the whole SUT ? For example: public class MyPrintHandler:…
ejw
  • 21
  • 2
2
votes
0 answers

Setting a property value on a fake (FakeItEasy library) seems not to work

I want to create interrelated objects via the FakeItEasy framework the following way var gameWorld = A.Fake(); var entityManager = A.Fake(); A.CallTo(() =>…
Marco
  • 2,189
  • 5
  • 25
  • 44
2
votes
1 answer

Unit Testing class with IStringLocalizer

I have a class with a constructor, that gets an IStringLocalizer injected. public MailBuilder(IStringLocalizer stringLocalizer) { ... } I'm trying to setup the fake of the string localizer: A.CallTo(() =>…
xeraphim
  • 4,375
  • 9
  • 54
  • 102
2
votes
1 answer

FakeItEasy: Return different objects based on expression

I have a repository that I fake and I need based on expression return different values A.CallTo(() => repository.FirstOrDefaultAsync(x => x.Id == busMessage.Id && x.GroupType == ObjectType.Office)).Returns(dbOffice); A.CallTo(() =>…
Burim Hajrizaj
  • 383
  • 4
  • 14
2
votes
1 answer

Can you use FakeItEasy with EF Core

I am wondering if I can use FakeItEasy with EF Core? I need to write some unit tests around CRUD operations. Can someone provide some insight into whether I should use In memory database or FakeItEasy? Any help regarding this will be highly…
Vin
  • 101
  • 1
  • 1
  • 4
2
votes
1 answer

How do I perform integration test on WebApi controller using FakeItEasy?

I am new at implementing unit tests and integration tests. I am trying to write some integration tests for my application. Following are the code snippets from my application to give you all the idea of my code. It would be great help if you could…
2
votes
1 answer

Mock private methods using FakeItEasy

I have achieved a solution to mock test the public virtual method using FakeItEasy Framework. Below I have a Test class with Private method and private method cannot be virtual. So please help me t mock the Private method using FakeItEasy…
Sujeet Singh
  • 165
  • 3
  • 13
2
votes
1 answer

How to correctly assert MustHaveHappend(object) in fake it easy

I am having a test method that asserts if the CreateClient method of the client account repository has been called. Please See the test bellow. [TestMethod] public void CreateNewBasicClientAccount_NewBasicClient_CreatesNewClientBasicClient() …
Ntu
  • 41
  • 4
2
votes
3 answers

FakeItEasy not finding call although its there

I experience some strange problems with FakeItEasy. Imagine following unit test method: [TestMethod] public void DeletePerson_WhenCalled_ThenPersonIsDeleted() { const int personId = 24; var commonParam = new CommonParam(); …
xeraphim
  • 4,375
  • 9
  • 54
  • 102
2
votes
2 answers

FakeItEasy - How to verify nested arguments value C#

I need your help in order to find a way of verifying the value of nested objects passed as a parameter of the method under test invocation. Assume this class: public class AuditTrailValueObject { public ActionType Action { get; private set; } …
Roni
  • 369
  • 1
  • 7
  • 22
2
votes
1 answer

How to wait for a call that takes a specific linq expression as an argument

I Have a call I wish to check has happened. This call is to a method that takes a Linq expression as an argument. This expression tests an objects id against the id of a local variable where the expression is declared. How can I make a fake it easy…
milo.farrell
  • 662
  • 6
  • 19
2
votes
3 answers

creating linked data with fakexrmeasy

How do you create an entity and link another entity to it in FakeXrmEasy? I am attempting to test this code: public List GetTasks(Guid workOrderGuid) { var result = (from task in _xrmServiceContext.abc_OrderTaskSet …
Alex Gordon
  • 57,446
  • 287
  • 670
  • 1,062
2
votes
1 answer

Fake it easy: Invoke does not work

I would like to check if the following method is called with the correct list of errors. void ShowErrorCollection(string description, List errors); My configuration of fake it easy looks like this, I am trying to save the given list to a…
HerrLoesch
  • 1,023
  • 1
  • 13
  • 24
2
votes
1 answer

How to assert "no calls to an object have been made"?

How to assert that no calls to an object have been made using FakeItEasy? I tried: A.CallTo(() => _myObj).MustNotHaveHappened(); That does not work though, it throws the following exception: System.ArgumentException : The specified expression is…
D.R.
  • 20,268
  • 21
  • 102
  • 205