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

Difference in Behavior between Rhino and FakeItEasy

We're considering switching from Rhino to FakeItEasy for our mocking framework. The main reason is simplicity, in FakeItEasy there's only one way to do things. Rhino has record/playback, AAA, stub, partial mock, strict mock, dynamic mock, etc. I'm…
Craig W.
  • 17,838
  • 6
  • 49
  • 82
0
votes
1 answer

How can I fake something which returns different answers over time using FakeItEasy?

I'm trying to fake a sealed external audio source using FakeItEasy. I've wrapped the audio source and successfully faked the wrapper, so I know the basics are right. Here's the bit I'm currently stuck on: The audio source returns isPlaying = true…
piersb
  • 609
  • 9
  • 22
0
votes
1 answer

xUnit is using a previous iteration to evaluate a different case when using Theory and InlineData

I'm trying to test a method and verify whether another method was called or not. This depends on a bool value. If it's true, the other method should be called. Still, the assertion occasionally works because the true scenario might run before the…
0
votes
1 answer

Why am I getting 'Call to unconfigured method' when using wrapped functionality?

Using version 7.3.0 of FakeItEasy. In following code I am getting message that call to method GetById is not configured, yet I am configuring it. What I am doing wrong? There is no overload for the GetById method. var fakeConnection =…
epitka
  • 17,275
  • 20
  • 88
  • 141
0
votes
1 answer

System.Threading.Tasks.Extensions error when faking "BlobContainerClient" of Azure

I have a unit test project that is using Nunit and Fakeiteasy and targeting .net framework 4.8. Yesterday I've added few test methods that are mocking "BlobContainerClient" of Azure storage. Locally all of the unit tests are passed but when I push…
Ask
  • 3,076
  • 6
  • 30
  • 63
0
votes
1 answer

How to wrap instance yet forward calls to wrapped instance members?

Given I have a wrapped instance like this, where Resolve method injects dependencies var handler = this.Resolve(); var wrapperHandler = A.Fake( o => o.Wrapping(handler)); …
epitka
  • 17,275
  • 20
  • 88
  • 141
0
votes
1 answer

Reflect over decorator to assert internal mock called

I have an interface, IFoo, with some number of methods. I also have an implementation of IFoo which decorates any IFoo, so something like: class FooDecroator : IFoo { FooDecorator(IFoo decoratedFoo) { ... } public void SomeFooMethod() { …
Mike
  • 150
  • 1
  • 8
0
votes
1 answer

Is it possible to create a generic method that take a method group as an argument

I'm trying to create a method that would allow a "method group" to be passed in. Basically this is for testing where I want to make sure that a method was called. FakeItEasy already allows for the following code public static…
Alex Krupka
  • 710
  • 9
  • 20
0
votes
2 answers

FackItEasy: How to get access to the value of a parameter passed to a faked interface?

I would like to check a property of a structure passed to a faked interface: JobSpec passedJobSpec = null; A.CallTo(() => fakeInvoker.Create(A._)) .Invokes((JobSpec jobSpec) => passedJobSpec =…
hagh
  • 507
  • 5
  • 13
0
votes
0 answers

How can I fake non-virtual members of an commercial library with FakeItEasy?

I am developing an .NET core OPC client on VS2019 using a commercial library to communicate with an OPC server. I am trying to test my code with Nunit and FakeItEasy. I need to Fake calls to a class Discovery but the members are non-virtual and…
sdmorris
  • 339
  • 1
  • 7
  • 18
0
votes
1 answer

FakeItEasy in C# on a servicereference

I have a servicereference with a method I need to use in a test. The servicereference class is defined as: public class MyServiceReference : Clientbase, IMyServiceReference { public MyServiceReference() { } .....…
0
votes
1 answer

AutoFixture AutoDataAttribute Customization Beyond Derived Attribute

I am using the AutoDataAttribute class within AutoFixture.Xunit2 in a lot of projects. The recommended approach to add your own customizations seems to be a derived attribute like the following (note I am using FakeItEasy): public class…
Shawn
  • 869
  • 1
  • 9
  • 27
0
votes
1 answer

Unit testing Azure functions v3 with xUnit and FakeItEasy

I am trying to implement some unit/integration testing to an Azure v3 HTTP trigger and am running into some issues with the process. I previously wrote some testing for an API controller that was using syntax like so: TransactionResponse…
orgg
  • 97
  • 1
  • 9
0
votes
1 answer

FakeItEasy: faking return value when anonymous type is returned

I have a function: TResult ShowDialogWindow(Func viewModelActivator, Func viewActivator, Func dialogResultFunc) I would like to fake the…
Igor Pashchuk
  • 2,455
  • 2
  • 22
  • 29
0
votes
2 answers

Assert that multiple unordered calls occur before a final call

I have a service that Makes a call to each registered class that implements a specific interface (IUnorderedService) Then makes a final call to another service (IFinalService) I want to write a test that asserts that my service makes a call to…
dybzon
  • 1,236
  • 2
  • 15
  • 21