You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.9 KiB

using apiLOL.Controllers;
using apiLOL.DTO;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using StubLib;
namespace TestUnitaire
{
public class TestAPILol
{
[Theory]
[InlineData("Beatrice", "sdfsdfd")]
[InlineData("Maurice", "Ahri est un champion de League of Legends")]
[InlineData("Loupiotte", "Akali est un champion de League of Legends")]
public async Task TestPostChampion(string name, string bio)
{
// Arrange
var data = new StubData();
var logger = new NullLogger<ControllerChampions>();
var controller = new ControllerChampions(data, logger);
var champDTO = new ChampionDTO(name, bio);
// Act
var nbInListBefore = data.ChampionsMgr.GetNbItems().Result;
var result = await controller.Post(champDTO);
var nbInListAfter = data.ChampionsMgr.GetNbItems().Result;
// Assert
// IS the champion added to the list, number of champions in the list + 1
Assert.Equal(nbInListBefore + 1, nbInListAfter);
// Test le code de retour
}
[Theory]
[InlineData("Beatrice", "Aatrox est un champion de League of Legends")]
[InlineData("Maurice", "Ahri est un champion de League of Legends")]
[InlineData("Loupiotte", "Akali est un champion de League of Legends")]
public async Task TestGetChampion(string name, string bio)
{
// Arrange
var data = new StubData();
var logger = new NullLogger<ControllerChampions>();
var controller = new ControllerChampions(data, logger);
var champDTO = new ChampionDTO(name, bio);
// Act
// Call method POST to add a champion
var result = await controller.Post(champDTO);
// Call method GET to get the champion
var resultGet = await controller.GetChampion(name);
// Assert
// IS the champion added to the list, number of champions in the list + 1
Assert.Equal(name, champDTO.Name);
Assert.Equal(bio, champDTO.Bio);
}
}
}