From 8a58b97d0bd1c842d2305ef2660512b8cbcd98f0 Mon Sep 17 00:00:00 2001 From: Corentin R <76619184+Koroh63@users.noreply.github.com> Date: Fri, 24 Mar 2023 17:48:16 +0100 Subject: [PATCH 1/2] Post fix no more :bug: --- .../Controllers/ChampionsController.cs | 2 +- Sources/API_LoL/champion.db | Bin 45056 -> 45056 bytes Sources/API_LoL/champion.db-shm | Bin 32768 -> 32768 bytes Sources/API_LoL/champion.db-wal | Bin 8272 -> 8272 bytes Sources/Api_UT/ChampionControllerTest.cs | 4 +++- 5 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Sources/API_LoL/Controllers/ChampionsController.cs b/Sources/API_LoL/Controllers/ChampionsController.cs index b397831..96adf52 100644 --- a/Sources/API_LoL/Controllers/ChampionsController.cs +++ b/Sources/API_LoL/Controllers/ChampionsController.cs @@ -139,7 +139,7 @@ namespace API_LoL.Controllers else { var champ = await ChampionsManager.GetItemsByName(champion.Name, 0, 1); - if(champ.FirstOrDefault().Name == champion.Name) + if(champ.Count() != 0 && champ.FirstOrDefault().Name == champion.Name) { return Conflict(champion); } diff --git a/Sources/API_LoL/champion.db b/Sources/API_LoL/champion.db index cfdeed20a24e3204770fcb3599b2dbddcd974542..9b9ff130077ae7df9858803da9ed0419f22a260c 100644 GIT binary patch delta 45 zcmZp8z|`=7X#&Flix_?gAoStl=$PXP+-*vzi5k)MT&S(0({9(|Vv04(SX Af&c&j diff --git a/Sources/API_LoL/champion.db-shm b/Sources/API_LoL/champion.db-shm index bc92bf7c90a1c6edccee2d085804f480c74475eb..679fed479812696cf301d2e325b32f2c7c8ae519 100644 GIT binary patch delta 73 zcmZo@U}|V!njj&OnB&|l6`mo}5q$e3L)EQ0SGpdx6@=(0PLNQi0n^6J>Gc3l CnH-n^ diff --git a/Sources/API_LoL/champion.db-wal b/Sources/API_LoL/champion.db-wal index 8456db7c80f7ebb3e7040059073e7a57d09bb9f3..82f57bbb19294b263fbf60a030027f6e88140386 100644 GIT binary patch delta 118 zcmccMaKXXeyq>LzLHCga1A_nq2y_JBKFLsZYtFnwVY5HCtZ)DdF(He~^(SzCeR^Xh zFHn%3f9^*6Y5dIM?5vY-@Mnm_^!7UEB+6ujOL2kK?ARPGu#umIi&>I!GLM1_09?@~ AD*ylh delta 118 zcmccMaKXXeyq>LzLHCga1A_nq2vi&JU18e0^w5g0#(m07Crp7tOvvJG*QD}`; Assert.IsNotNull(a); ChampionDTO champ = new ChampionDTO("nom", "bio", "icon","Assassin", ""); - Assert.IsTrue(champ.equals((ChampionDTO)((CreatedAtActionResult)a).Value)); + Assert.IsTrue(champ.equals(other: (ChampionDTO)((CreatedAtActionResult)a).Value)); } } -- 2.36.3 From 1aca79ec2895e02bcc28f298bff65bef6857ff3f Mon Sep 17 00:00:00 2001 From: Corentin R <76619184+Koroh63@users.noreply.github.com> Date: Fri, 24 Mar 2023 18:06:12 +0100 Subject: [PATCH 2/2] fix ef Test --- Sources/API_LoL/champion.db | Bin 45056 -> 45056 bytes Sources/API_LoL/champion.db-shm | Bin 32768 -> 0 bytes Sources/API_LoL/champion.db-wal | Bin 8272 -> 0 bytes Sources/EF_UT/EFDataManagerChampionTest.cs | 36 ++++++++++++++------- 4 files changed, 25 insertions(+), 11 deletions(-) delete mode 100644 Sources/API_LoL/champion.db-shm delete mode 100644 Sources/API_LoL/champion.db-wal diff --git a/Sources/API_LoL/champion.db b/Sources/API_LoL/champion.db index 9b9ff130077ae7df9858803da9ed0419f22a260c..cfdeed20a24e3204770fcb3599b2dbddcd974542 100644 GIT binary patch delta 45 zcmZp8z|`=7X#&Flix_?gAoStl=$PXP+-*vzi5k)MT&S(0({9(|Vv04(SX Af&c&j delta 45 zcmZp8z|`=7X#;2rG4x3_`eR)4THRSo0q1kWZzq8M# zGXVkw2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C7epDdNd=UcwDG(}8G2oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U7^gr74$>q! diff --git a/Sources/API_LoL/champion.db-wal b/Sources/API_LoL/champion.db-wal deleted file mode 100644 index 82f57bbb19294b263fbf60a030027f6e88140386..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8272 zcmeI$ze>e06bA6LxoJ&nIWCtPulNSeu2vsG(A9uoi{%Pw2XPU^!9{!k|IGRV;_7u0 z1lNl?DT0gBMQ4*%;XZ*ldv52f^dR&J(my!G4FXl`G9c$+jO8Kd1|*d8{qDwO9p(&mCTx4;2ZP0PvZap diff --git a/Sources/EF_UT/EFDataManagerChampionTest.cs b/Sources/EF_UT/EFDataManagerChampionTest.cs index 80f34af..07e3ca2 100644 --- a/Sources/EF_UT/EFDataManagerChampionTest.cs +++ b/Sources/EF_UT/EFDataManagerChampionTest.cs @@ -2,7 +2,9 @@ using EntityFramework.Manager; using FluentAssertions; using FluentAssertions.Primitives; +using Microsoft.AspNetCore.Builder; using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.DependencyInjection; using Model; using System; using System.Collections.Generic; @@ -24,16 +26,28 @@ namespace EF_UT var champ = championsManager.AddItem(new Champion("test")); } - //[TestMethod] - //public async Task GetItemsByName_DefaultChamp_One() - //{ - // IDataManager dataManager = new EFDataManager(); - // IChampionsManager championsManager = dataManager.ChampionsMgr; - - // var ak = (await championsManager.GetItemsByName("A",0,1)).First(); - - // Assert.IsNotNull(ak); - // //Assert.AreEqual("Akali", ak.Name); - //} + [TestMethod] + public async Task GetItemsByName_DefaultChamp_One() + { + var builder = WebApplication.CreateBuilder(); + + builder.Services.AddDbContext(); + + var app = builder.Build(); + + using (var scope = app.Services.CreateScope()) + { + var context = scope.ServiceProvider.GetService(); + context.Database.EnsureCreated(); + } + + IDataManager dataManager = new EFDataManager(); + IChampionsManager championsManager = dataManager.ChampionsMgr; + + var ak = (await championsManager.GetItemsByName("A", 0, 1)).First(); + + Assert.IsNotNull(ak); + //Assert.AreEqual("Akali", ak.Name); + } } } -- 2.36.3