Mock IOptionsMonitor

You are calling the constructor of the OptionsMonitor<TOptions> class incorrectly. In this case I would have just mocked the IOptionsMonitor<AuthenticationSettings> interface For example using Moq AuthenticationSettings au = new AuthenticationSettings() { … }; var monitor = Mock.Of<IOptionsMonitor<AuthenticationSettings>>(_ => _.CurrentValue == au); ActiveDirectoryLogic _SUT = new ActiveDirectoryLogic(monitor);

.net Core Quartz Dependency Injection

You can use the Quartz.Spi.IJobFactory interface and implement it. The Quartz documentations states: When a trigger fires, the Job it is associated to is instantiated via the JobFactory configured on the Scheduler. The default JobFactory simply activates a new instance of the job class. You may want to create your own implementation of JobFactory to … Read more

docker container exits immediately even with Console.ReadLine() in a .NET Core console application

If you switch your app to target .NET Core 2.0, you can use the Microsoft.Extensions.Hosting package to host a .NET Core console application by using the HostBuilder API to start/stop your application. Its ConsoleLifetime class would process the general application start/stop method. In order to run your app, you should implement your own IHostedService interface … Read more

How to reference ASP.NET Core 6 types in .NET 6 library?

You need to add a FrameworkReference to your project file instead of a PackageReference as described here. <ItemGroup> <FrameworkReference Include=”Microsoft.AspNetCore.App” /> </ItemGroup> Right-click your project in the Solution Explorer and select “Edit Project File” to open the file and look for the <ItemGroup> section, creating a new one if it does not exist.

‘Unable to resolve service for type ¨Microsoft.entityFrameworkCore.DbContextOptions¨1[LibraryData.LibraryContext] while attempting to activate

I fixed this error by specifying –project and –startup-project options to Entity Framework Core CLI tools like this: dotnet ef database update –verbose –project CommandService.Data –startup-project CommandService –project means which project contains the DbContext class –startup-project means which project contains the database connection information and other information.

How to force Visual Studio to re-create the SSL certificate for a .NET Core Web Application running Kestrel?

I finally figured it out. For anyone else who runs into this, the steps to fix it are: All localhost certificates must be deleted in certificate manager. They can be found in Personal and Trusted Root The secrets.json file must be deleted. This can be found in \Users\[user]\AppData\Roaming\Microsoft\UserSecrets\ In powershell, re-run dotnet dev-certs https –trust … Read more

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