How to initialize IOption for unit testing a .NET core MVC service?

I discovered the answer shortly after posting the question.

use Helper class Microsoft.Extensions.Options.Options

Creates a wrapper around an instance of TOptions to return itself as
IOptions

AppSettings appSettings = new AppSettings() { ConnectionString = "..." };
IOptions<AppSettings> options = Options.Create(appSettings);
MyController controller = new MyController(options);

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)