368 questions
1
vote
2
answers
117
views
How to fake a second function call using FakeItEasy?
I have a class that looks like this:
public int DoWork(int value)
{
return value + GetDataFromDB();
}
public int GetDataFromDB()
{
return 10;
}
In the real world the second function goes ...
0
votes
0
answers
33
views
Fake TableClient.QueryAsync<TableEntity>()
I'm trying to mock the return set in tableClient.QueryAsycn<TableEntity>(), but it continues to return empty lists. Is there anything glaringly obvious that I'm missing in my unit test.
The ...
1
vote
2
answers
143
views
How to fake a LocalCertificate in ASP.NET Core integration tests?
I'm working on an ASP.NET Core project, and I need to write an integration test that involves using SSL certificates. Specifically, I want to fake the LocalCertificate property in the integration test....
0
votes
1
answer
71
views
How to mock a db access with unitOfWork and repository (.NET Core 6)
In a PUT route, I have an utility method where we put the business logic (so we can call the method and not the route when we need to do the job that route does).
I don't understand how can I fake the ...
0
votes
2
answers
112
views
FakeItEasy ClearRecordedCalls not working on wrapping fake
I'm using the DI container to create my fakes for integration testing. I'm calling this method for all the interfaces I need to fake in my ConfigureServices function in my Application factory:
public ...
0
votes
1
answer
187
views
Faking a lazy out parameter value on a generic interface in FakeItEasy?
I have a generic C# interface that I'm trying to mock with FakeItEasy for an xUnit test like this:
#region FakeItEasyDebugging
public interface IFakeTest<T> : IDisposable where T : new()
...
1
vote
1
answer
2k
views
How to fake a static function using FakeItEasy
I have the function like this :
public class myClass
{
public static string myFunction()
{
return "returnValue";
}
}
I want to fake myClass() using FakeItEasy.
And I wrote:
var ...
0
votes
0
answers
59
views
Faking a service does not work. It calls the actual implementation of the service instead
I am faking a service using FakeItEasy
string phone = "123456";
var response = new VerifyResponse();
var fakeVerifyService = A.Fake<IVerifyService>();
var verifyCall = A.CallTo(() =&...
0
votes
1
answer
444
views
Mocking an AWS ScheduledEvent class using C# .NET
I am trying to verify that data coming in the Detail property of an AWS ScheduledEvent object is correct. The information should be coming in from EventBridge with JSON in the Detail property that ...
0
votes
1
answer
92
views
Creation fake of Amazon.DynamoDBv2.DocumentModel.Search with FakeItEasy
I may doing something wrong but can't find the answer.
It seems that line
var searchFake = A.Fake<Search>();
should simply work. But it always gives me the error
Constructor with signature () ...
-1
votes
1
answer
466
views
How to mock a protected method of a non-fake class using FakeItEasy?
I'm trying to add FakeItEasy-based unit tests to a REST API controller of an ASP.NET core app. The public controller methods I need to test call the protected authorization methods implemented in the ...
0
votes
2
answers
632
views
How to fake DbContextOptions
I'm writing a unit test for ConsumerService that uses EntityFramework Core. Below you can see my AppDBContext class, and its one and only constructor. In order to fake it, I'm required to pass ...
0
votes
1
answer
53
views
How do I refactor a code implementing 'using' key word , so that I can write unit tests for the method?
So, It seems I have arrived at an impasse. I have asked to write unit test for a legacy code base in .Net however I am frequently coming across code that is implementing the 'using' statement. This is ...
0
votes
1
answer
832
views
How to mock Dapper call to execute stored procedures with parameters?
I am using the following line in my code to execute the stored procedure,
var parameters = new DynamicParameters();
parameters.Add("MYPARAM", field.ListPickListCode, DbType.String, ...
0
votes
2
answers
216
views
How to check if a public method calls another public method using FakeItEasy
I have the following Interface & Class
and I also wrote a unit test as shown down, but I got an exception:
Assertion failed for the following call:
AsyncConsole.example1.IPlayer.Start(i: 1)
...
0
votes
1
answer
259
views
FakeItEasy A.CollectionOfFake doesn't work
I have a simple WCF service that returns a list of PackagesModel.UnitTypeList to my ASP.NET MVC 4 controller
[HttpGet]
public ContentResult GetUnitType()
{
List<PackageModelUnitTypeList> ...
1
vote
2
answers
163
views
Xunit.net: Validating model returned by an async ASP.NET method
I have been writing unit testing for the API. I need to check whether values inside the model returned by the action method are expected or not.
[Fact]
public async Task ...
0
votes
2
answers
279
views
Fake IMongoQueryable with FakeItEasy
I'm developing an API which communicates with MongoDB and I need to create some statistics from one collection. I have the following service:
public class BoxService : IBoxService
{
private ...
2
votes
1
answer
1k
views
Error while testing my async function using XUNIT in c# .net core
I have convereted my IEnumerable function into a (public async Task<List>) however im having issues fixing my unit test for that specific part. Im using fakeiteasy to mock my data, and assert ...
4
votes
1
answer
914
views
How to make FakeItEasy capture full argument state?
I have a piece of code like this (simplified):
await realApiClient.DoSomething(entity);
entity.Email = newEmail;
await realApiClient.DoSomethingElse(entity);
In my test I have created a fake and want ...
0
votes
1
answer
375
views
Why is faked IMemoryCache returning default value on Get
I'm writing a unit test and therefore i need to fake an IMemoryCache.
public MyUseCaseTest()
{
this.myCache = A.Fake<IMyCache>();
}
When i run the test and the tested method is called, the ...
0
votes
1
answer
204
views
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 ...
1
vote
1
answer
328
views
FakeItEasy - Invokes with option member arguments in F#
When attempting to supply a fake delegate for a method with an optional parameter in a faked object
type MyType () =
abstract B: ?s:string -> unit
default x.B (?s: string) = Option.iter (...
0
votes
1
answer
908
views
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 ...
1
vote
1
answer
4k
views
Mock repository that depends on DBContext using FakeItEasy
I'm developing an application with .NET Core and EF. I'm trying to implement some unit test using FakeItEasy and NUnit. Here's my problem.
I've a DbContext as this one:
public class PostgresDbContext :...