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/ApiLol/Controllers/ChampionsController.cs b/src/EntityFramework_LoL/Sources/ApiLol/Controllers/ChampionsController.cs
index c19a41a..d06fbaa 100644
--- a/src/EntityFramework_LoL/Sources/ApiLol/Controllers/ChampionsController.cs
+++ b/src/EntityFramework_LoL/Sources/ApiLol/Controllers/ChampionsController.cs
@@ -17,8 +17,8 @@ namespace ApiLol.Controllers
[HttpGet]
public async Task Get()
{
- var champions = await dataManager.GetItems(0, await dataManager.GetNbItems()); // Le await va permettre que les lignes suivantes ne s'éxécute pas
- return Ok(new { result = champions.Select(c => c.ToDto())});
+ var champions = await dataManager.GetItems(0, await dataManager.GetNbItems()); // Le await va permettre que les lignes suivantes ne s'éxécute pas
+ return Ok(new { result = champions.Select(c => c.ToDto()) });
}
// GET api//5
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 a1cac0d..558a0e2 100644
--- a/src/EntityFramework_LoL/Sources/LeagueOfLegends.sln
+++ b/src/EntityFramework_LoL/Sources/LeagueOfLegends.sln
@@ -19,7 +19,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ApiLol", "ApiLol\ApiLol.csp
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DTO", "DTO\DTO.csproj", "{3919E408-EB12-4422-989B-C6ED4816D465}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MyFlib", "MyFlib\MyFlib.csproj", "{2142AB69-B483-4B0A-96DC-CFA87DEB11A5}"
+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
@@ -55,6 +57,10 @@ Global
{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
@@ -62,6 +68,7 @@ Global
GlobalSection(NestedProjects) = preSolution
{1889FA6E-B7C6-416E-8628-9449FB9070B9} = {C76D0C23-1FFA-4963-93CD-E12BD643F030}
{B01D7EF2-2D64-409A-A29A-61FB7BB7A9DB} = {2C607793-B163-4731-A4D1-AFE8A7C4C170}
+ {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/ChampionEntity.cs b/src/EntityFramework_LoL/Sources/MyFlib/ChampionEntity.cs
deleted file mode 100644
index 0f25121..0000000
--- a/src/EntityFramework_LoL/Sources/MyFlib/ChampionEntity.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-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 string Name { get; set; }
- public ChampionEntity(string name)
- {
- Name = name;
- }
- }
-}
diff --git a/src/EntityFramework_LoL/Sources/MyFlib/DataBase.db b/src/EntityFramework_LoL/Sources/MyFlib/DataBase.db
index 13315b3..d146bd7 100644
Binary files a/src/EntityFramework_LoL/Sources/MyFlib/DataBase.db 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
index 71e5157..8b78047 100644
--- a/src/EntityFramework_LoL/Sources/MyFlib/LolDbContext.cs
+++ b/src/EntityFramework_LoL/Sources/MyFlib/LolDbContext.cs
@@ -7,19 +7,35 @@ using System.Threading.Tasks;
namespace MyFlib
{
- public class LolDbContext: DbContext
+ 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");
+ optionsBuilder.UseSqlite("Data Source=DataBase.db");
}
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
- modelBuilder.Entity().HasData(new ChampionEntity("Akali"));
+ 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/20230201163620_MyMigration.Designer.cs b/src/EntityFramework_LoL/Sources/MyFlib/Migrations/20230201163620_MyMigration.Designer.cs
deleted file mode 100644
index 6ce17ec..0000000
--- a/src/EntityFramework_LoL/Sources/MyFlib/Migrations/20230201163620_MyMigration.Designer.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-//
-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("20230201163620_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("Name")
- .HasColumnType("TEXT");
-
- b.HasKey("Name");
-
- b.ToTable("Champions");
-
- b.HasData(
- new
- {
- Name = "Akali"
- });
- });
-#pragma warning restore 612, 618
- }
- }
-}
diff --git a/src/EntityFramework_LoL/Sources/MyFlib/Migrations/20230201163620_MyMigration.cs b/src/EntityFramework_LoL/Sources/MyFlib/Migrations/20230201163620_MyMigration.cs
deleted file mode 100644
index 8716d00..0000000
--- a/src/EntityFramework_LoL/Sources/MyFlib/Migrations/20230201163620_MyMigration.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-using Microsoft.EntityFrameworkCore.Migrations;
-
-#nullable disable
-
-namespace MyFlib.Migrations
-{
- ///
- public partial class MyMigration : Migration
- {
- ///
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.CreateTable(
- name: "Champions",
- columns: table => new
- {
- Name = table.Column(type: "TEXT", nullable: false)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_Champions", x => x.Name);
- });
-
- migrationBuilder.InsertData(
- table: "Champions",
- column: "Name",
- value: "Akali");
- }
-
- ///
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropTable(
- name: "Champions");
- }
- }
-}
diff --git a/src/EntityFramework_LoL/Sources/MyFlib/Migrations/20230204102522_MyMigration.Designer.cs b/src/EntityFramework_LoL/Sources/MyFlib/Migrations/20230204102522_MyMigration.Designer.cs
new file mode 100644
index 0000000..78d288f
--- /dev/null
+++ b/src/EntityFramework_LoL/Sources/MyFlib/Migrations/20230204102522_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("20230204102522_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/20230204102522_MyMigration.cs b/src/EntityFramework_LoL/Sources/MyFlib/Migrations/20230204102522_MyMigration.cs
new file mode 100644
index 0000000..2480c4e
--- /dev/null
+++ b/src/EntityFramework_LoL/Sources/MyFlib/Migrations/20230204102522_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
index 5f71390..76cb456 100644
--- a/src/EntityFramework_LoL/Sources/MyFlib/Migrations/LolDbContextModelSnapshot.cs
+++ b/src/EntityFramework_LoL/Sources/MyFlib/Migrations/LolDbContextModelSnapshot.cs
@@ -18,17 +18,91 @@ namespace MyFlib.Migrations
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("Name");
+ 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
index f99623c..effa3a7 100644
--- a/src/EntityFramework_LoL/Sources/MyFlib/MyFlib.csproj
+++ b/src/EntityFramework_LoL/Sources/MyFlib/MyFlib.csproj
@@ -16,6 +16,7 @@
+
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
index ef4ef6d..3e22f35 100644
--- a/src/EntityFramework_LoL/Sources/MyFlib/Program.cs
+++ b/src/EntityFramework_LoL/Sources/MyFlib/Program.cs
@@ -1,10 +1,12 @@
// See https://aka.ms/new-console-template for more information
using MyFlib;
-Console.WriteLine("Hello, World!");
-
-using(var context = new LolDbContext())
+using (var context = new LolDbContext())
{
- //var champions = context.Champions.where
+
+ 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/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