merge resoled
continuous-integration/drone/push Build is failing Details

David_next_step
David D'ALMEIDA 2 years ago
commit 4a12988b66

@ -0,0 +1,59 @@
kind: pipeline
type: docker
name: default
trigger:
event:
- push
steps:
- name: build
image: mcr.microsoft.com/dotnet/sdk:6.0
volumes:
- name: docs
path: /docs
commands:
- cd EntityFramework_LoL/Sources/
- dotnet restore LeagueOfLegends.sln
- dotnet build LeagueOfLegends.sln -c Release --no-restore
- dotnet publish LeagueOfLegends.sln -c Release --no-restore -o CI_PROJECT_DIR/build/release
# docker image build
- name: docker-build-and-push
image: plugins/docker
settings:
dockerfile: EntityFramework_LoL/Sources/Dockerfile
context: EntityFramework_LoL/Sources/
registry: hub.codefirst.iut.uca.fr
repo: hub.codefirst.iut.uca.fr/git/arthur.valin/League-of-Legends_Project
username:
from_secret: SECRET_REGISTRY_USERNAME
password:
from_secret: SECRET_REGISTRY_PASSWORD
- name: tests
image: mcr.microsoft.com/dotnet/sdk:6.0
commands:
- cd EntityFramework_LoL/Sources/
- dotnet restore LeagueOfLegends.sln
- dotnet test LeagueOfLegends.sln --no-restore
depends_on: [build]
- name: generate-and-deploy-docs
image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-docdeployer
failure: ignore
volumes:
- name: docs
path: /docs
commands:
#- cd Documentation/doxygen
#- doxygen Doxyfile
- /entrypoint.sh
when:
branch:
- master
depends_on: [ build ]
volumes:
- name: docs
temp: {}

Binary file not shown.

