diff --git a/Sources/EntityFrameWorkLib/Migrations/20230317075439_MyMigration.Designer.cs b/Sources/EntityFrameWorkLib/Migrations/20230317075439_MyMigration.Designer.cs
deleted file mode 100644
index 026aaa2..0000000
--- a/Sources/EntityFrameWorkLib/Migrations/20230317075439_MyMigration.Designer.cs
+++ /dev/null
@@ -1,108 +0,0 @@
-//
-using System;
-using EntityFrameWorkLib;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-using Microsoft.EntityFrameworkCore.Migrations;
-using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
-
-#nullable disable
-
-namespace EntityFrameWorkLib.Migrations
-{
- [DbContext(typeof(LolContext))]
- [Migration("20230317075439_MyMigration")]
- partial class MyMigration
- {
- ///
- protected override void BuildTargetModel(ModelBuilder modelBuilder)
- {
-#pragma warning disable 612, 618
- modelBuilder.HasAnnotation("ProductVersion", "7.0.4");
-
- modelBuilder.Entity("EntityFrameWorkLib.ChampionEntity", b =>
- {
- b.Property("UniqueId")
- .ValueGeneratedOnAdd()
- .HasColumnType("INTEGER");
-
- b.Property("Bio")
- .IsRequired()
- .HasMaxLength(256)
- .HasColumnType("TEXT");
-
- b.Property("Class")
- .HasColumnType("INTEGER");
-
- b.Property("Icon")
- .IsRequired()
- .HasColumnType("TEXT");
-
- b.Property("Name")
- .IsRequired()
- .HasColumnType("TEXT");
-
- b.HasKey("UniqueId");
-
- b.ToTable("Champions");
- });
-
- modelBuilder.Entity("EntityFrameWorkLib.LargeImageEntity", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("TEXT");
-
- b.Property("Base64")
- .IsRequired()
- .HasColumnType("TEXT");
-
- b.Property("championId")
- .HasColumnType("INTEGER");
-
- b.HasKey("Id");
-
- b.HasIndex("championId")
- .IsUnique();
-
- b.ToTable("LargeImage");
- });
-
- modelBuilder.Entity("EntityFrameWorkLib.SkillEntity", b =>
- {
- b.Property("Name")
- .HasMaxLength(256)
- .HasColumnType("TEXT");
-
- b.Property("Description")
- .IsRequired()
- .HasMaxLength(500)
- .HasColumnType("TEXT");
-
- b.Property("SkillType")
- .HasColumnType("INTEGER");
-
- b.HasKey("Name");
-
- b.ToTable("Skill");
- });
-
- modelBuilder.Entity("EntityFrameWorkLib.LargeImageEntity", b =>
- {
- b.HasOne("EntityFrameWorkLib.ChampionEntity", "champion")
- .WithOne("LargeImageEntity")
- .HasForeignKey("EntityFrameWorkLib.LargeImageEntity", "championId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.Navigation("champion");
- });
-
- modelBuilder.Entity("EntityFrameWorkLib.ChampionEntity", b =>
- {
- b.Navigation("LargeImageEntity");
- });
-#pragma warning restore 612, 618
- }
- }
-}
diff --git a/Sources/EntityFrameWorkLib/Migrations/20230317075439_MyMigration.cs b/Sources/EntityFrameWorkLib/Migrations/20230317075439_MyMigration.cs
deleted file mode 100644
index 0fd9526..0000000
--- a/Sources/EntityFrameWorkLib/Migrations/20230317075439_MyMigration.cs
+++ /dev/null
@@ -1,82 +0,0 @@
-using System;
-using Microsoft.EntityFrameworkCore.Migrations;
-
-#nullable disable
-
-namespace EntityFrameWorkLib.Migrations
-{
- ///
- public partial class MyMigration : Migration
- {
- ///
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.CreateTable(
- name: "Champions",
- columns: table => new
- {
- UniqueId = table.Column(type: "INTEGER", nullable: false)
- .Annotation("Sqlite:Autoincrement", true),
- Name = table.Column(type: "TEXT", nullable: false),
- Bio = table.Column(type: "TEXT", maxLength: 256, nullable: false),
- Icon = table.Column(type: "TEXT", nullable: false),
- Class = table.Column(type: "INTEGER", nullable: false)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_Champions", x => x.UniqueId);
- });
-
- migrationBuilder.CreateTable(
- name: "Skill",
- columns: table => new
- {
- Name = table.Column(type: "TEXT", maxLength: 256, nullable: false),
- Description = table.Column(type: "TEXT", maxLength: 500, nullable: false),
- SkillType = table.Column(type: "INTEGER", nullable: false)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_Skill", x => x.Name);
- });
-
- migrationBuilder.CreateTable(
- name: "LargeImage",
- columns: table => new
- {
- Id = table.Column(type: "TEXT", nullable: false),
- Base64 = table.Column(type: "TEXT", nullable: false),
- championId = table.Column(type: "INTEGER", nullable: false)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_LargeImage", x => x.Id);
- table.ForeignKey(
- name: "FK_LargeImage_Champions_championId",
- column: x => x.championId,
- principalTable: "Champions",
- principalColumn: "UniqueId",
- onDelete: ReferentialAction.Cascade);
- });
-
- migrationBuilder.CreateIndex(
- name: "IX_LargeImage_championId",
- table: "LargeImage",
- column: "championId",
- unique: true);
- }
-
- ///
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropTable(
- name: "LargeImage");
-
- migrationBuilder.DropTable(
- name: "Skill");
-
- migrationBuilder.DropTable(
- name: "Champions");
- }
- }
-}
diff --git a/Sources/EntityFrameWorkLib/Migrations/LolContextModelSnapshot.cs b/Sources/EntityFrameWorkLib/Migrations/LolContextModelSnapshot.cs
deleted file mode 100644
index a9a3587..0000000
--- a/Sources/EntityFrameWorkLib/Migrations/LolContextModelSnapshot.cs
+++ /dev/null
@@ -1,105 +0,0 @@
-//
-using System;
-using EntityFrameWorkLib;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
-
-#nullable disable
-
-namespace EntityFrameWorkLib.Migrations
-{
- [DbContext(typeof(LolContext))]
- partial class LolContextModelSnapshot : ModelSnapshot
- {
- protected override void BuildModel(ModelBuilder modelBuilder)
- {
-#pragma warning disable 612, 618
- modelBuilder.HasAnnotation("ProductVersion", "7.0.4");
-
- modelBuilder.Entity("EntityFrameWorkLib.ChampionEntity", b =>
- {
- b.Property("UniqueId")
- .ValueGeneratedOnAdd()
- .HasColumnType("INTEGER");
-
- b.Property("Bio")
- .IsRequired()
- .HasMaxLength(256)
- .HasColumnType("TEXT");
-
- b.Property("Class")
- .HasColumnType("INTEGER");
-
- b.Property("Icon")
- .IsRequired()
- .HasColumnType("TEXT");
-
- b.Property("Name")
- .IsRequired()
- .HasColumnType("TEXT");
-
- b.HasKey("UniqueId");
-
- b.ToTable("Champions");
- });
-
- modelBuilder.Entity("EntityFrameWorkLib.LargeImageEntity", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("TEXT");
-
- b.Property("Base64")
- .IsRequired()
- .HasColumnType("TEXT");
-
- b.Property("championId")
- .HasColumnType("INTEGER");
-
- b.HasKey("Id");
-
- b.HasIndex("championId")
- .IsUnique();
-
- b.ToTable("LargeImage");
- });
-
- modelBuilder.Entity("EntityFrameWorkLib.SkillEntity", b =>
- {
- b.Property("Name")
- .HasMaxLength(256)
- .HasColumnType("TEXT");
-
- b.Property("Description")
- .IsRequired()
- .HasMaxLength(500)
- .HasColumnType("TEXT");
-
- b.Property("SkillType")
- .HasColumnType("INTEGER");
-
- b.HasKey("Name");
-
- b.ToTable("Skill");
- });
-
- modelBuilder.Entity("EntityFrameWorkLib.LargeImageEntity", b =>
- {
- b.HasOne("EntityFrameWorkLib.ChampionEntity", "champion")
- .WithOne("LargeImageEntity")
- .HasForeignKey("EntityFrameWorkLib.LargeImageEntity", "championId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.Navigation("champion");
- });
-
- modelBuilder.Entity("EntityFrameWorkLib.ChampionEntity", b =>
- {
- b.Navigation("LargeImageEntity");
- });
-#pragma warning restore 612, 618
- }
- }
-}
diff --git a/Sources/Tests/TestUnitaireLOL/TestAPI.cs b/Sources/Tests/TestUnitaireLOL/TestAPI.cs
new file mode 100644
index 0000000..22c7725
--- /dev/null
+++ b/Sources/Tests/TestUnitaireLOL/TestAPI.cs
@@ -0,0 +1,40 @@
+using System;
+using Microsoft.Extensions.Logging.Abstractions;
+using StubLib;
+using WebApiLol;
+using WebApiLol.Controllers;
+
+namespace TestUnitaireLOL
+{
+ public class TestAPI
+ {
+ [Theory]
+ [InlineData("Beatrice", "sdfsdfd", "icon.png")]
+ [InlineData("Maurice", "Ahri est un champion de League of Legends", "icon.png")]
+ [InlineData("Loupiotte", "Akali est un champion de League of Legends", "icon.png")]
+ public async Task TestPostChampion(string name, string bio, string icon)
+ {
+ // Arrange
+ var data = new StubData();
+ var logger = new NullLogger();
+ var controller = new ChampionController(data, logger);
+ var champDTO = new ChampionDTO()
+ {
+ Name = name,
+ Bio = bio,
+ Icon = icon
+ };
+
+ // Act
+ var nbInListBefore = data.ChampionsMgr.GetNbItems().Result;
+ var result = await controller.AddChampion(champDTO);
+ var nbInListAfter = data.ChampionsMgr.GetNbItems().Result;
+
+ // Assert
+ // IS the champion added to the list, number of champions in the list + 1
+ Assert.Equal(nbInListBefore + 1, nbInListAfter);
+ // Test le code de retour
+ }
+ }
+}
+
diff --git a/Sources/Tests/TestUnitaireLOL/TestEf.cs b/Sources/Tests/TestUnitaireLOL/TestEf.cs
index 90a7880..48dde60 100644
--- a/Sources/Tests/TestUnitaireLOL/TestEf.cs
+++ b/Sources/Tests/TestUnitaireLOL/TestEf.cs
@@ -1,4 +1,5 @@
using System;
+using System.Collections.ObjectModel;
using EntityFrameWorkLib;
using Microsoft.Data.Sqlite;
using Microsoft.EntityFrameworkCore;
@@ -7,52 +8,169 @@ using Shared;
namespace TestUnitaireLOL
{
- public class TestsData
+ public class TestEf
{
- public IEnumerable