I have dot net core (v5) web api porject.
I want to make a Xunit test
for testing my web api.
I have a UsersController
for CRUD
. in my Constructor i have 4 input as shown below:
public UsersController(AppDbContext _appDbContext, IMapper _mapper, IOptions<SieveOptions> sieveOptions, SeiveProcessorService sieveProcessorService) : base(_appDbContext, _mapper)
{
_sieveProcessorService = sieveProcessorService;
_sieveOptions = sieveOptions.Value;
}
SeiveProcessorService
its a Service
in my project.
I can pass three input in my test unit but i can't pass last input.
i dont know how to send to controller
my test code is :
[Fact]
public void Test_GetList()
{
using (var context = new AppDbContext(ContextOptions))
{
//auto mapper configuration
var mockMapper = new MapperConfiguration(cfg =>
{
cfg.AddProfile(new MappingProfile(null));
});
var mapper = mockMapper.CreateMapper();
//
SieveOptions sieveOptions = new SieveOptions() {
CaseSensitive = false,
DefaultPageSize = 50,
MaxPageSize = 500,
ThrowExceptions = true,
};
IOptions<SieveOptions> options = Options.Create(sieveOptions);
// Arrange
var controller = new UsersController(context, mapper, options,????);
// Act
var result = controller.GetList(null);
// Assert
var viewResult = Assert.IsType<IResult>(result);
Assert.Null(viewResult);
}
}
}
I don't know how can send fourth input?