@ -1,6 +1,7 @@
{
"ExpandedNodes": [
""
],
"PreviewInSolutionExplorer": false
{
"ExpandedNodes": [
""
],
"SelectedNode": "\\LeagueOfLegends.sln",
"PreviewInSolutionExplorer": false
}

@ -0,0 +1,25 @@
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/azds.yaml
**/bin
**/charts
**/docker-compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md

@ -4,9 +4,12 @@
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>c1310bab-6367-419f-9338-2a73d29996c3</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.15.1" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
</ItemGroup>
@ -17,4 +20,8 @@
<ProjectReference Include="..\StubLib\StubLib.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="service\" />
</ItemGroup>
</Project>

@ -1,8 +1,10 @@
using API_LoL_Project.Mapper;
using API_LoL_Project.Middleware;
using DTO;
using Microsoft.AspNetCore.Mvc;
using Model;
using StubLib;
using System.Text.Json;
using System.Xml.Linq;
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
@ -13,34 +15,96 @@ namespace API_LoL_Project.Controllers
[ApiController]
public class ChampionsController : ControllerBase
{
IChampionsManager dataManager = new StubData().ChampionsMgr;
public IChampionsManager dataManager;
private readonly ILogger<ChampionsController> _logger;
/* public ChampionsController(IChampionsManager dataManager)
{
this.dataManager = dataManager;
}*/
public ChampionsController(IDataManager dataManager, ILogger<ChampionsController> logger)
{
this.dataManager = dataManager.ChampionsMgr;
this._logger = logger;
}
// GET: api/<ChampionController>
[HttpGet]
public async Task<IActionResult> Get()
public async Task<ActionResult<IEnumerable<ChampionDTO>>> Get([FromQuery] Request.PageRequest request)
{
var champions = await dataManager.GetItems(0, await dataManager.GetNbItems());
return Ok(new { result = champions.Select(c => c.ToDTO())});
try
{
var totalcount = await dataManager.GetNbItems();
if (request.count + request.index > totalcount)
{
_logger.LogWarning("No chamions found with Id");
return BadRequest("No chamions found with Id ");
}
_logger.LogInformation("Executing {Action} with parameters: {Parameters}", nameof(Get), request);;
var champions = await dataManager.GetItems(request.PageNumber, totalcount, request.orderingPropertyName, (request.descending == null ? false : (bool)request.descending));
IEnumerable<ChampionDTO> res = champions.Select(c => c.toDTO());
if (res.Count() >= 0 || res == null)
{
_logger.LogWarning("No chamions found with Id");
return BadRequest("No chamions found with Id ");
}
return Ok(res);
}
catch (Exception e)
{
return BadRequest(e.Message);
}
}
// GET api/<ChampionController>/5
[HttpGet("{name}")]
public async Task<IActionResult> Get(string name)
public async Task<ActionResult<ChampionDTO>> GetChampionsByName(string name)
{
var champion = await dataManager
try
{
var champion = await dataManager
.GetItemsByName(name, 0, await dataManager.GetNbItems());
return Ok(new { result = champion.First().ToDTO() });
_logger.LogInformation("Executing {Action} with name : {championName}", nameof(GetChampionsByName), name);
ChampionDTO res = champion.First().toDTO();
if (res == null)
{
_logger.LogWarning("No chamions found with {name}", name); ;
return NotFound();
}
return Ok(res);
}
catch (Exception e)
{
return BadRequest(e.Message);
}
}
// POST api/<ChampionController>
[HttpPost]
public async Task<IActionResult> Post([FromBody] ChampionDTO value)
{
await dataManager.AddItem(value.ToModel());
return Ok();
try
{
var newChampion = value.toModel();
await dataManager.AddItem(newChampion);
return CreatedAtAction(nameof(Get), newChampion) ;
}
catch (Exception e)
{
return BadRequest(e.Message);
}
}
@ -48,20 +112,79 @@ namespace API_LoL_Project.Controllers
[HttpPut("{name}")]
public async Task<IActionResult> Put(string name, [FromBody] ChampionDTO value)
{
var champion = await dataManager
try
{
var champion = await dataManager
.GetItemsByName(name, 0, await dataManager.GetNbItems());
await dataManager.UpdateItem(champion.First(), value.ToModel());
return Ok();
await dataManager.UpdateItem(champion.First(), value.toModel());
return Ok();
}
catch(Exception e)
{
return BadRequest(e.Message);
}
}
// DELETE api/<ChampionController>/5
[HttpDelete("{name}")]
public async Task<IActionResult> Delete(string name)
{
var champion = await dataManager
try
{
var champion = await dataManager
.GetItemsByName(name, 0, await dataManager.GetNbItems());
await dataManager.DeleteItem(champion.First());
return Ok();
if (champion != null) await dataManager.DeleteItem(champion.First());
else
{
return NotFound();
}
return Ok();
}
catch (Exception e)
{
return BadRequest(e.Message);
}
}
/* [HttpGet]
public async Task<IActionResult> NbChampions()
{
var champions = await dataManager.GetItems(0, await dataManager.GetNbItems());
IEnumerable<ChampionDTO> res = champions.Select(c => c.toDTO());
return Ok(res);
}*/
[HttpGet("/{name}/skins")]
public async Task<ActionResult<Skin>> GetChampionsSkins(string name)
{
var champions = await dataManager.GetItemsByName(name, 0, await dataManager.GetNbItems());
//skinsDTO
IEnumerable<Skin> res = champions.First().Skins;
return Ok(res);
}
[HttpGet("/{name}/skills")]
public async Task<ActionResult<Skin>> GetChampionsSkills(string name)
{
var champions = await dataManager.GetItemsByName(name, 0, await dataManager.GetNbItems());
//SkillDTO
IEnumerable<Skill> res = champions.First().Skills;
return Ok(res);
}
/*[HttpGet("/{name}/skins")]
public async Task<ActionResult<Skill> NbChampions()
{
var champions = await dataManager.GetItems(0, await dataManager.GetNbItems());
IEnumerable<ChampionDTO> res = champions.Select(c => c.toDTO());
return Ok(res);
}*/
}
}

@ -0,0 +1,29 @@
namespace API_LoL_Project.Controllers.Request
{
public class PageRequest
{
//max leght
public string? orderingPropertyName { get; set; } = null;
public bool? descending { get; set; } = false;
const int maxPageSize = 50;
public int PageNumber { get; set; } = 1;
public int index { get; set; } = 1;
public int count { get; set; } = 1;
//max lentght
private int _pageSize;
public int PageSize
{
get
{
return _pageSize;
}
set
{
_pageSize = (value > maxPageSize) ? maxPageSize : value;
}
}
}
}

