diff --git a/Sources/EFLol/EFLol.csproj b/Sources/EFLol/EFLol.csproj index 3d9abc2..bbc403a 100644 --- a/Sources/EFLol/EFLol.csproj +++ b/Sources/EFLol/EFLol.csproj @@ -1,27 +1,28 @@ - - - - Exe - net6.0 - enable - enable - $(MSBuildProjectDirectory) - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - + + + + Exe + net6.0 + enable + enable + $(MSBuildProjectDirectory) + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - + + + + + diff --git a/Sources/Model/Model.csproj b/Sources/Model/Model.csproj index 63fa530..9844555 100644 --- a/Sources/Model/Model.csproj +++ b/Sources/Model/Model.csproj @@ -14,6 +14,8 @@ + + all diff --git a/Sources/Shared/Shared.csproj b/Sources/Shared/Shared.csproj index 000356c..a35cef7 100644 --- a/Sources/Shared/Shared.csproj +++ b/Sources/Shared/Shared.csproj @@ -8,6 +8,8 @@ + + all diff --git a/Sources/StubLib/StubLib.csproj b/Sources/StubLib/StubLib.csproj index a51603e..65ff122 100644 --- a/Sources/StubLib/StubLib.csproj +++ b/Sources/StubLib/StubLib.csproj @@ -8,6 +8,8 @@ + + all diff --git a/Sources/TestUnitaire/TestEfLol.cs b/Sources/TestUnitaire/TestEfLol.cs index da2b1dd..00b1923 100644 --- a/Sources/TestUnitaire/TestEfLol.cs +++ b/Sources/TestUnitaire/TestEfLol.cs @@ -1,7 +1,4 @@ - - - -using EFLol; +using EFLol; using Microsoft.Data.Sqlite; using Microsoft.EntityFrameworkCore; @@ -49,6 +46,49 @@ namespace TestUnitaire Assert.Equal("Zeus", found.Name); } } + + [Fact] + public void ModifyTestInMemory() + { + var options = new DbContextOptionsBuilder() + .UseInMemoryDatabase(databaseName: "Modify_Test_database") + .Options; + + //prepares the database with one instance of the context + + using (var context = new ChampionContext(options)) + { + ChampionEntity chewie = new ChampionEntity { Name = "Chewbacca", Bio = "Zeus is the king of the gods." }; + ChampionEntity yoda = new ChampionEntity { Name = "Yoda", Bio = "Zeus is the king of the gods." }; + ChampionEntity ewok = new ChampionEntity { Name = "Ewok", Bio = "Zeus is the king of the gods." }; + + context.Champions.Add(chewie); + context.Champions.Add(yoda); + context.Champions.Add(ewok); + context.SaveChanges(); + } + + //prepares the database with one instance of the context + using (var context = new ChampionContext(options)) + { + string nameToFind = "ew"; + Assert.Equal(2, context.Champions.Where(n => n.Name.ToLower().Contains(nameToFind)).Count()); + nameToFind = "ewo"; + Assert.Equal(1, context.Champions.Where(n => n.Name.ToLower().Contains(nameToFind)).Count()); + var ewok = context.Champions.Where(n => n.Name.ToLower().Contains(nameToFind)).First(); + ewok.Name = "Wicket"; + context.SaveChanges(); + } + + //prepares the database with one instance of the context + using (var context = new ChampionContext(options)) + { + string nameToFind = "ew"; + Assert.Equal(1, context.Champions.Where(n => n.Name.ToLower().Contains(nameToFind)).Count()); + nameToFind = "wick"; + Assert.Equal(1, context.Champions.Where(n => n.Name.ToLower().Contains(nameToFind)).Count()); + } + } } } diff --git a/Sources/TestUnitaire/TestUnitaire.csproj b/Sources/TestUnitaire/TestUnitaire.csproj index e625409..c7b05a5 100644 --- a/Sources/TestUnitaire/TestUnitaire.csproj +++ b/Sources/TestUnitaire/TestUnitaire.csproj @@ -9,6 +9,8 @@ + + diff --git a/Sources/Tests/ConsoleTests/ConsoleTests.csproj b/Sources/Tests/ConsoleTests/ConsoleTests.csproj index 69373bc..557bdc5 100644 --- a/Sources/Tests/ConsoleTests/ConsoleTests.csproj +++ b/Sources/Tests/ConsoleTests/ConsoleTests.csproj @@ -16,6 +16,8 @@ + + all diff --git a/Sources/apiLOL/apiLOL.csproj b/Sources/apiLOL/apiLOL.csproj index f112330..82733d5 100644 --- a/Sources/apiLOL/apiLOL.csproj +++ b/Sources/apiLOL/apiLOL.csproj @@ -8,6 +8,8 @@ + + all