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
2 answers

How to "skip" over void method with FakeItEasy?

I have this code in a method I´m unittesting public void SomeMethod() { IMyLogger log = new Logger(); log.ConfigLogger(); // Trying to not call this method //...some other code... } Where this is the Logger class public class Logger :…
Sturla
  • 3,446
  • 3
  • 39
  • 56
1
vote
2 answers

Fake WCF-Service calls with FakeItEasy

I want to test my Class, which calls the third Party Webservice. Is it possible to use FakeItEasy for this? Wenn I try to Fake the Class from Reference.cs (auto generated), UnitTest started and doesn't come back. Reference.cs(auto generated) …
Anny Igi
  • 95
  • 2
  • 11
1
vote
1 answer

Howto loop OrderedAssertions in FakeItEasy 2

As I understand, ordered assertions in FakeItEasy 2 are done like this (from the docs): // Assert A.CallTo(() => unitOfWorkFactory.BeginWork()).MustHaveHappened() .Then(A.CallTo(() => usefulCollaborator.JustDoIt()).MustHaveHappened()) …
AroglDarthu
  • 1,021
  • 8
  • 17
1
vote
1 answer

issue with fakeiteasy while throwing exception

I am using NUnit with FakeIteasy My test Method: [Test] public async Task SiteDetailsView_NMSException() { url = "/Svc/v1/Sites/GetNextID?UID=" + orgUID; A.CallTo(() => fake.GetDataAsync(fakeHttpSession,…
AMDI
  • 895
  • 2
  • 17
  • 40
1
vote
1 answer

"No persister for 'Class'" error when testing Fluent NHibernate with FakeItEasy

I'm writing some Persistence tests but am getting an error that NHibernate can't seem to work with FakeItEasy's fakes. Specifically the error is: No persister for: Castle.Proxies.FacilityProxy If I write the test like below it'll work fine and…
prestonsmith
  • 758
  • 1
  • 9
  • 29
1
vote
1 answer

How to Unit Test with fakes when the class you're testing uses reflection in C#

I'm trying to unit test a factory class that uses reflection to construct an unknown object that derives from a known base class. However, I'm getting an exception when the factory tries to invoke the the constructor derived from my fake unit's…
1
vote
1 answer

FakeItEasy property getter call rule not triggered

I'm trying to get FakeItEasy 1.25.3 to throw an exception on a property; the setter test works fine but the getter does not throw an exception as expected. What am I doing wrong? public interface IMisc { int IntProperty { get; set; } } //…
user152949
1
vote
1 answer

Why are dictionary elements being added by reference in C#?

I am trying to do something that seems like it should be easy, but it is not working. I have a dictionary objects with an int key. Within the objects, I have a property, PositionInEvent, that I want to match the key of the dictionary within it. It…
Jon Falkenstein
  • 135
  • 1
  • 9
1
vote
1 answer

How to verify method parameters with FakeItEasy as well as that a call has been made

I'm using FakeItEasy to do some testing, but I have run into a problem. When testing that the expected data is sent to a faked service, I would like to be able to see the error data as well. Right now I only see that the call never happened. Maybe…
Markus
  • 1,614
  • 1
  • 22
  • 32
1
vote
1 answer

How to setup specific call to for mocks?

I'm using FakeItEasy to mock stuff within unit tests but somehow i fail to setup pretty basic scenario. ie. i want to throw exception when specific user accesses a method. Help would be nice... thanks A.CallTo(() => m_fancyRepository …
eugeneK
  • 10,750
  • 19
  • 66
  • 101
1
vote
3 answers

Get method name of property setter in c#

I am using FakeItEasy to check that a call to the public setter method of a property has been called. The property is called Description, and at the moment I am testing it like this: A.CallTo(model) .Where(x =>…
James Monger
  • 10,181
  • 7
  • 62
  • 98
1
vote
1 answer

FakeItEasy argument constraint being evaluated as null outside of lambda

Using FakeItEasy, I have a setup similar to the one below in one of my tests, and the CallTo assertion at the bottom is failing when setup like this. var fakedTool = A.Fake(); var concreteUnderTest = new…
James Monger
  • 10,181
  • 7
  • 62
  • 98
1
vote
1 answer

Unit Test Mock Controller, C# Do I need to Mock HTTPContext? What methods do I mock?

I am tasked with writting unit Tests for some code we have in our Database. The Unit Tests must Mock everything, and test for both passing and failed scenarios. Currently I am using NUnit and FakeItEasy, I have used Moq in the past and don't mind…
jward01
  • 750
  • 4
  • 11
  • 26
1
vote
1 answer

FakeItEasy Action parameter in UnitTest, but still execute inner Action code

I'm currently making some UnitTests for some new features I've added to our ASP.NET project (no it's not test-driving design). We use the NHibernate framework and use the UnitTest Mock-ing library FakeItEasy. I have the following class & method…
Kevin Cruijssen
  • 9,153
  • 9
  • 61
  • 135
1
vote
1 answer

How do I test extension method of Nhibernate which does not return the value even after specifying return in fakeiteasy?

I have a class like below where using Fluent Nhibernate I am getting data from database public class MyActualClass { public MyActualClass(ISessionFactory sessionFactory) { this.sessionFactory = sessionFactory; } public…