@ -0,0 +1,6 @@
namespace API_LoL_Project.Controllers.Response
{
public class PageResponse
{
}
}

@ -0,0 +1,132 @@
using DTO;
using Microsoft.AspNetCore.Mvc;
using Model;
using API_LoL_Project.Mapper;
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
namespace API_LoL_Project.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class RuneController : ControllerBase
{
public IRunesManager runesManager;
// you should create a custom logger to be prety
private readonly ILogger<RuneController> _logger;
public RuneController(IDataManager dataManager, ILogger<RuneController> logger)
{
this.runesManager = dataManager.RunesMgr;
this._logger = logger;
}
/*// GET: api/<RuneController>
[HttpGet]
public async Task<IEnumerable<RuneDTO>> Get()
{
try
{
var runes = await runesManager.GetItems(0, await runesManager.GetNbItems());
IEnumerable<RuneDTO> res = runes.Select(c => c.toDTO());
return Ok(res);
}
catch (Exception e)
{
_logger.LogInformation("About get at {e.message}", DateTime.UtcNow.ToLongTimeString());
return BadRequest(e.Message);
}
}*/
// GET: api/<RuneController>
[HttpGet]
public async Task<ActionResult<IEnumerable<RuneDTO>>> Get([FromQuery] Request.PageRequest request)
{
try
{
var totalcount = await runesManager.GetNbItems();
if (request.count + request.index > totalcount)
{
_logger.LogWarning("to many rows ask the max is {totalcount}", totalcount);
return BadRequest("to many rows ask the max is " + totalcount) ;
}
_logger.LogInformation("Executing {Action} with parameters: {Parameters}", nameof(Get), request);
var runes = await runesManager.GetItems(request.PageNumber, totalcount, request.orderingPropertyName,(request.descending == null ? false : (bool)request.descending));
IEnumerable<RuneDTO> res = runes.Select(c => c.toDTO());
if (res.Count() >= 0 || res == null)
{
_logger.LogWarning("No runes found with Id");
return BadRequest("No runes found with Id ");
}
return Ok(res);
}
catch (Exception e)
{
_logger.LogError("About get at {e.message}", DateTime.UtcNow.ToLongTimeString());
return BadRequest(e.Message);
}
}
// GET api/<RuneController>/5
[HttpGet("{id}")]
public string Get(int id)
{
try
{
var rune = await dataManager
.GetItemsByName(name, 0, await dataManager.GetNbItems());
RuneDto result = champion.First().toDTO();
return Ok(result);
}
catch (Exeption e)
{
new HttpException(400, 'Cannot get rune :' + e.message);
}
}
// POST api/<RuneController>
[HttpPost]
public void Post([FromBody] string value)
{
try
{
await dataManager.AddItem(value.toModel());
return Ok();
}
catch ()
{
new HttpException(400, 'Cannot create rune')
}
}
// PUT api/<RuneController>/5
[HttpPut("{id}")]
public void Put(int id, [FromBody] string value)
{
}
// DELETE api/<RuneController>/5
[HttpDelete("{id}")]
public void Delete(int id)
{
}
}
}

@ -0,0 +1,70 @@
using Microsoft.AspNetCore.Mvc;
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
namespace API_LoL_Project.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class RunePageController : ControllerBase
{
// GET: api/<RunePageController>
[HttpGet]
public async Task<ActionResult<IEnumerable<RuneDTO>>> Get([FromQuery] Request.PageRequest request)
{
try
{
var totalcount = await runesManager.GetNbItems();
if (request.count + request.index > totalcount)
{
_logger.LogWarning("to many rows ask the max is {totalcount}", totalcount);
return BadRequest("to many rows ask the max is " + totalcount);
}
_logger.LogInformation("Executing {Action} with parameters: {Parameters}", nameof(Get), request);
var runes = await runesManager.GetItems(request.PageNumber, totalcount, request.orderingPropertyName, (request.descending == null ? false : (bool)request.descending));
IEnumerable<RuneDTO> res = runes.Select(c => c.toDTO());
if (res.Count() >= 0 || res == null)
{
_logger.LogWarning("No runes found with Id");
return BadRequest("No runes found with Id ");
}
return Ok(res);
}
catch (Exception e)
{
_logger.LogError("About get at {e.message}", DateTime.UtcNow.ToLongTimeString());
return BadRequest(e.Message);
}
}
// GET api/<RunePageController>/5
[HttpGet("{id}")]
public string Get(int id)
{
return "value";
}
// POST api/<RunePageController>
[HttpPost]
public void Post([FromBody] string value)
{
}
// PUT api/<RunePageController>/5
[HttpPut("{id}")]
public void Put(int id, [FromBody] string value)
{
}
// DELETE api/<RunePageController>/5
[HttpDelete("{id}")]
public void Delete(int id)
{
}
}
}

