How to return a valid data instead of (null, 0). Moq, mock

Viewed 40

I try to mock a method of a service. The method returns a TupleValue with (List<AnyViewModel>, int).

The mock which I use

mockService.Setup(s => s.GetAll(It.IsAny<int>(), It.IsAny<string>())).ReturnsAsync((testViewModels, countOfEntities))

In this case, the mock returns (null, 0).

Why is this happening and how to fix it?

UPD

Interface

public Task<(List<AnyViewModel>, int)> GetAll(int Id, string? search = null);

I tried to collect data like this

var tupleToReturn = ValueTuple.Create<List<AnyViewModel>, int>(testViewModels, countOfEntities);

// mock block
mockService.Setup(s => s.GetAll(It.IsAny<int>(), It.IsAny<string>())).ReturnsAsync(tupleToReturn)

It doesn't work

0 Answers
Related