Posts

Showing posts with the label xunit

.net core 2.1 test API controller missing AspNetCore.Mvc reference

Image
Clash Royale CLAN TAG #URR8PPP .net core 2.1 test API controller missing AspNetCore.Mvc reference I'm trying to tests an API controller with .net core 2.1 as from this MS doc. My code looks like [Fact] public async Task ShouldReturnOkWithHealthBackend() { var apiConsumerService = new Mock<IApiConsumerService>(); apiConsumerService.Setup(m => m.Consume()).Returns(Task.FromResult(true)); var controller = new HealthController(apiConsumerService.Object); await controller.GetHealth(); } When doing the await controller method invocation I get stucked with an "Assembly not referenced error" I can add the using Microsoft.AspNetCore.Mvc; But VS says that AspNetCore does not exists in the Microsoft namespace. Intellisense suggests me to add some references but this doesn't work too. But clicking it does nothing. I have also tried to play with the csproj file to see if I can force those assemblies to be loaded but still no...