@ -0,0 +1,70 @@
using Microsoft.AspNetCore.Mvc;
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
namespace API_LoL_Project.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class SkillController : ControllerBase
{
// GET: api/<SkillController>
[HttpGet]
public async Task<ActionResult<IEnumerable<RuneDTO>>> Get([FromQuery] Request.PageRequest request)
{
try
{
var totalcount = await runesManager.GetNbItems();
if (request.count + request.index > totalcount)
{
_logger.LogWarning("to many rows ask the max is {totalcount}", totalcount);
return BadRequest("to many rows ask the max is " + totalcount);
}
_logger.LogInformation("Executing {Action} with parameters: {Parameters}", nameof(Get), request);
var runes = await runesManager.GetItems(request.PageNumber, totalcount, request.orderingPropertyName, (request.descending == null ? false : (bool)request.descending));
IEnumerable<RuneDTO> res = runes.Select(c => c.toDTO());
if (res.Count() >= 0 || res == null)
{
_logger.LogWarning("No runes found with Id");
return BadRequest("No runes found with Id ");
}
return Ok(res);
}
catch (Exception e)
{
_logger.LogError("About get at {e.message}", DateTime.UtcNow.ToLongTimeString());
return BadRequest(e.Message);
}
}
// GET api/<SkillController>/5
[HttpGet("{id}")]
public string Get(int id)
{
return "value";
}
// POST api/<SkillController>
[HttpPost]
public void Post([FromBody] string value)
{
}
// PUT api/<SkillController>/5
[HttpPut("{id}")]
public void Put(int id, [FromBody] string value)
{
}
// DELETE api/<SkillController>/5
[HttpDelete("{id}")]
public void Delete(int id)
{
}
}
}

@ -0,0 +1,70 @@
using Microsoft.AspNetCore.Mvc;
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
namespace API_LoL_Project.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class SkinController : ControllerBase
{
// GET: api/<SkinController>
[HttpGet]
public async Task<ActionResult<IEnumerable<RuneDTO>>> Get([FromQuery] Request.PageRequest request)
{
try
{
var totalcount = await runesManager.GetNbItems();
if (request.count + request.index > totalcount)
{
_logger.LogWarning("to many rows ask the max is {totalcount}", totalcount);
return BadRequest("to many rows ask the max is " + totalcount);
}
_logger.LogInformation("Executing {Action} with parameters: {Parameters}", nameof(Get), request);
var runes = await runesManager.GetItems(request.PageNumber, totalcount, request.orderingPropertyName, (request.descending == null ? false : (bool)request.descending));
IEnumerable<RuneDTO> res = runes.Select(c => c.toDTO());
if (res.Count() >= 0 || res == null)
{
_logger.LogWarning("No runes found with Id");
return BadRequest("No runes found with Id ");
}
return Ok(res);
}
catch (Exception e)
{
_logger.LogError("About get at {e.message}", DateTime.UtcNow.ToLongTimeString());
return BadRequest(e.Message);
}
}
// GET api/<SkinController>/5
[HttpGet("{id}")]
public string Get(int id)
{
return "value";
}
// POST api/<SkinController>
[HttpPost]
public void Post([FromBody] string value)
{
}
// PUT api/<SkinController>/5
[HttpPut("{id}")]
public void Put(int id, [FromBody] string value)
{
}
// DELETE api/<SkinController>/5
[HttpDelete("{id}")]
public void Delete(int id)
{
}
}
}

