Update Project

pull/10/head
Louwar 2 years ago
parent 37a380fed9
commit 6fd96637f5

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

@ -29,6 +29,14 @@ namespace API.Controllers
this.dataManager = datamanager; this.dataManager = datamanager;
} }
/* public championHttpManager(HttpClient client)
{
_client = client;
client.BaseAddress = new Uri("à chopper dans lauchSettings.json propriété du projet");
}
*/
/**** Méthodes GET ****/
[HttpGet] [HttpGet]
public async Task<ActionResult<ChampionDto>> Get() public async Task<ActionResult<ChampionDto>> Get()
{ {
@ -58,10 +66,6 @@ namespace API.Controllers
.ToArray()); .ToArray());
} }
static async Task GetJsonData() static async Task GetJsonData()
{ {
using var client = new HttpClient(); using var client = new HttpClient();
@ -92,35 +96,32 @@ namespace API.Controllers
} }
} }
/* public async Task<IEnumerable<ChampionDto>> getJson()
{
var champions = await _client.GetFromJsonAsync<IEnumerable<ChampionDto>>();
var reponse = await _cleint.GetAscyn("api/champion");
return champions;
}*/
/**** Méthodes POST ****/
/*[HttpPost] /* [HttpPost]
public async Task<IActionResult> post([FromBody] ChampionDto champion) public async Task<IActionResult> post([FromBody] ChampionDto champion)
{ {
return CreatedAtAction(nameof(GetById), new { id = 1 }, return CreatedAtAction(nameof(GetById), new { id = 1 },
await dataManager.ChampionsMgr.AddItem(champion.ToModel)); await dataManager.ChampionsMgr.AddItem(champion.ToModel));
} }
public championHttpManager(HttpClient client) public async void addchampion(ChampionDto champion)
{ {
_client = client; _clientLpostAsJsonAscync<Champion>(ApiChampion, champion);
client.BaseAddress = new Uri("à chopper dans lauchSettings.json propriété du projet"); }*/
}
/**** Méthodes DELETE ****/
public async Task<IEnumerable<ChampionDto>> getChampion() /**** Méthodes PUT ****/
{
var champions = await _client.GetFromJsonAsync<IEnumerable<ChampionDto>>();
var reponse = await _cleint.GetAscyn("api/champion") ;
return champions;
}
public async void addchampion(ChampionDto champion)
{
_clientLpostAsJsonAscync<Champion>(ApiChampion, champion);
}
*/
} }
} }

@ -1,6 +1,7 @@
using API.Controllers; using API.Controllers;
using API.Dto; using API.Dto;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using StubLib;
using System.Collections.Generic; using System.Collections.Generic;
namespace TestProject1 namespace TestProject1
@ -13,7 +14,7 @@ namespace TestProject1
} }
[Test] /*[Test]
public void TestGET() public void TestGET()
{ {
//Arrange //Arrange
@ -26,10 +27,10 @@ namespace TestProject1
//vérifie que cest un ok 200 et un objet //vérifie que cest un ok 200 et un objet
Assert.IsNotNull(objectResult); Assert.IsNotNull(objectResult);
var champions = objectResult?.value as IEnumerable<ChampionDto>; var champions = objectResult?.Value as IEnumerable<ChampionDto>;
Assert.IsNotNull(champions); Assert.IsNotNull(champions);
Assert.AreEqual(champions.count(), (await stubData.championsMgr.getItems(0, 5)).Count()); Assert.AreEqual(champions.Count(), (await StubData.championsMgr.getItems(0, 5)).Count());
} }
[Test] [Test]
@ -48,10 +49,10 @@ namespace TestProject1
var objectResult = championResult as CreatedAtActionResult; var objectResult = championResult as CreatedAtActionResult;
Assert.IsNotNull(objectResult); Assert.IsNotNull(objectResult);
var champions = objectResult?.value as ChampionDto; var champions = objectResult?.Value as ChampionDto;
Assert.IsNotNull(champions); Assert.IsNotNull(champions);
} }*/
} }

Loading…
Cancel
Save