28 lines
941 B
C#
28 lines
941 B
C#
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<string,string>
|
|
{
|
|
{"MongoDB:ConnectionString","mongodb://localhost"},
|
|
{"MongoDB:DatabaseName","test"}
|
|
}).Build();
|
|
|
|
[Fact]
|
|
public async Task Create_InvalidLocation_ReturnsBadRequest()
|
|
{
|
|
var loc = new Mock<LocationService>(config);
|
|
loc.Setup(l => l.GetByIdAsync("bad")).ReturnsAsync((Location?)null);
|
|
var controller = new ItemController(new Mock<ItemService>(config).Object, loc.Object);
|
|
|
|
var result = await controller.Create(new CreateItemRequest { LocationId = "bad", Name = "n" });
|
|
|
|
Assert.IsType<BadRequestObjectResult>(result);
|
|
}
|
|
}
|