@ -0,0 +1,26 @@
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["API_LoL_Project/API_LoL_Project.csproj", "API_LoL_Project/"]
COPY ["StubLib/StubLib.csproj", "StubLib/"]
COPY ["Model/Model.csproj", "Model/"]
COPY ["Shared/Shared.csproj", "Shared/"]
COPY ["DTO/DTO.csproj", "DTO/"]
RUN dotnet restore "API_LoL_Project/API_LoL_Project.csproj"
COPY . .
WORKDIR "/src/API_LoL_Project"
RUN dotnet build "API_LoL_Project.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "API_LoL_Project.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "API_LoL_Project.dll"]

@ -8,7 +8,13 @@ namespace API_LoL_Project.Mapper
public static ChampionDTO ToDTO(this Champion item)
{
return new() {
if (item == null)
{
var message = string.Format("Champion with name = {} nhhoddt found", item.Name);
/*throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.NotFound, message));
*/
}
return new ChampionDTO() {
Name = item.Name,
Bio = item.Bio
};
@ -25,9 +31,35 @@ namespace API_LoL_Project.Mapper
Image = new() { Base64 = item.Image.Base64 },
};
}
public static ChampionFullDTO toFullDTO(this Champion item)
{
if (item == null)
{
var message = string.Format("Champion with name = {} nhhoddt found", item.Name);
/*throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.NotFound, message));
*/
}
return new ChampionFullDTO()
{
Name = item.Name,
Bio = item.Bio,
Characteristics = item.Characteristics,
skills = item.Skills,
skins = item.Skins,
LargeImage = item.Image
};
}
public static Champion ToModel(this ChampionDTO dto)
{
if (dto == null)
{
var message = string.Format("Champion with name = {} nhhoddt found", dto.Name);
/*throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.NotFound, message));
*/}
return new(dto.Name);
}
@ -36,5 +68,7 @@ namespace API_LoL_Project.Mapper
return new(entity.Name, entity.Class, entity.Icon, entity.Image.Base64, entity.Bio);
}
}
}

@ -0,0 +1,29 @@
using DTO;
using Model;
namespace API_LoL_Project.Mapper
{
public static class RunesMappeur
{
public static RuneDTO toDTO(this Rune item)
{
return new RuneDTO()
{
Name = item.Name,
Family = item.Family,
};
}
public static Rune toModel(this RuneDTO dto)
{
/*if (dto == null)
{
*//* var message = string.Format("Champion with name = {} not found", dto.Name);
throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.NotFound, message));*//*
}*/
return new Rune(dto.Name, dto.Family);
}
}
}

@ -0,0 +1,6 @@
namespace API_LoL_Project.Middleware
{
public class ExceptionMiddleware
{
}
}

@ -0,0 +1,33 @@
using Microsoft.AspNetCore.Http.Headers;
using System.Net;
namespace API_LoL_Project.Middleware
{
public class HttpExeption : Exception
{
public HttpStatusCode StatusCode { get; set; }
public String Message { get; set; }
public HttpExeption(HttpStatusCode statusCode, string message ="") : base(message)
{
this.StatusCode = statusCode;
this.Message = message;
}
/*void AddHeaders(this HttpRequestMessage message, RequestHeaders headers)
{
var headerParameters = headers.Parameters.Where(x => !KnownHeaders.IsContentHeader(x.Name!));
headerParameters.ForEach(x => AddHeader(x, message.Headers));
}
void AddHeader(Parameter parameter, HttpHeaders httpHeaders)
{
var parameterStringValue = parameter.Value!.ToString();
httpHeaders.Remove(parameter.Name!);
httpHeaders.TryAddWithoutValidation(parameter.Name!, parameterStringValue);
}*/
}
}

@ -0,0 +1,8 @@
namespace API_LoL_Project.Middleware
{
public class Validator
{
}
}

@ -1,3 +1,6 @@
using Model;
using StubLib;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
@ -7,8 +10,10 @@ builder.Services.AddControllers();
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.AddSingleton<IDataManager, StubData>();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
@ -22,4 +27,5 @@ app.UseAuthorization();
app.MapControllers();
app.Run();

