using GameAuthApi.Controllers; using GameAuthApi.Models; using GameAuthApi.Services; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Configuration; public class ItemControllerTests { private static IConfiguration config = new ConfigurationBuilder() .AddInMemoryCollection(new Dictionary { {"MongoDB:ConnectionString","mongodb://localhost"}, {"MongoDB:DatabaseName","test"} }).Build(); [Fact] public async Task Create_InvalidLocation_ReturnsBadRequest() { var loc = new Mock(config); loc.Setup(l => l.GetByIdAsync("bad")).ReturnsAsync((Location?)null); var controller = new ItemController(new Mock(config).Object, loc.Object); var result = await controller.Create(new CreateItemRequest { LocationId = "bad", Name = "n" }); Assert.IsType(result); } }