Add README.md, images(Title) for doc, also started the UT and client side

Documentation_UT_Client
Emre KARTAL 2 years ago
parent b7670ae160
commit 371c778f0f

Binary file not shown.

@ -1,4 +1,40 @@
# LolProject # LOL-Project <img src="https://logo-marque.com/wp-content/uploads/2020/11/League-of-Legends-Embleme.png" width="40" >
Realization of an API and an ORM which will be linked to a database in the theme of League of legends
**Thème du projet** : Réalisation d'une API et d'un ORM(Entity Framework) qui seront reliés à une base de données dans le thème de League of legends <img src="https://logo-marque.com/wp-content/uploads/2020/11/League-of-Legends-Embleme.png" width="40" >
</br>
# Répartition du Gitlab
La racine de notre gitlab est composée de deux dossiers essentiels au projet:
[**src**](src) : **Toute la partie codage de l'application**
[**doc**](doc) : **Documentation de l'application**
👉 [**Solution de l'application**](src/EntityFramework_LoL/Sources/LeagueOfLegends.sln)
# Environnement de Travail
Mon environnement de travail se base sur plusieurs outils :👇
<div align = center>
---
&nbsp; ![Docnet](https://img.shields.io/badge/Docnet-000?style=for-the-badge&logo=Docnet&logoColor=white&color=white)
&nbsp; ![C#](https://img.shields.io/badge/Csharp-000?style=for-the-badge&logo=csharp&logoColor=white&color=blue)
---
</div>
# Technicien en charge de l'application
⚙️ Emre KARTAL
<br>
<div align = center>
© Groupe 4
</div>

Binary file not shown.

After

Width:  |  Height:  |  Size: 960 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

@ -2,7 +2,6 @@
using DTO; using DTO;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Model; using Model;
using StubLib;
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 // For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
@ -12,41 +11,50 @@ namespace ApiLol.Controllers
[ApiController] [ApiController]
public class ChampionsController : ControllerBase public class ChampionsController : ControllerBase
{ {
IChampionsManager dataManager = new StubData().ChampionsMgr; private readonly IDataManager _manager;
public ChampionsController(IDataManager dataManager)
{
this._manager = dataManager;
}
// GET: api/<ValuesController> // GET: api/<ValuesController>
[HttpGet] [HttpGet]
public async Task<IActionResult> Get() public async Task<IActionResult> Get()
{ {
var champions = await dataManager.GetItems(0, await dataManager.GetNbItems()); // Le await va permettre que les lignes suivantes ne s'éxécute pas IEnumerable<ChampionDto> dtos = (await _manager.ChampionsMgr.GetItems(0, await _manager.ChampionsMgr.GetNbItems()))
return Ok(new { result = champions.Select(c => c.ToDto())}); .Select(x => x.ToDto());
return Ok(dtos);
} }
// GET api/<ValuesController>/5 // GET api/<ValuesController>/5
[HttpGet("{name}")] [HttpGet("{name}")]
public IActionResult Get(string name) public async Task<IActionResult> Get(string name)
{ {
dataManager.GetItemsByName(name, 0, 1); var dtos = (await _manager.ChampionsMgr.GetItemsByName(name,0, await _manager.ChampionsMgr.GetNbItems()))
return NotFound(); .Select(x => x.ToDto());
return Ok(dtos);
} }
// POST api/<ValuesController> // POST api/<ValuesController>
[HttpPost] [HttpPost]
public async Task<IActionResult> Post([FromBody] ChampionDto value) public async Task<IActionResult> Post([FromBody] ChampionDto champion)
{ {
//await dataManager.AddItem(value.toModel()); return CreatedAtAction(nameof(Get),
return Ok(); await _manager.ChampionsMgr.AddItem(champion.ToModel()));
} }
// PUT api/<ValuesController>/5 // PUT api/<ValuesController>/5
[HttpPut("{id}")] [HttpPut("{id}")]
public void Put(int id, [FromBody] string value) public void Put(int id, [FromBody] string value)
{ {
} }
// DELETE api/<ValuesController>/5 // DELETE api/<ValuesController>/5
[HttpDelete("{id}")] [HttpDelete("{id}")]
public void Delete(int id) public void Delete(int id)
{ {
} }
} }
} }

@ -12,5 +12,11 @@ namespace ApiLol.Mapper
Name = champion.Name, Name = champion.Name,
}; };
} }
public static Champion ToModel(this ChampionDto championDto)
{
}
} }
} }

@ -1,3 +1,6 @@
using Model;
using StubLib;
var builder = WebApplication.CreateBuilder(args); var builder = WebApplication.CreateBuilder(args);
// Add services to the container. // Add services to the container.
@ -6,6 +9,7 @@ builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer(); builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen(); builder.Services.AddSwaggerGen();
builder.Services.AddScoped<IDataManager, StubData>();
var app = builder.Build(); var app = builder.Build();

@ -0,0 +1,42 @@
using DTO;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http.Json;
using System.Text;
using System.Threading.Tasks;
namespace Client
{
public class ChampionHttpClient
{
private const string ApiChampions = "api/champions";
private readonly HttpClient _httpClient;
public ChampionHttpClient(HttpClient httpClient)
{
_httpClient = httpClient;
httpClient.BaseAddress = new Uri("https://localhost:7252;http://localhost:5252");
}
public async Task<IEnumerable<ChampionDto>> GetChampion()
{
var champions = await _httpClient.GetFromJsonAsync<IEnumerable<ChampionDto>>(ApiChampions);
return champions;
}
public async void Add(ChampionDto champion)
{
await _httpClient.PostAsJsonAsync<ChampionDto>(ApiChampions, champion);
}
public async void Delete(ChampionDto champion)
{
await _httpClient.DeleteAsync(champion);
}
public async void Update(ChampionDto champion)
{
await _httpClient.PutAsJsonAsync<ChampionDto>(ApiChampions, champion);
}
}
}

