Add test controlleur, mais marche pas des masses (mon côté api doit pas être fou)
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
d6723ed2b6
commit
18a853a3d0
@ -1,8 +1,49 @@
|
||||
|
||||
using Microsoft.Extensions.Logging.Abstractions;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Model;
|
||||
using StubLib;
|
||||
using API.Controllers.version2;
|
||||
using API.Dto;
|
||||
using EFManager;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Moq;
|
||||
using FluentAssertions;
|
||||
using EFlib;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using static EFManager.ManagerData;
|
||||
|
||||
namespace TestAPI
|
||||
{
|
||||
|
||||
public class UnitTestChampionController
|
||||
{
|
||||
/*[Fact]
|
||||
public async Task GetChamps_ReturnsOkResultWithChampionDtoList()
|
||||
{
|
||||
// Arrange
|
||||
var options = new DbContextOptionsBuilder<SQLiteContext>()
|
||||
.UseSqlite("DataSource=:memory:")
|
||||
.Options;
|
||||
using (var context = new SQLiteContext(options))
|
||||
{
|
||||
context.Database.EnsureCreated();
|
||||
context.Champions.Add(new EFChampion { Name = "Champion 1" });
|
||||
context.Champions.Add(new EFChampion { Name = "Champion 2" });
|
||||
context.SaveChanges();
|
||||
|
||||
var controller = new ChampionController(new ManagerData(context), NullLogger<ChampionController>.Instance);
|
||||
|
||||
// Act
|
||||
var result = await controller.GetChamps();
|
||||
|
||||
// Assert
|
||||
var okResult = Assert.IsType<OkObjectResult>(result.Result);
|
||||
var dtoChamps = Assert.IsAssignableFrom<IEnumerable<ChampionDto>>(okResult.Value);
|
||||
Assert.Equal(2, dtoChamps.Count());
|
||||
Assert.Equal("Champion 1", dtoChamps.ElementAt(0).Name);
|
||||
Assert.Equal("Champion 2", dtoChamps.ElementAt(1).Name);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
Loading…
Reference in new issue