using APILOL.Controllers; using APILOL.Controllers.Request; using APILOL.Mapper; using DTO; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging.Abstractions; using StubLib; using System.Web.Http; namespace TestUnitaire { [TestClass] public class UnitTestChampion { private readonly ChampionsController controller; private readonly StubData stub; public UnitTestChampion() { stub = new StubData(); controller = new ChampionsController(stub, new NullLogger()); } [TestMethod] public async Task TestGet() { var champions = await controller.Get(new PageRequest()); var resultObject = champions as OkObjectResult; Assert.IsNotNull(resultObject); var resultType = resultObject?.Value as IEnumerable; Assert.IsNotNull(resultType); Assert.AreEqual(resultType.Count(), await stub.ChampionsMgr.GetNbItems()); } [TestMethod] public void Get_OkResult_WhenChampExists() { // Act Task result = controller.Get(new PageRequest()); // Assert Assert.IsInstanceOfType(result, typeof(OkResult)); } [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; Assert.IsNotNull(resultType); Assert.AreEqual(resultType.Last(), stub.ChampionsMgr.GetItems(-1, await stub.ChampionsMgr.GetNbItems()));*/ } [TestMethod] public void TestPut() { } [TestMethod] public void TestDelete() { } } }