.Net Core Unit Testing - Mock IOptions
Jak
908
Points
132
Posts
|
I have a .NET core rest api service and controller. I'm using xUnitTest to test the controller and service. In my unit test project to test the service/controller. I'm not able to mock/initialize an instance of IOptions to satisfy the constructor of my controller:
Use Microsoft.Extensions.Options.Options - beginer 25-Apr-2020 01:59
|
Answers
Alice
32
Points
1
Posts
|
Use Helper class Microsoft.Extensions.Options.Options Options.Create() a wrapper around an instance of TOptions to return itself as IOptions
Posted On:
25-Apr-2020 02:03
|
Smith
2890
Points
78
Posts
|
Check following code:
For this following package to be installed
And import package as:
Posted On:
30-Apr-2020 05:31
Thanks - Jak 01-May-2020 21:12
|
Blog
Active User (0)
No Active User!