@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\ApiLol\ApiLol.csproj" />
<ProjectReference Include="..\DTO\DTO.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,2 @@
// See https://aka.ms/new-console-template for more information
Console.WriteLine("Hello, World!");

@ -17,7 +17,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StubLib", "StubLib\StubLib.
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ApiLol", "ApiLol\ApiLol.csproj", "{D59C9C7B-9BC2-4601-959D-BFA97E46D017}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ApiLol", "ApiLol\ApiLol.csproj", "{D59C9C7B-9BC2-4601-959D-BFA97E46D017}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DTO", "DTO\DTO.csproj", "{3919E408-EB12-4422-989B-C6ED4816D465}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DTO", "DTO\DTO.csproj", "{3919E408-EB12-4422-989B-C6ED4816D465}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ApiTests", "Tests\ApiTests\ApiTests.csproj", "{1779D8A4-2E12-47F3-BDA2-2E7F04B758EB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Client", "Client\Client.csproj", "{464DAB04-BE65-429D-9A39-3E1BB43C521A}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -49,6 +53,14 @@ Global
{3919E408-EB12-4422-989B-C6ED4816D465}.Debug|Any CPU.Build.0 = Debug|Any CPU {3919E408-EB12-4422-989B-C6ED4816D465}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3919E408-EB12-4422-989B-C6ED4816D465}.Release|Any CPU.ActiveCfg = Release|Any CPU {3919E408-EB12-4422-989B-C6ED4816D465}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3919E408-EB12-4422-989B-C6ED4816D465}.Release|Any CPU.Build.0 = Release|Any CPU {3919E408-EB12-4422-989B-C6ED4816D465}.Release|Any CPU.Build.0 = Release|Any CPU
{1779D8A4-2E12-47F3-BDA2-2E7F04B758EB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1779D8A4-2E12-47F3-BDA2-2E7F04B758EB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1779D8A4-2E12-47F3-BDA2-2E7F04B758EB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1779D8A4-2E12-47F3-BDA2-2E7F04B758EB}.Release|Any CPU.Build.0 = Release|Any CPU
{464DAB04-BE65-429D-9A39-3E1BB43C521A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{464DAB04-BE65-429D-9A39-3E1BB43C521A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{464DAB04-BE65-429D-9A39-3E1BB43C521A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{464DAB04-BE65-429D-9A39-3E1BB43C521A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
@ -56,6 +68,7 @@ Global
GlobalSection(NestedProjects) = preSolution GlobalSection(NestedProjects) = preSolution
{1889FA6E-B7C6-416E-8628-9449FB9070B9} = {C76D0C23-1FFA-4963-93CD-E12BD643F030} {1889FA6E-B7C6-416E-8628-9449FB9070B9} = {C76D0C23-1FFA-4963-93CD-E12BD643F030}
{B01D7EF2-2D64-409A-A29A-61FB7BB7A9DB} = {2C607793-B163-4731-A4D1-AFE8A7C4C170} {B01D7EF2-2D64-409A-A29A-61FB7BB7A9DB} = {2C607793-B163-4731-A4D1-AFE8A7C4C170}
{1779D8A4-2E12-47F3-BDA2-2E7F04B758EB} = {C76D0C23-1FFA-4963-93CD-E12BD643F030}
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {92F3083D-793F-4552-8A9A-0AD6534159C9} SolutionGuid = {92F3083D-793F-4552-8A9A-0AD6534159C9}

@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.8" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.8" />
<PackageReference Include="coverlet.collector" Version="3.1.2" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\ApiLol\ApiLol.csproj" />
<ProjectReference Include="..\..\StubLib\StubLib.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,61 @@
using ApiLol.Controllers;
using DTO;
using Microsoft.AspNetCore.Mvc;
using Model;
using StubLib;
namespace ApiTests
{
[TestClass]
public class ChampionsControllerTest
{
private readonly StubData stub;
private readonly ChampionsControllerTest champs;
public ChampionsControllerTest()
{
stub = new StubData();
champs = new ChampionsController(stub);
}
[TestMethod]
public async void TestGetChampions()
{
//Arrange
//Act
var champion = champs.Get();
//Assert
var objectResult = champion as OkObjectResult;
Assert.IsNotNull(objectResult);
var champions = objectResult?.Value as IEnumerable<Champion>;
Assert.IsNotNull(champions);
Assert.AreEqual(champions.Count(), await stub.ChampionsMgr.GetItems(0,5).Count());
}
[TestMethod]
public async Task TestPostChampion()
{
//Arange
var ChampionDto = new ChampionDto
{
Name = "Sylas"
};
//Act
var championsResult = await champs.Post(ChampionDto);
//Assert
var objectResult = championsResult as OkObjectResult;
Assert.IsNotNull(objectResult);
var champions = objectResult?.Value as IEnumerable<Champion>;
Assert.IsNotNull(champions);
}
}
}

@ -0,0 +1 @@
global using Microsoft.VisualStudio.TestTools.UnitTesting;
Loading…
Cancel
Save