@ -1,31 +1,38 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:45539",
"sslPort": 44382
}
},
"profiles": {
"API_LoL_Project": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "https://localhost:7041;http://localhost:5233",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:45539",
"sslPort": 44382
}
},
"profiles": {
"API_LoL_Project": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:7041;http://localhost:5233",
"dotnetRunMessages": true
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Docker": {
"commandName": "Docker",
"launchBrowser": true,
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger",
"publishAllPorts": true,
"useSSL": true
}
}
}

@ -1,8 +1,23 @@
namespace DTO
using Model;
namespace DTO
{
public class ChampionDTO
{
public string Name { get; set; }
public string Bio { get; set; }
/*public string Icon { get; set; }
*/
}
public class ChampionFullDTO
{
public string Name { get; set; }
public string Bio { get; set; }
public string Characteristics { get; set; }
public byte[] LargeImage { get; set; }
public IEnumerable<Skin> skins { get; set; }
public IEnumerable<Skill> skills { get; set; }
}
}

@ -6,4 +6,8 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Model\Model.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,22 @@
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DTO
{
public class RuneDTO
{
public string Name { get; set; }
public string Description { get; set; }
public RuneFamily Family { get; set; }
public string Icon { get; set; }
public LargeImage Image { get; set; }
}
}

@ -23,6 +23,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Entity Framework", "Entity
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Entities", "Entities\Entities.csproj", "{C463E2E1-237A-4339-A4C4-6EA3BE7002AE}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Test_Api", "Test_Api\Test_Api.csproj", "{C35C38F6-5774-4562-BD00-C81BCE13A260}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Business", "Business\Business.csproj", "{A447B0BE-62AE-4F66-B887-D1F3D46B0DB3}"
EndProject
Global

@ -0,0 +1,62 @@
using API_LoL_Project.Controllers;
using DTO;
using Microsoft.AspNetCore.Mvc;
using Model;
using StubLib;
namespace TestProject1
{
[TestClass]
public class ChampionControllerTest
{
public readonly ChampionsController championCtrl;
public readonly IChampionsManager stubMgr;
public ChampionControllerTest()
{
stubMgr = new StubData().ChampionsMgr;
championCtrl = new ChampionsController(stubMgr);
}
[TestMethod]
public async Task TestGetChampions()
{
var getResult = await championCtrl.Get();
var objectRes = getResult as OkObjectResult;
Assert.IsNotNull(objectRes);
var champions = objectRes?.Value as IEnumerable<ChampionDTO>;
Assert.IsNotNull(champions);
Assert.AreEqual(champions.Count(), await stubMgr.GetNbItems());
}
[TestMethod]
public async void TestPostChampions()
{
var chamionGetResul = championCtrl.Get();
}
[TestMethod]
public async void TestUpdateChampions()
{
var chamionGetResul = championCtrl.Get();
}
[TestMethod]
public async void TestDeleteChampions()
{
var chamionGetResul = championCtrl.Get();
}
}
}

@ -0,0 +1,22 @@
<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="..\API_LoL_Project\API_LoL_Project.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,11 @@
namespace TestProject1
{
[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
}
}
}

@ -0,0 +1 @@
global using Microsoft.VisualStudio.TestTools.UnitTesting;

@ -0,0 +1,46 @@
using API_LoL_Project.Controllers;
using DTO;
using Microsoft.AspNetCore.Mvc;
using Model;
using StubLib;
using System.Net;
namespace Test_Api
{
[TestClass]
public class ChampionControllerTest
{
public readonly ChampionsController championCtrl;
public readonly IDataManager stubMgr;
public ChampionControllerTest()
{
var stubMgr = new StubData();
championCtrl = new ChampionsController(stubMgr);
}
[TestMethod]
public async Task TestGetChampions()
{
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);
/*
Assert.AreEqual(champions.Count(), await stubMgr.ChampionsMgr.GetNbItems());*/
}
}
}

@ -0,0 +1,25 @@
<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="..\API_LoL_Project\API_LoL_Project.csproj" />
<ProjectReference Include="..\DTO\DTO.csproj" />
<ProjectReference Include="..\Model\Model.csproj" />
<ProjectReference Include="..\StubLib\StubLib.csproj" />
</ItemGroup>
</Project>

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