diff --git a/README.md b/README.md
index 9596336..06487b4 100644
--- a/README.md
+++ b/README.md
@@ -5,7 +5,7 @@
-**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
+**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
@@ -62,7 +62,9 @@ Ensuite sur le terminal PowerShell ou Visual Studio, lancer la migration via la
C'est bien beau toutes ces étapes mais s’il n'y a pas de résultat à quoi cela sert !
-Afin de visualiser la migration dans la base de données, cliquer dans l'onglet **Affichage**->**Explorateur d'objets SQL Server** :
+Tout d'abord veuille regarder dans l'onglet extension, si l'outil **SQLite and SQL Server Compact Toolbax** est bien installer.
+
+Puis, afin de visualiser la migration dans la base de données, cliquer dans l'onglet **Outils**->**SQLLite/ SQL Server compact Toolbox** :
@@ -70,9 +72,17 @@ Afin de visualiser la migration dans la base de données, cliquer dans l'onglet
-Puis dans l'Explorateur d'objets SQL Server, cliquer sur **SQL Server**-> **(localdb)\MSSQLLocalDB ...**->**Bases de données**
+Et enfin cliquer sur l'icône ci-dessous pour faire la connexion à la solution courent :
+
+
+
+
+
+
+
+Vous pouvez dorénavant voir toutes les tables qui y sont enregistrées !
-:information_source: *Notez qu'il est également possible d'utiliser l'Explorateur d'objets SQL Server pour ajouter, modifier ou supprimer des données dans les tables.*
+:information_source: *Notez qu'il est également possible grâce à SQLLite d'ajouter, modifier ou supprimer des données dans les tables.*
diff --git a/doc/Images/Connection_BD.png b/doc/Images/Connection_BD.png
new file mode 100644
index 0000000..bde0568
Binary files /dev/null and b/doc/Images/Connection_BD.png differ
diff --git a/doc/Images/Start_BD.png b/doc/Images/Start_BD.png
index 4955286..dee5655 100644
Binary files a/doc/Images/Start_BD.png and b/doc/Images/Start_BD.png differ
diff --git a/src/EntityFramework_LoL/Sources/ApiLol/ApiLol.csproj b/src/EntityFramework_LoL/Sources/ApiLol/ApiLol.csproj
index e9239f1..53e03ba 100644
--- a/src/EntityFramework_LoL/Sources/ApiLol/ApiLol.csproj
+++ b/src/EntityFramework_LoL/Sources/ApiLol/ApiLol.csproj
@@ -7,6 +7,7 @@
+
diff --git a/src/EntityFramework_LoL/Sources/DTO/DTO.csproj b/src/EntityFramework_LoL/Sources/DTO/DTO.csproj
index bafd05b..9c33615 100644
--- a/src/EntityFramework_LoL/Sources/DTO/DTO.csproj
+++ b/src/EntityFramework_LoL/Sources/DTO/DTO.csproj
@@ -6,4 +6,8 @@
enable
+
+
+
+
diff --git a/src/EntityFramework_LoL/Sources/LeagueOfLegends.sln b/src/EntityFramework_LoL/Sources/LeagueOfLegends.sln
index 5ac870e..e57cb50 100644
--- a/src/EntityFramework_LoL/Sources/LeagueOfLegends.sln
+++ b/src/EntityFramework_LoL/Sources/LeagueOfLegends.sln
@@ -22,6 +22,10 @@ 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}"
+
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MyFlib", "MyFlib\MyFlib.csproj", "{2142AB69-B483-4B0A-96DC-CFA87DEB11A5}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UT_EF", "Tests\UT_EF\UT_EF.csproj", "{F896C30B-A6FE-42B2-BAC8-08360BC48DC6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -61,6 +65,14 @@ Global
{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
+ {2142AB69-B483-4B0A-96DC-CFA87DEB11A5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {2142AB69-B483-4B0A-96DC-CFA87DEB11A5}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {2142AB69-B483-4B0A-96DC-CFA87DEB11A5}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {2142AB69-B483-4B0A-96DC-CFA87DEB11A5}.Release|Any CPU.Build.0 = Release|Any CPU
+ {F896C30B-A6FE-42B2-BAC8-08360BC48DC6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {F896C30B-A6FE-42B2-BAC8-08360BC48DC6}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {F896C30B-A6FE-42B2-BAC8-08360BC48DC6}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {F896C30B-A6FE-42B2-BAC8-08360BC48DC6}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -69,6 +81,7 @@ Global
{1889FA6E-B7C6-416E-8628-9449FB9070B9} = {C76D0C23-1FFA-4963-93CD-E12BD643F030}
{B01D7EF2-2D64-409A-A29A-61FB7BB7A9DB} = {2C607793-B163-4731-A4D1-AFE8A7C4C170}
{1779D8A4-2E12-47F3-BDA2-2E7F04B758EB} = {C76D0C23-1FFA-4963-93CD-E12BD643F030}
+ {F896C30B-A6FE-42B2-BAC8-08360BC48DC6} = {C76D0C23-1FFA-4963-93CD-E12BD643F030}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {92F3083D-793F-4552-8A9A-0AD6534159C9}
diff --git a/src/EntityFramework_LoL/Sources/Model/Model.csproj b/src/EntityFramework_LoL/Sources/Model/Model.csproj
index 27b2839..397943a 100644
--- a/src/EntityFramework_LoL/Sources/Model/Model.csproj
+++ b/src/EntityFramework_LoL/Sources/Model/Model.csproj
@@ -12,6 +12,9 @@
+
+
+
diff --git a/src/EntityFramework_LoL/Sources/MyFlib/DataBase.db b/src/EntityFramework_LoL/Sources/MyFlib/DataBase.db
new file mode 100644
index 0000000..d146bd7
Binary files /dev/null and b/src/EntityFramework_LoL/Sources/MyFlib/DataBase.db differ
diff --git a/src/EntityFramework_LoL/Sources/MyFlib/Entities/ChampionEntity.cs b/src/EntityFramework_LoL/Sources/MyFlib/Entities/ChampionEntity.cs
new file mode 100644
index 0000000..98313cf
--- /dev/null
+++ b/src/EntityFramework_LoL/Sources/MyFlib/Entities/ChampionEntity.cs
@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MyFlib
+{
+ public class ChampionEntity
+ {
+ [Key]
+ public int Id { get; set; }
+ [MaxLength(255)]
+ public string Name { get; set; }
+ [MaxLength(255)]
+ public string Bio { get; set; }
+ [MaxLength(255)]
+ public string Icon { get; set; }
+ [MaxLength(255)]
+ public string Image { get; set; }
+ public ChampionClassEntity Class { get; set; }
+
+ }
+}
diff --git a/src/EntityFramework_LoL/Sources/MyFlib/LolDbContext.cs b/src/EntityFramework_LoL/Sources/MyFlib/LolDbContext.cs
new file mode 100644
index 0000000..8b78047
--- /dev/null
+++ b/src/EntityFramework_LoL/Sources/MyFlib/LolDbContext.cs
@@ -0,0 +1,42 @@
+using Microsoft.EntityFrameworkCore;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MyFlib
+{
+ public class LolDbContext : DbContext
+ {
+ public DbSet Champions { get; set; }
+ public LolDbContext()
+ { }
+
+ public LolDbContext(DbContextOptions options) : base(options)
+ { }
+
+ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
+ {
+ if (!optionsBuilder.IsConfigured)
+ {
+ optionsBuilder.UseSqlite("Data Source=DataBase.db");
+ }
+ }
+ protected override void OnModelCreating(ModelBuilder modelBuilder)
+ {
+ modelBuilder.Entity().HasKey(e => e.Id);
+ modelBuilder.Entity().Property(e => e.Id).ValueGeneratedOnAdd();
+ modelBuilder.Entity().HasData(
+ new ChampionEntity { Id = 1, Name = "Akali", Class = ChampionClassEntity.Assassin, Bio = "", Icon = "", Image = "" },
+ new ChampionEntity { Id = 2, Name = "Aatrox", Class = ChampionClassEntity.Fighter, Bio = "", Icon = "", Image = "" },
+ new ChampionEntity { Id = 3, Name = "Ahri", Class = ChampionClassEntity.Mage, Bio = "", Icon = "", Image = "" },
+ new ChampionEntity { Id = 4, Name = "Akshan", Class = ChampionClassEntity.Marksman, Bio = "", Icon = "", Image = "" },
+ new ChampionEntity { Id = 5, Name = "Bard", Class = ChampionClassEntity.Support, Bio = "", Icon = "", Image = "" },
+ new ChampionEntity { Id = 6, Name = "Alistar", Class = ChampionClassEntity.Tank, Bio = "", Icon = "", Image = "" }
+ );
+
+ }
+
+ }
+}
diff --git a/src/EntityFramework_LoL/Sources/MyFlib/Migrations/20230204131532_MyMigration.Designer.cs b/src/EntityFramework_LoL/Sources/MyFlib/Migrations/20230204131532_MyMigration.Designer.cs
new file mode 100644
index 0000000..8cfaffe
--- /dev/null
+++ b/src/EntityFramework_LoL/Sources/MyFlib/Migrations/20230204131532_MyMigration.Designer.cs
@@ -0,0 +1,114 @@
+//
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using MyFlib;
+
+#nullable disable
+
+namespace MyFlib.Migrations
+{
+ [DbContext(typeof(LolDbContext))]
+ [Migration("20230204131532_MyMigration")]
+ partial class MyMigration
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder.HasAnnotation("ProductVersion", "7.0.2");
+
+ modelBuilder.Entity("MyFlib.ChampionEntity", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("Bio")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("TEXT");
+
+ b.Property("Class")
+ .HasColumnType("INTEGER");
+
+ b.Property("Icon")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("TEXT");
+
+ b.Property("Image")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("TEXT");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.ToTable("Champions");
+
+ b.HasData(
+ new
+ {
+ Id = 1,
+ Bio = "",
+ Class = 1,
+ Icon = "",
+ Image = "",
+ Name = "Akali"
+ },
+ new
+ {
+ Id = 2,
+ Bio = "",
+ Class = 2,
+ Icon = "",
+ Image = "",
+ Name = "Aatrox"
+ },
+ new
+ {
+ Id = 3,
+ Bio = "",
+ Class = 3,
+ Icon = "",
+ Image = "",
+ Name = "Ahri"
+ },
+ new
+ {
+ Id = 4,
+ Bio = "",
+ Class = 4,
+ Icon = "",
+ Image = "",
+ Name = "Akshan"
+ },
+ new
+ {
+ Id = 5,
+ Bio = "",
+ Class = 5,
+ Icon = "",
+ Image = "",
+ Name = "Bard"
+ },
+ new
+ {
+ Id = 6,
+ Bio = "",
+ Class = 6,
+ Icon = "",
+ Image = "",
+ Name = "Alistar"
+ });
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/src/EntityFramework_LoL/Sources/MyFlib/Migrations/20230204131532_MyMigration.cs b/src/EntityFramework_LoL/Sources/MyFlib/Migrations/20230204131532_MyMigration.cs
new file mode 100644
index 0000000..2480c4e
--- /dev/null
+++ b/src/EntityFramework_LoL/Sources/MyFlib/Migrations/20230204131532_MyMigration.cs
@@ -0,0 +1,53 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
+
+namespace MyFlib.Migrations
+{
+ ///
+ public partial class MyMigration : Migration
+ {
+ ///
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.CreateTable(
+ name: "Champions",
+ columns: table => new
+ {
+ Id = table.Column(type: "INTEGER", nullable: false)
+ .Annotation("Sqlite:Autoincrement", true),
+ Name = table.Column(type: "TEXT", maxLength: 255, nullable: false),
+ Bio = table.Column(type: "TEXT", maxLength: 255, nullable: false),
+ Icon = table.Column(type: "TEXT", maxLength: 255, nullable: false),
+ Image = table.Column(type: "TEXT", maxLength: 255, nullable: false),
+ Class = table.Column(type: "INTEGER", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Champions", x => x.Id);
+ });
+
+ migrationBuilder.InsertData(
+ table: "Champions",
+ columns: new[] { "Id", "Bio", "Class", "Icon", "Image", "Name" },
+ values: new object[,]
+ {
+ { 1, "", 1, "", "", "Akali" },
+ { 2, "", 2, "", "", "Aatrox" },
+ { 3, "", 3, "", "", "Ahri" },
+ { 4, "", 4, "", "", "Akshan" },
+ { 5, "", 5, "", "", "Bard" },
+ { 6, "", 6, "", "", "Alistar" }
+ });
+ }
+
+ ///
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropTable(
+ name: "Champions");
+ }
+ }
+}
diff --git a/src/EntityFramework_LoL/Sources/MyFlib/Migrations/LolDbContextModelSnapshot.cs b/src/EntityFramework_LoL/Sources/MyFlib/Migrations/LolDbContextModelSnapshot.cs
new file mode 100644
index 0000000..76cb456
--- /dev/null
+++ b/src/EntityFramework_LoL/Sources/MyFlib/Migrations/LolDbContextModelSnapshot.cs
@@ -0,0 +1,111 @@
+//
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using MyFlib;
+
+#nullable disable
+
+namespace MyFlib.Migrations
+{
+ [DbContext(typeof(LolDbContext))]
+ partial class LolDbContextModelSnapshot : ModelSnapshot
+ {
+ protected override void BuildModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder.HasAnnotation("ProductVersion", "7.0.2");
+
+ modelBuilder.Entity("MyFlib.ChampionEntity", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("Bio")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("TEXT");
+
+ b.Property("Class")
+ .HasColumnType("INTEGER");
+
+ b.Property("Icon")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("TEXT");
+
+ b.Property("Image")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("TEXT");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.ToTable("Champions");
+
+ b.HasData(
+ new
+ {
+ Id = 1,
+ Bio = "",
+ Class = 1,
+ Icon = "",
+ Image = "",
+ Name = "Akali"
+ },
+ new
+ {
+ Id = 2,
+ Bio = "",
+ Class = 2,
+ Icon = "",
+ Image = "",
+ Name = "Aatrox"
+ },
+ new
+ {
+ Id = 3,
+ Bio = "",
+ Class = 3,
+ Icon = "",
+ Image = "",
+ Name = "Ahri"
+ },
+ new
+ {
+ Id = 4,
+ Bio = "",
+ Class = 4,
+ Icon = "",
+ Image = "",
+ Name = "Akshan"
+ },
+ new
+ {
+ Id = 5,
+ Bio = "",
+ Class = 5,
+ Icon = "",
+ Image = "",
+ Name = "Bard"
+ },
+ new
+ {
+ Id = 6,
+ Bio = "",
+ Class = 6,
+ Icon = "",
+ Image = "",
+ Name = "Alistar"
+ });
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/src/EntityFramework_LoL/Sources/MyFlib/MyFlib.csproj b/src/EntityFramework_LoL/Sources/MyFlib/MyFlib.csproj
new file mode 100644
index 0000000..effa3a7
--- /dev/null
+++ b/src/EntityFramework_LoL/Sources/MyFlib/MyFlib.csproj
@@ -0,0 +1,26 @@
+
+
+
+ Exe
+ net6.0
+ enable
+ enable
+ $(MSBuildProjectDirectory)
+
+
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+
diff --git a/src/EntityFramework_LoL/Sources/MyFlib/Program.cs b/src/EntityFramework_LoL/Sources/MyFlib/Program.cs
new file mode 100644
index 0000000..3e22f35
--- /dev/null
+++ b/src/EntityFramework_LoL/Sources/MyFlib/Program.cs
@@ -0,0 +1,12 @@
+// See https://aka.ms/new-console-template for more information
+using MyFlib;
+
+using (var context = new LolDbContext())
+{
+
+ foreach (var c in context.Champions)
+ {
+ Console.WriteLine($"{c.Name} - {c.Bio}");
+ }
+ context.SaveChangesAsync(); // or context.SaveChangesAsync
+}
\ No newline at end of file
diff --git a/src/EntityFramework_LoL/Sources/MyFlib/enums/ChampionClassEntity.cs b/src/EntityFramework_LoL/Sources/MyFlib/enums/ChampionClassEntity.cs
new file mode 100644
index 0000000..bec72f2
--- /dev/null
+++ b/src/EntityFramework_LoL/Sources/MyFlib/enums/ChampionClassEntity.cs
@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MyFlib
+{
+ public enum ChampionClassEntity
+ {
+ Unknown,
+ Assassin,
+ Fighter,
+ Mage,
+ Marksman,
+ Support,
+ Tank,
+ }
+}
diff --git a/src/EntityFramework_LoL/Sources/Shared/Shared.csproj b/src/EntityFramework_LoL/Sources/Shared/Shared.csproj
index bafd05b..9c33615 100644
--- a/src/EntityFramework_LoL/Sources/Shared/Shared.csproj
+++ b/src/EntityFramework_LoL/Sources/Shared/Shared.csproj
@@ -6,4 +6,8 @@
enable
+
+
+
+
diff --git a/src/EntityFramework_LoL/Sources/StubLib/StubLib.csproj b/src/EntityFramework_LoL/Sources/StubLib/StubLib.csproj
index f05027c..b03fb75 100644
--- a/src/EntityFramework_LoL/Sources/StubLib/StubLib.csproj
+++ b/src/EntityFramework_LoL/Sources/StubLib/StubLib.csproj
@@ -6,6 +6,10 @@
enable
+
+
+
+
diff --git a/src/EntityFramework_LoL/Sources/Tests/ApiTests/ChampionsControllerTest.cs b/src/EntityFramework_LoL/Sources/Tests/ApiTests/ChampionsControllerTest.cs
index a0b976c..5546a25 100644
--- a/src/EntityFramework_LoL/Sources/Tests/ApiTests/ChampionsControllerTest.cs
+++ b/src/EntityFramework_LoL/Sources/Tests/ApiTests/ChampionsControllerTest.cs
@@ -53,7 +53,7 @@ namespace ApiTests
var objectResult = championsResult as CreatedAtActionResult;
Assert.IsNotNull(objectResult);
- var champions = objectResult?.Value as Champion;
+ var champions = objectResult?.Value as ChampionDto;
Assert.IsNotNull(champions);
}
diff --git a/src/EntityFramework_LoL/Sources/Tests/ConsoleTests/ConsoleTests.csproj b/src/EntityFramework_LoL/Sources/Tests/ConsoleTests/ConsoleTests.csproj
index 1602b94..3b17a32 100644
--- a/src/EntityFramework_LoL/Sources/Tests/ConsoleTests/ConsoleTests.csproj
+++ b/src/EntityFramework_LoL/Sources/Tests/ConsoleTests/ConsoleTests.csproj
@@ -15,6 +15,7 @@
+
diff --git a/src/EntityFramework_LoL/Sources/Tests/UT_EF/ChampionsTest.cs b/src/EntityFramework_LoL/Sources/Tests/UT_EF/ChampionsTest.cs
new file mode 100644
index 0000000..1f99d6a
--- /dev/null
+++ b/src/EntityFramework_LoL/Sources/Tests/UT_EF/ChampionsTest.cs
@@ -0,0 +1,75 @@
+
+using Microsoft.EntityFrameworkCore;
+using MyFlib;
+using Xunit;
+
+namespace UT_EF
+{
+ public class UnitTest1
+ {
+ [Fact]
+ public void TestAdd()
+ {
+ var options = new DbContextOptionsBuilder()
+ .UseInMemoryDatabase(databaseName: "Add_Test_database")
+ .Options;
+
+ using (var context = new LolDbContext(options))
+ {
+ ChampionEntity sylas = new ChampionEntity { Name = "Sylas", Class = ChampionClassEntity.Assassin, Bio = "", Icon = "", Image = "" };
+ ChampionEntity hecarim = new ChampionEntity { Name = "Hecarim", Class = ChampionClassEntity.Fighter, Bio = "", Icon = "", Image = "" };
+ ChampionEntity yuumi = new ChampionEntity { Name = "yuumi", Class = ChampionClassEntity.Mage, Bio = "", Icon = "", Image = "" };
+
+ context.Champions.Add(sylas);
+ context.Champions.Add(hecarim);
+ context.Champions.Add(yuumi);
+ context.SaveChanges();
+ }
+
+ using (var context = new LolDbContext(options))
+ {
+ Assert.Equal(3, context.Champions.Count());
+ Assert.Equal("Sylas", context.Champions.First().Name);
+ }
+ }
+
+ [Fact]
+ public void Modify_Test()
+ {
+ var options = new DbContextOptionsBuilder()
+ .UseInMemoryDatabase(databaseName: "Modify_Test_database")
+ .Options;
+
+ using (var context = new LolDbContext(options))
+ {
+ ChampionEntity sylas = new ChampionEntity { Name = "Sylas", Class = ChampionClassEntity.Assassin, Bio = "", Icon = "", Image = "" };
+ ChampionEntity hecarim = new ChampionEntity { Name = "Hecarim", Class = ChampionClassEntity.Fighter, Bio = "", Icon = "", Image = "" };
+ ChampionEntity yuumi = new ChampionEntity { Name = "yuumi", Class = ChampionClassEntity.Mage, Bio = "", Icon = "", Image = "" };
+
+ context.Champions.Add(sylas);
+ context.Champions.Add(hecarim);
+ context.Champions.Add(yuumi);
+ context.SaveChanges();
+ }
+
+ using (var context = new LolDbContext(options))
+ {
+ string nameToFind = "m";
+ Assert.Equal(2, context.Champions.Where(c => c.Name.ToLower().Contains(nameToFind)).Count());
+ nameToFind = "yuu";
+ Assert.Equal(1, context.Champions.Where(c => c.Name.ToLower().Contains(nameToFind)).Count());
+ var ewok = context.Champions.Where(c => c.Name.ToLower().Contains(nameToFind)).First();
+ ewok.Name = "Garen";
+ context.SaveChanges();
+ }
+
+ using (var context = new LolDbContext(options))
+ {
+ string nameToFind = "m";
+ Assert.Equal(1, context.Champions.Where(c => c.Name.ToLower().Contains(nameToFind)).Count());
+ nameToFind = "garen";
+ Assert.Equal(1, context.Champions.Where(c => c.Name.ToLower().Contains(nameToFind)).Count());
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/EntityFramework_LoL/Sources/Tests/UT_EF/UT_EF.csproj b/src/EntityFramework_LoL/Sources/Tests/UT_EF/UT_EF.csproj
new file mode 100644
index 0000000..0b8e47b
--- /dev/null
+++ b/src/EntityFramework_LoL/Sources/Tests/UT_EF/UT_EF.csproj
@@ -0,0 +1,29 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+ false
+
+
+
+
+
+
+
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+ all
+
+
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+ all
+
+
+
+
+
+
+
+
diff --git a/src/EntityFramework_LoL/Sources/Tests/UT_EF/Usings.cs b/src/EntityFramework_LoL/Sources/Tests/UT_EF/Usings.cs
new file mode 100644
index 0000000..8c927eb
--- /dev/null
+++ b/src/EntityFramework_LoL/Sources/Tests/UT_EF/Usings.cs
@@ -0,0 +1 @@
+global using Xunit;
\ No newline at end of file