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.
LOLProject/Sources/TestUnitaire/UnitTestChampion.cs

62 lines
1.6 KiB

using APILOL.Controllers;
using APILOL.Mapper;
using DTO;
using Microsoft.AspNetCore.Mvc;
using StubLib;
namespace TestUnitaire
{
[TestClass]
public class UnitTestChampion
{
private readonly ChampionsController controller;
private readonly StubData stub;
public UnitTestChampion()
{
stub = new StubData();
controller = new ChampionsController();
}
[TestMethod]
public async Task TestGet()
{
var champions = await controller.Get();
var resultObject = champions as OkObjectResult;
Assert.IsNotNull(resultObject);
var resultType = resultObject?.Value as IEnumerable<ChampionDTO>;
Assert.IsNotNull(resultType);
Assert.AreEqual(resultType.Count(), await stub.ChampionsMgr.GetNbItems());
}
[TestMethod]
public async Task TestPost()
{
var ChampionDtoToTest = new ChampionDTO { Bio= "This champion is a legendary Fox", Name="Foxane"};
var champions = await controller.Post(ChampionDtoToTest);
var resultObject = champions as OkObjectResult;
Assert.IsNotNull(resultObject);
var resultType = resultObject?.Value as IEnumerable<ChampionDTO>;
Assert.IsNotNull(resultType);
Assert.AreEqual(resultType.Last(), stub.ChampionsMgr.GetItems(-1, await stub.ChampionsMgr.GetNbItems()));
}
[TestMethod]
public void TestPut()
{
}
[TestMethod]
public void TestDelete()
{
}
}
}