Ajout pagination et filtre
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
8f823252ac
commit
01de760381
@ -0,0 +1,85 @@
|
||||
using API_LoL.Controllers;
|
||||
using DTO;
|
||||
using FluentAssertions;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore.Query;
|
||||
using Model;
|
||||
using StubLib;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Api_UT
|
||||
{
|
||||
[TestClass]
|
||||
public class ChampionControllerTest
|
||||
{
|
||||
|
||||
ChampionsController api = new ChampionsController(new StubData());
|
||||
|
||||
[TestMethod]
|
||||
public async Task Get_Default_OkList()
|
||||
{
|
||||
|
||||
List<ChampionDTO> list = new List<ChampionDTO> {new ChampionDTO("Akali","",""), new ChampionDTO("Aatrox", "", ""), new ChampionDTO("Ahri", "", ""), new ChampionDTO("Akshan", "", ""), new ChampionDTO("Bard", "", ""), new ChampionDTO("Alistar", "", "") };
|
||||
IActionResult a = await api.Get();
|
||||
a.Should().NotBeNull();
|
||||
var aObject = a as OkObjectResult;
|
||||
aObject.Should().NotBeNull();
|
||||
var championresult = aObject.Value as IEnumerable<ChampionDTO>;
|
||||
list.Should().BeEquivalentTo(championresult);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task Get_MoreThanLimit_BadRequest()
|
||||
{
|
||||
IActionResult a = await api.Get(index :0,size :11);
|
||||
|
||||
a.Should().NotBeNull();
|
||||
a.Should().BeOfType<BadRequestResult>();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task Get_2First_OkListOf2()
|
||||
{
|
||||
List<ChampionDTO> list = new List<ChampionDTO> { new ChampionDTO("Akali", "", ""), new ChampionDTO("Aatrox", "", "") };
|
||||
|
||||
IActionResult a = await api.Get(index: 0,size: 2);
|
||||
|
||||
a.Should().NotBeNull();
|
||||
a.Should().BeOfType<OkObjectResult>();
|
||||
var aObject = a as OkObjectResult;
|
||||
aObject.Should().NotBeNull();
|
||||
var championresult = aObject.Value as IEnumerable<ChampionDTO>;
|
||||
list.Should().BeEquivalentTo(championresult);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task Get_FilterAName_OkListOf5()
|
||||
{
|
||||
List<ChampionDTO> list = new List<ChampionDTO> { new ChampionDTO("Akali", "", ""), new ChampionDTO("Akshan", "", "") };
|
||||
|
||||
IActionResult a = await api.Get(name: "Ak");
|
||||
|
||||
a.Should().NotBeNull();
|
||||
a.Should().BeOfType<OkObjectResult>();
|
||||
var aObject = a as OkObjectResult;
|
||||
aObject.Should().NotBeNull();
|
||||
var championresult = aObject.Value as IEnumerable<ChampionDTO>;
|
||||
list.Should().BeEquivalentTo(championresult);
|
||||
}
|
||||
|
||||
|
||||
|
||||
[TestMethod]
|
||||
public async Task Post_ValidChampion_Created()
|
||||
{
|
||||
ChampionsController api = new ChampionsController(new StubData());
|
||||
IActionResult a = await api.Post(new ChampionDTO("nom","bio","icon"));
|
||||
Assert.IsNotNull(a);
|
||||
ChampionDTO champ = new ChampionDTO("nom", "bio", "icon");
|
||||
Assert.IsTrue(champ.equals((ChampionDTO)((CreatedAtActionResult)a).Value));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,45 +0,0 @@
|
||||
using API_LoL.Controllers;
|
||||
using DTO;
|
||||
using FluentAssertions;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore.Query;
|
||||
using Model;
|
||||
using StubLib;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Api_UT
|
||||
{
|
||||
[TestClass]
|
||||
public class UnitTest1
|
||||
{
|
||||
[TestMethod]
|
||||
public async Task TestGet()
|
||||
{
|
||||
List<ChampionDTO> list = new List<ChampionDTO> {new ChampionDTO("Akali","",""), new ChampionDTO("Aatrox", "", ""), new ChampionDTO("Ahri", "", ""), new ChampionDTO("Akshan", "", ""), new ChampionDTO("Bard", "", ""), new ChampionDTO("Alistar", "", "") };
|
||||
ChampionsController api = new ChampionsController(new StubData());
|
||||
IActionResult a = await api.Get();
|
||||
|
||||
/// utilisation du nuggets fluentAssertion
|
||||
//Assert.IsNotNull(a);
|
||||
a.Should().NotBeNull();
|
||||
//Assert.AreEqual(list,((OkObjectResult)a).Value);
|
||||
var aObject = a as OkObjectResult;
|
||||
aObject.Should().NotBeNull();
|
||||
var championresult = aObject.Value as IEnumerable<ChampionDTO>;
|
||||
list.Should().BeEquivalentTo(championresult);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task TestPostValid()
|
||||
{
|
||||
ChampionsController api = new ChampionsController(new StubData());
|
||||
IActionResult a = await api.Post(new ChampionDTO("nom","bio","icon"));
|
||||
Assert.IsNotNull(a);
|
||||
ChampionDTO champ = new ChampionDTO("nom", "bio", "icon");
|
||||
Assert.IsTrue(champ.equals((ChampionDTO)((CreatedAtActionResult)a).Value));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in new issue