Mise à jour de 'EntityFramework_LoL/Sources/Test_Api/ChampionControllerTest.cs'
continuous-integration/drone/push Build is failing Details

Dave_more
David D'ALMEIDA 2 years ago
parent 2654d4dc27
commit eebdbe43b3

@ -1,198 +1,199 @@
using API_LoL_Project.Controllers;
using API_LoL_Project.Controllers.Request;
using API_LoL_Project.Controllers.Response;
using API_LoL_Project.Controllers.version2;
using DTO;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Model;
using StubLib;
using System.Net;
namespace Test_Api
{
[TestClass]
public class ChampionControllerTest
{
public readonly ChampionsController championCtrl;
private readonly ILogger<ChampionsController> logger = new NullLogger<ChampionsController>();
public readonly IDataManager stubMgr;
public ChampionControllerTest()
{
stubMgr = new StubData();
championCtrl = new ChampionsController(stubMgr, logger);
}
/* [TestMethod]
public async Task TestGetChampions()
{
var request = new PageRequest
{
index = 0,
count = 10,
orderingPropertyName = "Name",
descending = false
};
var totalcountTest = await stubMgr.ChampionsMgr.GetNbItems();
// Act
var getResult = await championCtrl.Get(request);
// Assert
Assert.IsInstanceOfType(getResult, typeof(OkObjectResult));
var objectRes = getResult.Result as OkObjectResult;
Assert.AreEqual(200, objectRes.StatusCode);
Assert.IsNotNull(objectRes);
var champions = objectRes?.Value as IEnumerable<ChampionDTO>;
Assert.IsNotNull(champions);
Assert.IsInstanceOfType(objectRes.Value, typeof(PageResponse<ChampionDTO>));
var pageResponse = objectRes.Value as PageResponse<ChampionDTO>;
Assert.AreEqual(totalcountTest, pageResponse.TotalCount);
Assert.AreEqual(totalcountTest, pageResponse.Data.Count());
*//* Assert.AreEqual(1, pageResponse.Data[.Data.Id);
*//* Assert.AreEqual("Champion1", pageResponse.Items[0].Data.Name);
*//* Assert.AreEqual(2, pageResponse.Items[1].Data.Id);
*//* Assert.AreEqual("Champion2", pageResponse.Items[1].Data.Name);
*/
/*
Assert.AreEqual(champions.Count(), await stubMgr.ChampionsMgr.GetNbItems());*//*
}
[TestMethod]
public async Task TestGetChampions_When_Count_Index_Too_High()
{
var totalcountTest = await stubMgr.ChampionsMgr.GetNbItems();
var request = new PageRequest
{
index = 999,
count = 9,
orderingPropertyName = "Name",
descending = false
};
// Act
var getResult = await championCtrl.Get(request);
// Assert
var badRequestResult = getResult.Result as BadRequestObjectResult;
Assert.IsNotNull(badRequestResult);
Assert.AreEqual("To many object is asked the max is : {totalcountTest}", badRequestResult.Value);
}
[TestMethod]
public async Task TestGetBadRequest_WhenNoChampionsFound()
{
var totalcountTest = await stubMgr.ChampionsMgr.GetNbItems();
// need to be empty
var request = new PageRequest
{
index = 0,
count = 10,
orderingPropertyName = "Name",
descending = false
};
// Act
var getResult = await championCtrl.Get(request);
Console.WriteLine(getResult);
// Assert
var badRequestResult = getResult.Result as BadRequestObjectResult;
Assert.IsNotNull(badRequestResult);
Assert.AreEqual("No chamions found : totalcount is : 0", badRequestResult.Value);
}
*/
/*
[TestMethod]
public async Task TestPostChampions()
{
var getResult = await championCtrl.Get();
Console.WriteLine(getResult);
var objectRes = getResult as OkObjectResult;
Assert.AreEqual(200, objectRes.StatusCode);
Assert.IsNotNull(objectRes);
var champions = objectRes?.Value as IEnumerable<ChampionDTO>;
Assert.IsNotNull(champions);
}
[TestMethod]
public async Task TestUpdateChampions()
{
var getResult = await championCtrl.Get();
Console.WriteLine(getResult);
var objectRes = getResult as OkObjectResult;
Assert.AreEqual(200, objectRes.StatusCode);
Assert.IsNotNull(objectRes);
var champions = objectRes?.Value as IEnumerable<ChampionDTO>;
Assert.IsNotNull(champions);
}
[TestMethod]
public async Task TestDeleteChampions()
{
var getResult = await championCtrl.Get();
Console.WriteLine(getResult);
var objectRes = getResult as OkObjectResult;
Assert.AreEqual(200, objectRes.StatusCode);
Assert.IsNotNull(objectRes);
var champions = objectRes?.Value as IEnumerable<ChampionDTO>;
Assert.IsNotNull(champions);
}
*/
}
using API_LoL_Project.Controllers;
using API_LoL_Project.Controllers.Request;
using API_LoL_Project.Controllers.Response;
using API_LoL_Project.Controllers.version2;
using DTO;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Model;
using StubLib;
using System.Net;
namespace Test_Api
{
[TestClass]
public class ChampionControllerTest
{
public readonly ChampionsController championCtrl;
private readonly ILogger<ChampionsController> logger = new NullLogger<ChampionsController>();
public readonly IDataManager stubMgr;
public ChampionControllerTest()
{
stubMgr = new StubData();
championCtrl = new ChampionsController(stubMgr, logger);
}
/* [TestMethod]
public async Task TestGetChampions()
{
var request = new PageRequest
{
index = 0,
count = 10,
orderingPropertyName = "Name",
descending = false
};
var totalcountTest = await stubMgr.ChampionsMgr.GetNbItems();
// Act
var getResult = await championCtrl.Get(request);
// Assert
Assert.IsInstanceOfType(getResult, typeof(OkObjectResult));
var objectRes = getResult.Result as OkObjectResult;
Assert.AreEqual(200, objectRes.StatusCode);
Assert.IsNotNull(objectRes);
var champions = objectRes?.Value as IEnumerable<ChampionDTO>;
Assert.IsNotNull(champions);
Assert.IsInstanceOfType(objectRes.Value, typeof(PageResponse<ChampionDTO>));
var pageResponse = objectRes.Value as PageResponse<ChampionDTO>;
Assert.AreEqual(totalcountTest, pageResponse.TotalCount);
Assert.AreEqual(totalcountTest, pageResponse.Data.Count());
*//* Assert.AreEqual(1, pageResponse.Data[.Data.Id);
*//* Assert.AreEqual("Champion1", pageResponse.Items[0].Data.Name);
*//* Assert.AreEqual(2, pageResponse.Items[1].Data.Id);
*//* Assert.AreEqual("Champion2", pageResponse.Items[1].Data.Name);
*/
/*
Assert.AreEqual(champions.Count(), await stubMgr.ChampionsMgr.GetNbItems());*//*
}
[TestMethod]
public async Task TestGetChampions_When_Count_Index_Too_High()
{
var totalcountTest = await stubMgr.ChampionsMgr.GetNbItems();
var request = new PageRequest
{
index = 999,
count = 9,
orderingPropertyName = "Name",
descending = false
};
// Act
var getResult = await championCtrl.Get(request);
// Assert
var badRequestResult = getResult.Result as BadRequestObjectResult;
Assert.IsNotNull(badRequestResult);
Assert.AreEqual("To many object is asked the max is : {totalcountTest}", badRequestResult.Value);
}
[TestMethod]
public async Task TestGetBadRequest_WhenNoChampionsFound()
{
var totalcountTest = await stubMgr.ChampionsMgr.GetNbItems();
// need to be empty
var request = new PageRequest
{
index = 0,
count = 10,
orderingPropertyName = "Name",
descending = false
};
// Act
var getResult = await championCtrl.Get(request);
Console.WriteLine(getResult);
// Assert
var badRequestResult = getResult.Result as BadRequestObjectResult;
Assert.IsNotNull(badRequestResult);
Assert.AreEqual("No chamions found : totalcount is : 0", badRequestResult.Value);
}
*/
/*
[TestMethod]
public async Task TestPostChampions()
{
var getResult = await championCtrl.Get();
Console.WriteLine(getResult);
var objectRes = getResult as OkObjectResult;
Assert.AreEqual(200, objectRes.StatusCode);
Assert.IsNotNull(objectRes);
var champions = objectRes?.Value as IEnumerable<ChampionDTO>;
Assert.IsNotNull(champions);
}
[TestMethod]
public async Task TestUpdateChampions()
{
var getResult = await championCtrl.Get();
Console.WriteLine(getResult);
var objectRes = getResult as OkObjectResult;
Assert.AreEqual(200, objectRes.StatusCode);
Assert.IsNotNull(objectRes);
var champions = objectRes?.Value as IEnumerable<ChampionDTO>;
Assert.IsNotNull(champions);
}
[TestMethod]
public async Task TestDeleteChampions()
{
var getResult = await championCtrl.Get();
Console.WriteLine(getResult);
var objectRes = getResult as OkObjectResult;
Assert.AreEqual(200, objectRes.StatusCode);
Assert.IsNotNull(objectRes);
var champions = objectRes?.Value as IEnumerable<ChampionDTO>;
Assert.IsNotNull(champions);
}
*/
}
}
Loading…
Cancel
Save