From b67d2b3478568cf5328bda7f1c387fbf0dfd1599 Mon Sep 17 00:00:00 2001 From: Maxence Lanone Date: Wed, 15 Mar 2023 17:55:13 +0100 Subject: [PATCH 1/7] :ambulance: application maui --- Sources/DbDatamanager/ChampionManager.cs | 1 + Sources/EntityFrameWorkLib/ChampionEntity.cs | 3 ++- .../EntityFrameWorkLib.csproj | 11 +++++----- Sources/EntityFrameWorkLib/RuneEntity.cs | 22 +++++++++++++++++++ .../ContentViews/ChampionClassSelector.xaml | 14 ++++++------ .../ChampionClassSelector.xaml.cs | 1 + .../ChampionClassToIconConverter.cs | 1 + Sources/LolApp/ViewModels/AddSkillVM.cs | 2 +- Sources/LolApp/ViewModels/ChampionClassVM.cs | 1 + Sources/LolApp/ViewModels/ChampionsPageVM.cs | 2 ++ Sources/Model/Champion.cs | 1 + Sources/Model/Model.csproj | 6 ----- Sources/Model/Rune.cs | 1 + Sources/Model/Skill.cs | 2 +- Sources/Shared/Shared.csproj | 6 +++++ Sources/Shared/enums/ChampionClass.cs | 2 +- Sources/Shared/enums/RuneFamily.cs | 2 +- Sources/Shared/enums/SkillType.cs | 2 +- Sources/StubLib/StubData.Champions.cs | 1 + Sources/StubLib/StubData.Runes.cs | 1 + Sources/Tests/ConsoleDB/ConsoleDB.csproj | 6 ++--- Sources/Tests/ConsoleTests/Program.cs | 1 + .../TestUnitaireLOL/TestUnitaireLOL.csproj | 2 +- Sources/ViewModels/ChampionVM.cs | 1 + Sources/ViewModels/ChampionsMgrVM.cs | 1 + Sources/ViewModels/EditableChampionVM.cs | 1 + Sources/ViewModels/SkillVM.cs | 1 + 27 files changed, 66 insertions(+), 29 deletions(-) create mode 100644 Sources/EntityFrameWorkLib/RuneEntity.cs diff --git a/Sources/DbDatamanager/ChampionManager.cs b/Sources/DbDatamanager/ChampionManager.cs index 5d74e3f..1f97fe9 100644 --- a/Sources/DbDatamanager/ChampionManager.cs +++ b/Sources/DbDatamanager/ChampionManager.cs @@ -1,6 +1,7 @@ using System; using EntityFrameWorkLib; using Model; +using Shared; namespace DbDatamanager { diff --git a/Sources/EntityFrameWorkLib/ChampionEntity.cs b/Sources/EntityFrameWorkLib/ChampionEntity.cs index fde9d2f..d724f42 100644 --- a/Sources/EntityFrameWorkLib/ChampionEntity.cs +++ b/Sources/EntityFrameWorkLib/ChampionEntity.cs @@ -1,6 +1,7 @@ using System; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; +using Shared; namespace EntityFrameWorkLib { @@ -13,7 +14,7 @@ namespace EntityFrameWorkLib public string Name { get; set; } public string Bio { get; set; } public string Icon { get; set; } - public ChampionClassEntity championClass { get; set; } + public ChampionClass championClass { get; set; } } } diff --git a/Sources/EntityFrameWorkLib/EntityFrameWorkLib.csproj b/Sources/EntityFrameWorkLib/EntityFrameWorkLib.csproj index eb89a7d..185b9c5 100644 --- a/Sources/EntityFrameWorkLib/EntityFrameWorkLib.csproj +++ b/Sources/EntityFrameWorkLib/EntityFrameWorkLib.csproj @@ -12,21 +12,20 @@ - - - - + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all - + diff --git a/Sources/EntityFrameWorkLib/RuneEntity.cs b/Sources/EntityFrameWorkLib/RuneEntity.cs new file mode 100644 index 0000000..6fca3d2 --- /dev/null +++ b/Sources/EntityFrameWorkLib/RuneEntity.cs @@ -0,0 +1,22 @@ +using System; +using System.ComponentModel.DataAnnotations; + +using Shared; + +namespace EntityFrameWorkLib +{ + public class RuneEntity + { + [Key] + [MaxLength(256)] + public string Name { get; set; } + + [Required] + [MaxLength(500)] + public string Description { get; set; } + + [Required] + public RuneFamily RuneFamily { get; set; } + } +} + diff --git a/Sources/LolApp/ContentViews/ChampionClassSelector.xaml b/Sources/LolApp/ContentViews/ChampionClassSelector.xaml index 6dc66e4..612c20f 100644 --- a/Sources/LolApp/ContentViews/ChampionClassSelector.xaml +++ b/Sources/LolApp/ContentViews/ChampionClassSelector.xaml @@ -1,17 +1,17 @@  - Assassin - Fighter - Mage - Marksman - Support - Tank + Assassin + Fighter + Mage + Marksman + Support + Tank diff --git a/Sources/Model/Model.csproj b/Sources/Model/Model.csproj index 1061ec5..7121f9c 100644 --- a/Sources/Model/Model.csproj +++ b/Sources/Model/Model.csproj @@ -6,12 +6,6 @@ enable - - - - - - diff --git a/Sources/Model/Rune.cs b/Sources/Model/Rune.cs index f63ad1c..8b6cdbb 100644 --- a/Sources/Model/Rune.cs +++ b/Sources/Model/Rune.cs @@ -1,4 +1,5 @@ using System; +using Shared; namespace Model { diff --git a/Sources/Model/Skill.cs b/Sources/Model/Skill.cs index 56d63df..4461984 100644 --- a/Sources/Model/Skill.cs +++ b/Sources/Model/Skill.cs @@ -1,5 +1,5 @@ using System; - +using Shared; namespace Model { public class Skill : IEquatable diff --git a/Sources/Shared/Shared.csproj b/Sources/Shared/Shared.csproj index bafd05b..cdcfd2d 100644 --- a/Sources/Shared/Shared.csproj +++ b/Sources/Shared/Shared.csproj @@ -6,4 +6,10 @@ enable + + + + + + diff --git a/Sources/Shared/enums/ChampionClass.cs b/Sources/Shared/enums/ChampionClass.cs index d169512..249ca02 100644 --- a/Sources/Shared/enums/ChampionClass.cs +++ b/Sources/Shared/enums/ChampionClass.cs @@ -1,5 +1,5 @@ using System; -namespace Model +namespace Shared { public enum ChampionClass { diff --git a/Sources/Shared/enums/RuneFamily.cs b/Sources/Shared/enums/RuneFamily.cs index 07a232c..4928100 100644 --- a/Sources/Shared/enums/RuneFamily.cs +++ b/Sources/Shared/enums/RuneFamily.cs @@ -1,5 +1,5 @@ using System; -namespace Model +namespace Shared { public enum RuneFamily { diff --git a/Sources/Shared/enums/SkillType.cs b/Sources/Shared/enums/SkillType.cs index d7fc8da..bad87d3 100644 --- a/Sources/Shared/enums/SkillType.cs +++ b/Sources/Shared/enums/SkillType.cs @@ -1,5 +1,5 @@ using System; -namespace Model +namespace Shared { public enum SkillType { diff --git a/Sources/StubLib/StubData.Champions.cs b/Sources/StubLib/StubData.Champions.cs index ad19275..8ed1220 100644 --- a/Sources/StubLib/StubData.Champions.cs +++ b/Sources/StubLib/StubData.Champions.cs @@ -1,5 +1,6 @@ using System; using Model; +using Shared; namespace StubLib { diff --git a/Sources/StubLib/StubData.Runes.cs b/Sources/StubLib/StubData.Runes.cs index f0e8802..32fce54 100644 --- a/Sources/StubLib/StubData.Runes.cs +++ b/Sources/StubLib/StubData.Runes.cs @@ -1,5 +1,6 @@ using System; using Model; +using Shared; namespace StubLib { diff --git a/Sources/Tests/ConsoleDB/ConsoleDB.csproj b/Sources/Tests/ConsoleDB/ConsoleDB.csproj index fa2a4bd..f628bc5 100644 --- a/Sources/Tests/ConsoleDB/ConsoleDB.csproj +++ b/Sources/Tests/ConsoleDB/ConsoleDB.csproj @@ -14,9 +14,9 @@ - - - + + + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/Sources/Tests/ConsoleTests/Program.cs b/Sources/Tests/ConsoleTests/Program.cs index 28dc26b..a886d2c 100644 --- a/Sources/Tests/ConsoleTests/Program.cs +++ b/Sources/Tests/ConsoleTests/Program.cs @@ -4,6 +4,7 @@ using Microsoft.Extensions.DependencyInjection; using Model; using StubLib; using static System.Console; +using Shared; namespace ConsoleTests { diff --git a/Sources/Tests/TestUnitaireLOL/TestUnitaireLOL.csproj b/Sources/Tests/TestUnitaireLOL/TestUnitaireLOL.csproj index cb2bdfc..0fc8bb0 100644 --- a/Sources/Tests/TestUnitaireLOL/TestUnitaireLOL.csproj +++ b/Sources/Tests/TestUnitaireLOL/TestUnitaireLOL.csproj @@ -19,7 +19,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive all - + diff --git a/Sources/ViewModels/ChampionVM.cs b/Sources/ViewModels/ChampionVM.cs index bdd1e7f..f55d05a 100644 --- a/Sources/ViewModels/ChampionVM.cs +++ b/Sources/ViewModels/ChampionVM.cs @@ -3,6 +3,7 @@ using CommunityToolkit.Mvvm.ComponentModel; using Model; using Microsoft.Maui.Controls; using System.Collections.ObjectModel; +using Shared; namespace ViewModels diff --git a/Sources/ViewModels/ChampionsMgrVM.cs b/Sources/ViewModels/ChampionsMgrVM.cs index 06e5d67..6fb5ae3 100644 --- a/Sources/ViewModels/ChampionsMgrVM.cs +++ b/Sources/ViewModels/ChampionsMgrVM.cs @@ -6,6 +6,7 @@ using System.Collections.ObjectModel; using CommunityToolkit.Mvvm.Input; using System.Data.SqlTypes; using System.Reflection; +using Shared; namespace ViewModels; diff --git a/Sources/ViewModels/EditableChampionVM.cs b/Sources/ViewModels/EditableChampionVM.cs index 2db038b..63b5a17 100644 --- a/Sources/ViewModels/EditableChampionVM.cs +++ b/Sources/ViewModels/EditableChampionVM.cs @@ -3,6 +3,7 @@ using System.Collections.ObjectModel; using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; using Model; +using Shared; namespace ViewModels { diff --git a/Sources/ViewModels/SkillVM.cs b/Sources/ViewModels/SkillVM.cs index c9c2ca1..1c5c9c9 100644 --- a/Sources/ViewModels/SkillVM.cs +++ b/Sources/ViewModels/SkillVM.cs @@ -1,6 +1,7 @@ using System; using CommunityToolkit.Mvvm.ComponentModel; using Model; +using Shared; namespace ViewModels { From 1c428ee70baa44c90d85d39c7f98041146c5c9bf Mon Sep 17 00:00:00 2001 From: Maxence Lanone Date: Fri, 17 Mar 2023 08:35:49 +0100 Subject: [PATCH 2/7] add SkillEntity + LargeImageEntity + RuneEntity + relation oneToOne entre image et champion --- Sources/EntityFrameWorkLib/ChampionEntity.cs | 14 ++++-- .../EntityFrameWorkLib/LargeImageEntity.cs | 21 +++++++++ Sources/EntityFrameWorkLib/LolContext.cs | 45 +++++++++++-------- Sources/EntityFrameWorkLib/SkillEntity.cs | 21 +++++++++ Sources/EntityFrameWorkLib/Skin.cs | 12 ----- Sources/EntityFrameWorkLib/SkinEntity.cs | 22 +++++++++ 6 files changed, 101 insertions(+), 34 deletions(-) create mode 100644 Sources/EntityFrameWorkLib/LargeImageEntity.cs create mode 100644 Sources/EntityFrameWorkLib/SkillEntity.cs delete mode 100644 Sources/EntityFrameWorkLib/Skin.cs create mode 100644 Sources/EntityFrameWorkLib/SkinEntity.cs diff --git a/Sources/EntityFrameWorkLib/ChampionEntity.cs b/Sources/EntityFrameWorkLib/ChampionEntity.cs index d724f42..b3514c7 100644 --- a/Sources/EntityFrameWorkLib/ChampionEntity.cs +++ b/Sources/EntityFrameWorkLib/ChampionEntity.cs @@ -11,10 +11,18 @@ namespace EntityFrameWorkLib [Key] [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int UniqueId { get; set; } - public string Name { get; set; } + public string Name { get; set; } + + [Required] + [MaxLength(256)] public string Bio { get; set; } + public string Icon { get; set; } - public ChampionClass championClass { get; set; } - } + + [Required] + public ChampionClass Class { get; set; } + + public LargeImageEntity? LargeImageEntity { get; set; } + } } diff --git a/Sources/EntityFrameWorkLib/LargeImageEntity.cs b/Sources/EntityFrameWorkLib/LargeImageEntity.cs new file mode 100644 index 0000000..26d6886 --- /dev/null +++ b/Sources/EntityFrameWorkLib/LargeImageEntity.cs @@ -0,0 +1,21 @@ +using System; +using System.ComponentModel.DataAnnotations; + +namespace EntityFrameWorkLib +{ + public class LargeImageEntity + { + [Key] + public Guid Id { get; set; } + + [Required] + public string Base64 { get; set; } + + [Required] + public int championId { get; set; } + + [Required] + public ChampionEntity champion { get; set; } + } +} + diff --git a/Sources/EntityFrameWorkLib/LolContext.cs b/Sources/EntityFrameWorkLib/LolContext.cs index 89f6651..8d2869c 100644 --- a/Sources/EntityFrameWorkLib/LolContext.cs +++ b/Sources/EntityFrameWorkLib/LolContext.cs @@ -6,32 +6,39 @@ namespace EntityFrameWorkLib { public class LolContext : DbContext { - public DbSet Champions { get; set; } - - public LolContext() { } - public LolContext(DbContextOptions options) - :base(options) - { } - protected override void OnConfiguring(DbContextOptionsBuilder options) - { - if (!options.IsConfigured) - { + public DbSet Champions { get; set; } + public DbSet Skill { get; set; } + public DbSet LargeImage { get; set; } + + public LolContext() { } + public LolContext(DbContextOptions options) + : base(options) + { } + protected override void OnConfiguring(DbContextOptionsBuilder options) + { + if (!options.IsConfigured) + { base.OnConfiguring(options.UseSqlite($"DataSource=projet.Champions.db")); } } - protected override void OnModelCreating(ModelBuilder modelBuilder) - { - //Définition de la clé primaire de ChampionEntity - modelBuilder.Entity().HasKey(n => n.UniqueId); - //Définition du mode de generation de la clé : génération à l'insertion - modelBuilder.Entity().Property(n => n.UniqueId).ValueGeneratedOnAdd(); + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + //Définition de la clé primaire de ChampionEntity + modelBuilder.Entity().HasKey(n => n.UniqueId); + //Définition du mode de generation de la clé : génération à l'insertion + modelBuilder.Entity().Property(n => n.UniqueId).ValueGeneratedOnAdd(); + + modelBuilder.Entity() + .HasOne(c => c.LargeImageEntity) + .WithOne(li => li.champion) + .HasForeignKey(li => li.championId); - base.OnModelCreating(modelBuilder); + base.OnModelCreating(modelBuilder); } - - } + + } } diff --git a/Sources/EntityFrameWorkLib/SkillEntity.cs b/Sources/EntityFrameWorkLib/SkillEntity.cs new file mode 100644 index 0000000..e0a15e2 --- /dev/null +++ b/Sources/EntityFrameWorkLib/SkillEntity.cs @@ -0,0 +1,21 @@ +using System; +using Shared; +using System.ComponentModel.DataAnnotations; + +namespace EntityFrameWorkLib +{ + public class SkillEntity + { + [Key] + [MaxLength(256)] + public string Name { get; set; } + + [Required] + [MaxLength(500)] + public string Description { get; set; } + + [Required] + public SkillType SkillType { get; set; } + } +} + diff --git a/Sources/EntityFrameWorkLib/Skin.cs b/Sources/EntityFrameWorkLib/Skin.cs deleted file mode 100644 index 6735e2d..0000000 --- a/Sources/EntityFrameWorkLib/Skin.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -namespace EntityFrameWorkLib -{ - public class Skin - { - public string Name { get; set; } - public string Description { get; set; } - public string Icon { get; set; } - public float Price { get; set; } - } -} - diff --git a/Sources/EntityFrameWorkLib/SkinEntity.cs b/Sources/EntityFrameWorkLib/SkinEntity.cs new file mode 100644 index 0000000..6be476d --- /dev/null +++ b/Sources/EntityFrameWorkLib/SkinEntity.cs @@ -0,0 +1,22 @@ +using System; +using System.ComponentModel.DataAnnotations; + +namespace EntityFrameWorkLib +{ + public class SkinEntity + { + [Key] + [MaxLength(256)] + public string Name { get; set; } + + [Required] + [MaxLength(500)] + public string Description { get; set; } + + public string Icon { get; set; } + + [Required] + public float Price { get; set; } + } +} + From 175b8398dc3636418321524d0c56a8a4a023c1bd Mon Sep 17 00:00:00 2001 From: Maxence Lanone Date: Fri, 17 Mar 2023 08:44:29 +0100 Subject: [PATCH 3/7] :construction_worker: ajout solution pour build ci --- Sources/LeagueOfLegends_CI.sln | 98 ++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 Sources/LeagueOfLegends_CI.sln diff --git a/Sources/LeagueOfLegends_CI.sln b/Sources/LeagueOfLegends_CI.sln new file mode 100644 index 0000000..d8877d5 --- /dev/null +++ b/Sources/LeagueOfLegends_CI.sln @@ -0,0 +1,98 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 25.0.1704.2 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Model", "Model\Model.csproj", "{2960F9BA-49DE-494D-92E3-CE5A794BA1A9}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{C76D0C23-1FFA-4963-93CD-E12BD643F030}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleTests", "Tests\ConsoleTests\ConsoleTests.csproj", "{1889FA6E-B7C6-416E-8628-9449FB9070B9}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shared", "Shared\Shared.csproj", "{3B720C0C-53FE-4642-A2DB-87FD8634CD74}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Stub", "Stub", "{2C607793-B163-4731-A4D1-AFE8A7C4C170}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StubLib", "StubLib\StubLib.csproj", "{B01D7EF2-2D64-409A-A29A-61FB7BB7A9DB}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleDB", "Tests\ConsoleDB\ConsoleDB.csproj", "{3E16421B-7372-477D-A25E-8249D5203A1E}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestUnitaireLOL", "Tests\TestUnitaireLOL\TestUnitaireLOL.csproj", "{F4473EB6-6CD7-4A73-89BC-82C247A23412}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DbDatamanager", "DbDatamanager\DbDatamanager.csproj", "{B316E0A6-491B-45D6-A4E5-78AB662ABE1B}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EntityFrameWorkLib", "EntityFrameWorkLib\EntityFrameWorkLib.csproj", "{C78F459C-A1CE-4978-A08D-73C6BDB4094C}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebApiLol", "WebApiLol\WebApiLol.csproj", "{DAE3B5A2-8904-43AE-8459-ED64C3366FDF}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{73142960-0D40-4766-973B-37094F4BD879}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleTestapi", "Tests\ConsoleTestapi\ConsoleTestapi.csproj", "{EA884D64-6425-46FB-BA25-E2EB8FE6BECE}" +EndProject +Project("{E53339B2-1760-4266-BCC7-CA923CBCF16C}") = "docker-compose", "docker-compose.dcproj", "{1B81A541-7D10-4603-B5A2-94108954D831}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {2960F9BA-49DE-494D-92E3-CE5A794BA1A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2960F9BA-49DE-494D-92E3-CE5A794BA1A9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2960F9BA-49DE-494D-92E3-CE5A794BA1A9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2960F9BA-49DE-494D-92E3-CE5A794BA1A9}.Release|Any CPU.Build.0 = Release|Any CPU + {1889FA6E-B7C6-416E-8628-9449FB9070B9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1889FA6E-B7C6-416E-8628-9449FB9070B9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1889FA6E-B7C6-416E-8628-9449FB9070B9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1889FA6E-B7C6-416E-8628-9449FB9070B9}.Release|Any CPU.Build.0 = Release|Any CPU + {3B720C0C-53FE-4642-A2DB-87FD8634CD74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3B720C0C-53FE-4642-A2DB-87FD8634CD74}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3B720C0C-53FE-4642-A2DB-87FD8634CD74}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3B720C0C-53FE-4642-A2DB-87FD8634CD74}.Release|Any CPU.Build.0 = Release|Any CPU + {B01D7EF2-2D64-409A-A29A-61FB7BB7A9DB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B01D7EF2-2D64-409A-A29A-61FB7BB7A9DB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B01D7EF2-2D64-409A-A29A-61FB7BB7A9DB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B01D7EF2-2D64-409A-A29A-61FB7BB7A9DB}.Release|Any CPU.Build.0 = Release|Any CPU + {3E16421B-7372-477D-A25E-8249D5203A1E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3E16421B-7372-477D-A25E-8249D5203A1E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3E16421B-7372-477D-A25E-8249D5203A1E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3E16421B-7372-477D-A25E-8249D5203A1E}.Release|Any CPU.Build.0 = Release|Any CPU + {F4473EB6-6CD7-4A73-89BC-82C247A23412}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F4473EB6-6CD7-4A73-89BC-82C247A23412}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F4473EB6-6CD7-4A73-89BC-82C247A23412}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F4473EB6-6CD7-4A73-89BC-82C247A23412}.Release|Any CPU.Build.0 = Release|Any CPU + {B316E0A6-491B-45D6-A4E5-78AB662ABE1B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B316E0A6-491B-45D6-A4E5-78AB662ABE1B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B316E0A6-491B-45D6-A4E5-78AB662ABE1B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B316E0A6-491B-45D6-A4E5-78AB662ABE1B}.Release|Any CPU.Build.0 = Release|Any CPU + {C78F459C-A1CE-4978-A08D-73C6BDB4094C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C78F459C-A1CE-4978-A08D-73C6BDB4094C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C78F459C-A1CE-4978-A08D-73C6BDB4094C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C78F459C-A1CE-4978-A08D-73C6BDB4094C}.Release|Any CPU.Build.0 = Release|Any CPU + {DAE3B5A2-8904-43AE-8459-ED64C3366FDF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DAE3B5A2-8904-43AE-8459-ED64C3366FDF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DAE3B5A2-8904-43AE-8459-ED64C3366FDF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DAE3B5A2-8904-43AE-8459-ED64C3366FDF}.Release|Any CPU.Build.0 = Release|Any CPU + {EA884D64-6425-46FB-BA25-E2EB8FE6BECE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EA884D64-6425-46FB-BA25-E2EB8FE6BECE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EA884D64-6425-46FB-BA25-E2EB8FE6BECE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EA884D64-6425-46FB-BA25-E2EB8FE6BECE}.Release|Any CPU.Build.0 = Release|Any CPU + {1B81A541-7D10-4603-B5A2-94108954D831}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1B81A541-7D10-4603-B5A2-94108954D831}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1B81A541-7D10-4603-B5A2-94108954D831}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1B81A541-7D10-4603-B5A2-94108954D831}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {92F3083D-793F-4552-8A9A-0AD6534159C9} + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {1889FA6E-B7C6-416E-8628-9449FB9070B9} = {C76D0C23-1FFA-4963-93CD-E12BD643F030} + {B01D7EF2-2D64-409A-A29A-61FB7BB7A9DB} = {2C607793-B163-4731-A4D1-AFE8A7C4C170} + {3E16421B-7372-477D-A25E-8249D5203A1E} = {C76D0C23-1FFA-4963-93CD-E12BD643F030} + {F4473EB6-6CD7-4A73-89BC-82C247A23412} = {C76D0C23-1FFA-4963-93CD-E12BD643F030} + {EA884D64-6425-46FB-BA25-E2EB8FE6BECE} = {C76D0C23-1FFA-4963-93CD-E12BD643F030} + EndGlobalSection +EndGlobal From c77a3d5c214f44e830bb6438e59b1aecf7172fc0 Mon Sep 17 00:00:00 2001 From: Maxence LANONE Date: Fri, 17 Mar 2023 08:46:03 +0100 Subject: [PATCH 4/7] =?UTF-8?q?Mise=20=C3=A0=20jour=20de=20'.drone.yml'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .drone.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.drone.yml b/.drone.yml index 7543512..f60d9f0 100644 --- a/.drone.yml +++ b/.drone.yml @@ -12,28 +12,28 @@ steps: image: mcr.microsoft.com/dotnet/sdk:7.0 commands: - cd Sources/ - - dotnet restore LeagueOfLegends.sln - - dotnet build LeagueOfLegends.sln -c Release --no-restore - - dotnet publish LeagueOfLegends.sln -c Release --no-restore -o CI_PROJECT_DIR/build/release + - dotnet restore LeagueOfLegends_CI.sln + - dotnet build LeagueOfLegends_CI.sln -c Release --no-restore + - dotnet publish LeagueOfLegends_CI.sln -c Release --no-restore -o CI_PROJECT_DIR/build/release - name: tests image: mcr.microsoft.com/dotnet/sdk:7.0 commands: - cd Sources/ - - dotnet restore LeagueOfLegends.sln - - dotnet test LeagueOfLegends.sln --no-restore + - dotnet restore LeagueOfLegends_CI.sln + - dotnet test LeagueOfLegends_CI.sln --no-restore depends_on: [build] - name: code-analysis image: hub.codefirst.iut.uca.fr/marc.chevaldonne/codefirst-dronesonarplugin-dotnet7 commands: - cd Sources/ - - dotnet restore LeagueOfLegends.sln + - dotnet restore LeagueOfLegends_CI.sln - dotnet sonarscanner begin /k:EfCore_Lol_S4 /d:sonar.host.url="https://codefirst.iut.uca.fr/sonar" /d:sonar.coverage.exclusions="Tests/**" /d:sonar.coverageReportPaths="coveragereport/SonarQube.xml" /d:sonar.login=$${PLUGIN_SONAR_TOKEN} - - dotnet build LeagueOfLegends.sln -c Release --no-restore - - dotnet test LeagueOfLegends.sln --logger trx --no-restore /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura --collect "XPlat Code Coverage" + - dotnet build LeagueOfLegends_CI.sln -c Release --no-restore + - dotnet test LeagueOfLegends_CI.sln --logger trx --no-restore /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura --collect "XPlat Code Coverage" - reportgenerator -reports:"**/coverage.cobertura.xml" -reporttypes:SonarQube -targetdir:"coveragereport" - - dotnet publish LeagueOfLegends.sln -c Release --no-restore -o $CI_PROJECT_DIR/build/release + - dotnet publish LeagueOfLegends_CI.sln -c Release --no-restore -o $CI_PROJECT_DIR/build/release - dotnet sonarscanner end /d:sonar.login=$${PLUGIN_SONAR_TOKEN} secrets: [ SECRET_SONAR_LOGIN ] settings: From 8268a713fd79503c030d528a8ed4d6ca7e0a4866 Mon Sep 17 00:00:00 2001 From: Maxence Lanone Date: Sun, 26 Mar 2023 21:36:38 +0200 Subject: [PATCH 5/7] ajout test unit add in memory en inline data + modif champ en fact --- .../20230308120111_MyMigration.Designer.cs | 50 -------- .../Migrations/20230308120111_MyMigration.cs | 37 ------ .../20230317075439_MyMigration.Designer.cs | 108 ++++++++++++++++++ .../Migrations/20230317075439_MyMigration.cs | 82 +++++++++++++ .../Migrations/LolContextModelSnapshot.cs | 66 ++++++++++- Sources/EntityFrameWorkLib/RunePageEntity.cs | 20 ++++ Sources/Tests/ConsoleDB/Program.cs | 38 ++++-- Sources/Tests/ConsoleDB/projet.Champions.db | Bin 0 -> 45056 bytes Sources/Tests/TestUnitaireLOL/TestEf.cs | 60 ++++++++++ .../TestUnitaireLOL/UnitTestDbDataManager.cs | 27 ++++- Sources/WebApiLol/WebApiLol.csproj | 2 +- 11 files changed, 385 insertions(+), 105 deletions(-) delete mode 100644 Sources/EntityFrameWorkLib/Migrations/20230308120111_MyMigration.Designer.cs delete mode 100644 Sources/EntityFrameWorkLib/Migrations/20230308120111_MyMigration.cs create mode 100644 Sources/EntityFrameWorkLib/Migrations/20230317075439_MyMigration.Designer.cs create mode 100644 Sources/EntityFrameWorkLib/Migrations/20230317075439_MyMigration.cs create mode 100644 Sources/EntityFrameWorkLib/RunePageEntity.cs create mode 100644 Sources/Tests/TestUnitaireLOL/TestEf.cs diff --git a/Sources/EntityFrameWorkLib/Migrations/20230308120111_MyMigration.Designer.cs b/Sources/EntityFrameWorkLib/Migrations/20230308120111_MyMigration.Designer.cs deleted file mode 100644 index 7be9ec3..0000000 --- a/Sources/EntityFrameWorkLib/Migrations/20230308120111_MyMigration.Designer.cs +++ /dev/null @@ -1,50 +0,0 @@ -// -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("20230308120111_MyMigration")] - partial class MyMigration - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "7.0.3"); - - modelBuilder.Entity("EntityFrameWorkLib.ChampionEntity", b => - { - b.Property("UniqueId") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Bio") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Icon") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Name") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("championClass") - .HasColumnType("INTEGER"); - - b.HasKey("UniqueId"); - - b.ToTable("Champions"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Sources/EntityFrameWorkLib/Migrations/20230308120111_MyMigration.cs b/Sources/EntityFrameWorkLib/Migrations/20230308120111_MyMigration.cs deleted file mode 100644 index f82da3b..0000000 --- a/Sources/EntityFrameWorkLib/Migrations/20230308120111_MyMigration.cs +++ /dev/null @@ -1,37 +0,0 @@ -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", nullable: false), - Icon = table.Column(type: "TEXT", nullable: false), - championClass = table.Column(type: "INTEGER", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Champions", x => x.UniqueId); - }); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "Champions"); - } - } -} diff --git a/Sources/EntityFrameWorkLib/Migrations/20230317075439_MyMigration.Designer.cs b/Sources/EntityFrameWorkLib/Migrations/20230317075439_MyMigration.Designer.cs new file mode 100644 index 0000000..026aaa2 --- /dev/null +++ b/Sources/EntityFrameWorkLib/Migrations/20230317075439_MyMigration.Designer.cs @@ -0,0 +1,108 @@ +// +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 new file mode 100644 index 0000000..0fd9526 --- /dev/null +++ b/Sources/EntityFrameWorkLib/Migrations/20230317075439_MyMigration.cs @@ -0,0 +1,82 @@ +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 index 86cbf85..a9a3587 100644 --- a/Sources/EntityFrameWorkLib/Migrations/LolContextModelSnapshot.cs +++ b/Sources/EntityFrameWorkLib/Migrations/LolContextModelSnapshot.cs @@ -1,4 +1,5 @@ // +using System; using EntityFrameWorkLib; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; @@ -14,7 +15,7 @@ namespace EntityFrameWorkLib.Migrations protected override void BuildModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "7.0.3"); + modelBuilder.HasAnnotation("ProductVersion", "7.0.4"); modelBuilder.Entity("EntityFrameWorkLib.ChampionEntity", b => { @@ -24,8 +25,12 @@ namespace EntityFrameWorkLib.Migrations b.Property("Bio") .IsRequired() + .HasMaxLength(256) .HasColumnType("TEXT"); + b.Property("Class") + .HasColumnType("INTEGER"); + b.Property("Icon") .IsRequired() .HasColumnType("TEXT"); @@ -34,13 +39,66 @@ namespace EntityFrameWorkLib.Migrations .IsRequired() .HasColumnType("TEXT"); - b.Property("championClass") - .HasColumnType("INTEGER"); - 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/RunePageEntity.cs b/Sources/EntityFrameWorkLib/RunePageEntity.cs new file mode 100644 index 0000000..bd2affa --- /dev/null +++ b/Sources/EntityFrameWorkLib/RunePageEntity.cs @@ -0,0 +1,20 @@ +using System; +namespace EntityFrameWorkLib +{ + public class RunePageEntity + { + public int Id { get; set; } + public String Name { get; set; } + } + + public enum Category + { + Major, + Minor1, + Minor2, + Minor3, + OtherMinor1, + OtherMinor2 + } +} + diff --git a/Sources/Tests/ConsoleDB/Program.cs b/Sources/Tests/ConsoleDB/Program.cs index c9fdc38..8f0a4b9 100644 --- a/Sources/Tests/ConsoleDB/Program.cs +++ b/Sources/Tests/ConsoleDB/Program.cs @@ -2,31 +2,51 @@ using EntityFrameWorkLib; using Microsoft.EntityFrameworkCore; +using Shared; + +SkillEntity skill1 = new SkillEntity +{ + Name = "skill1", + Description = "Cette description est celle du skill1", + SkillType = SkillType.Basic, +}; + +LargeImageEntity largeImage = new LargeImageEntity +{ + Base64 = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJAAAACQCAYAAADnRuK4AAAAAXNSR0IArs4c6QAAADhlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAAqACAAQAAAABAAAAkKADAAQAAAABAAAAkAAAAAAc9yiyAAAV90lEQVR4Ae1dC3xU1Zn/33lPJhMSQoDwCA9BI6DUB2JRiqiooFYWf9rV7tatu3VXXe36aNfd/W3727ZW++tKbbetutZVi1rdn67uro9SsYLycIWAT1AeASQQJIQkJJnJvPf/3TAQQ0KSuXfu3Jk5R4ebuXfOuef8z/9+33e+851ztRQTVFIIZIiAI8N8KptCQEdAEUgRwRACikCG4FOZFYEUBwwhoAhkCD6VWRFIccAQAopAhuBTmRWBFAcMIaAIZAg+lVkRSHHAEAKKQIbgU5kVgRQHDCGgCGQIPpVZEUhxwBACikCG4FOZFYEUBwwhoAhkCD6VWRFIccAQAopAhuBTmRWBFAcMIaAIZAg+lVkRSHHAEAKKQIbgU5kVgRQHDCGgCGQIPpXZpSAAkgf2I9l0AInWFqRaDyHV1YVUNALEYkilktCchMnrhcMfgBYMwlFeAceIUXCOGg24ihvC4mt9NIrY9k8R+3AT4jt3ILm3AcnOdiAcRjJC0kS6gEQcqUSCzEqCDAIcFNROJzQhi9sDzefjpwRaSQkcVaPgmjwF7ukz4ao9FY7SsqJ6JrVCXxufIilSh1sR/WAjou+sQezjD/i9DalYtFvCkCiapoH/8CN93+PYmwrpbQTkyI9sK6A5+HsXSeXxAH4/3KdMg3f2HLjPOheO4ZXQ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knZGGYT3AX19TRgLJqMlLA1giFkvdJRjmDWKEfzhGMXIxkMU9Gvuqq93OKQLZrUfyrD72nurNMzCLsbqKQMXY6ya2WRHIRDCLsShFoGLsdRPbrAhkIpjFWJQiUDH2uoltVgQyEcxiLEoRqBh73cQ2KwKZCGYxFqUIVIy9bmKbFYFMBLMYi1IEKsZeN7HNikAmglmMRSkCFWOvm9hmRSATwSzGohSBirHXTWyzIpCJYBZjUYpAxdjrJrZZEchEMIuxKEWgYux1E9usCGQimMVYlCJQMfa6iW1WBDIRzGIsShGoGHvdxDYrApkIZjEW9f+b81XHPCcvvwAAAABJRU5ErkJggg==" +}; ChampionEntity jax = new ChampionEntity { Name = "jax", Icon = "icon jax", - Bio = "test bio jax" + Bio = "test bio jax", + Class = ChampionClass.Fighter, + LargeImageEntity = largeImage }; ChampionEntity darius = new ChampionEntity { Name = "darius", Icon = "icon darius", - Bio = "test bio darius" + Bio = "test bio darius", + Class = ChampionClass.Assassin, }; ChampionEntity champions = new ChampionEntity { Name = "toto", Icon = "icon", - Bio = "test bio champion" + Bio = "test bio champion", + Class = ChampionClass.Marksman, }; -using (var context= new LolContext()) + +using (var context = new LolContext()) { Console.WriteLine("Create and Insert new Champion"); - context.Add(champions); - context.Add(darius); - context.Add(jax); - await context.SaveChangesAsync(); -} + context.Skill.AddAsync(skill1); + context.LargeImage.AddAsync(largeImage); + context.Champions.AddAsync(champions); + context.Champions.AddAsync(darius); + context.Champions.AddAsync(jax); + await context.SaveChangesAsync(); +} \ No newline at end of file diff --git a/Sources/Tests/ConsoleDB/projet.Champions.db b/Sources/Tests/ConsoleDB/projet.Champions.db index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..27306d01c4fba6ae4ffd31f44fe93e157d9d6390 100644 GIT binary patch literal 45056 zcmeI5$qwYmnV758t!j18$YsD7G<1+vYQruqzwV)mfXoCnOqH{!8N%hnaMRt z_@c4lXYe~1J{U0Ii{D{R2IgSEfZt#)g8}AZR&}d4b$fjAK^jITlfhst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100644 index 0000000..90a7880 --- /dev/null +++ b/Sources/Tests/TestUnitaireLOL/TestEf.cs @@ -0,0 +1,60 @@ +using System; +using EntityFrameWorkLib; +using Microsoft.Data.Sqlite; +using Microsoft.EntityFrameworkCore; +using Model; +using Shared; + +namespace TestUnitaireLOL +{ + public class TestsData + { + public IEnumerable Data_TestAddItem() + { + yield return new object[] + { + 1, + new ChampionEntity[] + { + new ChampionEntity + { + Name = "jax", + Icon = "icon jax", + Bio = "test bio jax", + Class = ChampionClass.Fighter, + LargeImageEntity = new LargeImageEntity(){Base64 = "tevhdfvsdefefef"} + }, + new ChampionEntity + { + Name = "jax2", + Icon = "icon jax2", + Bio = "test bio jax2", + Class = ChampionClass.Assassin, + LargeImageEntity = new LargeImageEntity(){Base64 = "tevhdfvsdfefefe"} + }, + new ChampionEntity + { + Name = "jax3", + Icon = "icon jax3", + Bio = "test bio jax3", + Class = ChampionClass.Tank, + LargeImageEntity = new LargeImageEntity(){Base64 = "tevhdfvsdfkhefef"} + } + }, + new ChampionEntity[] + { + new ChampionEntity() + { + Name = "jax4", + Icon = "icon jax4", + Bio = "test bio jax4", + Class = ChampionClass.Marksman, + LargeImageEntity = new LargeImageEntity(){Base64 = "tevhdfvsdfkhvfdfdf"} + } + } + }; + + } + } +} + diff --git a/Sources/Tests/TestUnitaireLOL/UnitTestDbDataManager.cs b/Sources/Tests/TestUnitaireLOL/UnitTestDbDataManager.cs index b5b971c..57ad20f 100644 --- a/Sources/Tests/TestUnitaireLOL/UnitTestDbDataManager.cs +++ b/Sources/Tests/TestUnitaireLOL/UnitTestDbDataManager.cs @@ -1,11 +1,30 @@ using System; +using EntityFrameWorkLib; +using Microsoft.Data.Sqlite; +using Microsoft.EntityFrameworkCore; + namespace TestUnitaireLOL { public class UnitTestDbDataManager { - public UnitTestDbDataManager() - { - } - } + + public void Test_Data_AddItem(int expectedResult, + IEnumerable expectedChampions, + IEnumerable expectedChampionsAdded, + params ChampionEntity[] championsToAdd) + { + var connexion = new SqliteConnection("DataSource=:memory:"); + connexion.Open(); + + var options = new DbContextOptionsBuilder() + .UseSqlite(connexion) + .Options; + + using (var context = new LolContext()) + { + + } + } + } } diff --git a/Sources/WebApiLol/WebApiLol.csproj b/Sources/WebApiLol/WebApiLol.csproj index 12d51ee..6a32b1f 100644 --- a/Sources/WebApiLol/WebApiLol.csproj +++ b/Sources/WebApiLol/WebApiLol.csproj @@ -11,7 +11,7 @@ - + From 9ba8bb4c00aa9170971b2761a9ed9527a18693b3 Mon Sep 17 00:00:00 2001 From: Maxence Lanone Date: Sun, 26 Mar 2023 23:36:25 +0200 Subject: [PATCH 6/7] ajout test unit for api (not op) --- .../20230317075439_MyMigration.Designer.cs | 108 ---------- .../Migrations/20230317075439_MyMigration.cs | 82 ------- .../Migrations/LolContextModelSnapshot.cs | 105 --------- Sources/Tests/TestUnitaireLOL/TestAPI.cs | 40 ++++ Sources/Tests/TestUnitaireLOL/TestEf.cs | 200 ++++++++++++++---- .../TestUnitaireLOL/TestUnitaireLOL.csproj | 6 + .../Tests/TestUnitaireLOL/projet.Champions.db | Bin 0 -> 77824 bytes .../TestUnitaireLOL/projet.Champions.db-shm | Bin 0 -> 32768 bytes .../TestUnitaireLOL/projet.Champions.db-wal | 0 9 files changed, 205 insertions(+), 336 deletions(-) delete mode 100644 Sources/EntityFrameWorkLib/Migrations/20230317075439_MyMigration.Designer.cs delete mode 100644 Sources/EntityFrameWorkLib/Migrations/20230317075439_MyMigration.cs delete mode 100644 Sources/EntityFrameWorkLib/Migrations/LolContextModelSnapshot.cs create mode 100644 Sources/Tests/TestUnitaireLOL/TestAPI.cs create mode 100644 Sources/Tests/TestUnitaireLOL/projet.Champions.db create mode 100644 Sources/Tests/TestUnitaireLOL/projet.Champions.db-shm create mode 100644 Sources/Tests/TestUnitaireLOL/projet.Champions.db-wal 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 Data_TestAddItem() + //[Theory] + + //[InlineData(0, "Zeus", "Dieu de la foudre", true)] + //[InlineData(10, "Hades", "Dieu des enfers", true)] + //[InlineData(1, "Aphrodite", "Déesse de l'amour", true)] + ////[InlineData(10, "AresAresAresAresAresAresAresAresAresAres", + //// "Dieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerre" + + //// "Dieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerre" + + //// "Dieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerre", false)] + //public async Task TestAddChampionInMemory(int id, String name, String bio, bool expected) + //{ + // var connection = new SqliteConnection("DataSource=:memory:"); + // connection.Open(); + + // var options = new DbContextOptionsBuilder() + // .UseSqlite(connection) + // .Options; + + // using (var context = new LolContext(options)) + // { + // await context.Database.EnsureCreatedAsync(); + // SkinEntity black = new SkinEntity { Name = "Black", Description = "Black skin", Icon = "black.png", Price = 0.99f }; + // SkinEntity white = new SkinEntity { Name = "White", Description = "White skin", Icon = "white.png", Price = 150.99f }; + // SkinEntity green = new SkinEntity { Name = "Green", Description = "Green skin", Icon = "green.png", Price = 4.99f }; + + // RunePageEntity runePage1 = new RunePageEntity { Id = 1, Name = "runepage1" }; + + // var Dieu = new ChampionEntity + // { + // UniqueId = id, + // Name = name, + // Bio = bio, + // Skins = new Collection(new List { black, white, green }), + // ListRunePages = new Collection(new List { { runePage1 } }) + // }; + + // ChampionEntity found = await context.Champions.SingleOrDefaultAsync(c => c.Name == "Zeus"); + // Assert.Null(found); + + // await context.Champions.AddAsync(Dieu); + // await context.SaveChangesAsync(); + + // found = await context.Champions.SingleOrDefaultAsync(c => c.Name == name); + // Assert.NotNull(found); + + // Assert.Equal(1, await context.Champions.CountAsync()); + // Assert.Equal(name, found.Name); + // Assert.Equal(3, found.Skins.Count); + // Assert.Equal(1, found.ListRunePages.Count); + + // // Test if the max length of the name is respected (30) and the max length of the bio is respected (256) + // if (expected) + // { + // Assert.True(found.Name.Length <= 30); + // Assert.True(found.Bio.Length <= 256); + // } + // else + // { + // Assert.False(found.Name.Length <= 30); + // Assert.False(found.Bio.Length <= 256); + // } + // } + //} + + [Fact] + public void TestModifyChampionInMemory() { - yield return new object[] + var connection = new SqliteConnection("DataSource=:memory:"); + connection.Open(); + + var options = new DbContextOptionsBuilder() + .UseSqlite(connection) + .Options; + + //prepares the database with one instance of the context + using (var context = new LolContext(options)) + { + //context.Database.OpenConnection(); + context.Database.EnsureCreated(); + + ChampionEntity chewie = new ChampionEntity { Name = "Chewbacca",Icon="Icon1", Bio = "Zeus is the king of the gods." }; + ChampionEntity yoda = new ChampionEntity { Name = "Yoda",Icon="Icon2", Bio = "Zeus is the king of the gods." }; + ChampionEntity ewok = new ChampionEntity { Name = "Ewok",Icon="Icon3", Bio = "Zeus is the king of the gods." }; + + + context.Champions.Add(chewie); + context.Champions.Add(yoda); + context.Champions.Add(ewok); + context.SaveChanges(); + } + + //uses another instance of the context to do the tests + using (var context = new LolContext(options)) { - 1, - new ChampionEntity[] + context.Database.EnsureCreated(); + + string nameToFind = "ew"; + Assert.Equal(2, context.Champions.Where(n => n.Name.ToLower().Contains(nameToFind)).Count()); + nameToFind = "wo"; + 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(); + } + + //uses another instance of the context to do the tests + using (var context = new LolContext(options)) + { + context.Database.EnsureCreated(); + + 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()); + } + } + + [Theory] + + [InlineData(0, "black", "super Skin", "icon1.png", 190000000.2f, true)] + [InlineData(1, "White", "skin1", "icon1", 19, true)] + [InlineData(2, "Green", "skin", "icon1.jpg", -1, false)] + public async Task TestAddSkinToChampionInMemory(int id, String name, String description, String icon, float price, bool expected) + { + var connection = new SqliteConnection("DataSource=:memory:"); + connection.Open(); + + var options = new DbContextOptionsBuilder() + .UseSqlite(connection) + .Options; + + using (var context = new LolContext(options)) + { + await context.Database.EnsureCreatedAsync(); + + var Dieu = new ChampionEntity { - new ChampionEntity - { - Name = "jax", - Icon = "icon jax", - Bio = "test bio jax", - Class = ChampionClass.Fighter, - LargeImageEntity = new LargeImageEntity(){Base64 = "tevhdfvsdefefef"} - }, - new ChampionEntity - { - Name = "jax2", - Icon = "icon jax2", - Bio = "test bio jax2", - Class = ChampionClass.Assassin, - LargeImageEntity = new LargeImageEntity(){Base64 = "tevhdfvsdfefefe"} - }, - new ChampionEntity - { - Name = "jax3", - Icon = "icon jax3", - Bio = "test bio jax3", - Class = ChampionClass.Tank, - LargeImageEntity = new LargeImageEntity(){Base64 = "tevhdfvsdfkhefef"} - } - }, - new ChampionEntity[] + UniqueId = 0, + Name = "Zeus", + Bio = "Dieu de la foudre", + Skins = new Collection() + }; + + SkinEntity item = new SkinEntity { - new ChampionEntity() - { - Name = "jax4", - Icon = "icon jax4", - Bio = "test bio jax4", - Class = ChampionClass.Marksman, - LargeImageEntity = new LargeImageEntity(){Base64 = "tevhdfvsdfkhvfdfdf"} - } - } - }; + Name = name, + Description = description, + Icon = icon, + Price = price + }; + + Dieu.Skins.Add(item); + + ChampionEntity found = await context.Champions.SingleOrDefaultAsync(c => c.Name == "Zeus"); + Assert.Null(found); + + await context.Champions.AddAsync(Dieu); + await context.SaveChangesAsync(); + + found = await context.Champions.SingleOrDefaultAsync(c => c.Name == name); + } } } diff --git a/Sources/Tests/TestUnitaireLOL/TestUnitaireLOL.csproj b/Sources/Tests/TestUnitaireLOL/TestUnitaireLOL.csproj index 0fc8bb0..8b4fdcb 100644 --- a/Sources/Tests/TestUnitaireLOL/TestUnitaireLOL.csproj +++ b/Sources/Tests/TestUnitaireLOL/TestUnitaireLOL.csproj @@ -20,6 +20,10 @@ all + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + @@ -28,5 +32,7 @@ + + diff --git a/Sources/Tests/TestUnitaireLOL/projet.Champions.db b/Sources/Tests/TestUnitaireLOL/projet.Champions.db new file mode 100644 index 0000000000000000000000000000000000000000..b980d537fbe1b83bdac29136aea094349c56b531 GIT binary patch literal 77824 zcmeI(%}*m`9Ki7zUOG@H>`Tm?lwlI%HoFpD*2Rt4#8L*FPzqa$**%!1mXU2NWw$Mf zBzh?8#-nF%o=x=VU*OrB2NO^J6?*fTr_*_9r?6a1cJgg#nf96I?elwH7zPd=7wR3y z_~Nv6QtcRP$_-^~O!?R_6h#>m&)eeJf6R)5iT)e$T@4+NIvi7$YHDWwALZ8g56avh z^FL?)o%<>CPUiQS?`IxO|28wF{h4~G{WAIM&8Cx&@N7Sq@( z8m7!>8h6b2a?R{FH#I%KpmyKwH=}gcblUsXW2fRC^_o$vo;d#Jw}zVGCk_GnZ0PuYPzngukxMh=M6`WBl(i?>M7?o3RW<{(uR1L?m#h(vh}2F z6!*mQuuw4ad&PrtDQ6eUhPl7f8|J35U$S>|rKiS@_4HmZ@21nPwd&71V(NQcXm>vbcUN2L>m(lrTib+(qwylzEV(-*&JGZ=c`qOdL#59eqy^>{b7u}9r zGR;KWwycs>%v%SBKNs7se1D3Y*>pCWN$HPtRgqC|zi5c9yHY*toXYp!05Gf%x4Sab z!Lkt?rK7Sh$eDdPtI1jW>R6WPcfdcGij)&sDSETkUoL_bY{cC4%Zx0x*POc> z_0#yEk6w)PjcQv v^&=6M5YaHF|miu;}D?P0?^S#+ojmL451GBrH2y6;cQP442M z42MjYFR5r4`WdgY$u$}gcdz?bZgR4!^7(VIoec_#{ULS5{?KSt-2I`^(7H?Gy{>&E zyCxSE`7#mhT7R{9?XGzlhL?ydyXNNHs-Dyv=dpd8xU6ro*2;?fHrYK?HGO?uy|889 zDiv#Mw|?BJx<5L!KdHAnr>*nY567Z?k3GjWD) z{wXJ&wZ~HWXX~RDsn}X7E3qGsi%YC2_cALZp6dKxiumGz00IagfB*srAbr2Z^_tTipk|_~L;80tg_000Iag zfB*srAb+%Ewd400IagfB*srAb#f1-SlCevIiM0tg_000IagfB*srAbmo$5I_I{1Q0*~0R#|0 i009ILNWK8q|H+RrJwyNj1Q0*~0R#|0009ILK;S<_XZyea literal 0 HcmV?d00001 diff --git a/Sources/Tests/TestUnitaireLOL/projet.Champions.db-shm b/Sources/Tests/TestUnitaireLOL/projet.Champions.db-shm new file mode 100644 index 0000000000000000000000000000000000000000..fe9ac2845eca6fe6da8a63cd096d9cf9e24ece10 GIT binary patch literal 32768 zcmeIuAr62r3 Date: Mon, 27 Mar 2023 00:16:25 +0200 Subject: [PATCH 7/7] :fire: rm useless files --- Sources/EntityFrameWorkLib/ChampionEntity.cs | 13 +- .../EntityFrameWorkLib/LargeImageEntity.cs | 6 +- Sources/EntityFrameWorkLib/LolContext.cs | 17 +- .../20230326210027_MyMigration.Designer.cs | 225 ++++++++++++++++++ .../Migrations/20230326210027_MyMigration.cs | 175 ++++++++++++++ .../Migrations/LolContextModelSnapshot.cs | 222 +++++++++++++++++ Sources/EntityFrameWorkLib/RuneEntity.cs | 9 +- Sources/EntityFrameWorkLib/SkillEntity.cs | 6 +- Sources/EntityFrameWorkLib/SkinEntity.cs | 4 +- Sources/Tests/ConsoleDB/Program.cs | 2 +- Sources/Tests/ConsoleDB/projet.Champions.db | Bin 45056 -> 0 bytes Sources/WebApiLol/ChampionDTO.cs | 1 - Sources/WebApiLol/ChampionPageDTO.cs | 15 ++ .../Controllers/ChampionController.cs | 28 ++- .../Controllers/WeatherForecastController.cs | 33 --- 15 files changed, 702 insertions(+), 54 deletions(-) create mode 100644 Sources/EntityFrameWorkLib/Migrations/20230326210027_MyMigration.Designer.cs create mode 100644 Sources/EntityFrameWorkLib/Migrations/20230326210027_MyMigration.cs create mode 100644 Sources/EntityFrameWorkLib/Migrations/LolContextModelSnapshot.cs delete mode 100644 Sources/Tests/ConsoleDB/projet.Champions.db create mode 100644 Sources/WebApiLol/ChampionPageDTO.cs delete mode 100644 Sources/WebApiLol/Controllers/WeatherForecastController.cs diff --git a/Sources/EntityFrameWorkLib/ChampionEntity.cs b/Sources/EntityFrameWorkLib/ChampionEntity.cs index b3514c7..df9864d 100644 --- a/Sources/EntityFrameWorkLib/ChampionEntity.cs +++ b/Sources/EntityFrameWorkLib/ChampionEntity.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.ObjectModel; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using Shared; @@ -13,16 +14,22 @@ namespace EntityFrameWorkLib public int UniqueId { get; set; } public string Name { get; set; } - [Required] + //[Required] [MaxLength(256)] public string Bio { get; set; } public string Icon { get; set; } - [Required] + //[Required] public ChampionClass Class { get; set; } - public LargeImageEntity? LargeImageEntity { get; set; } + public Collection Skins { get; set; } + + public LargeImageEntity? LargeImage { get; set; } + + public HashSet skills = new HashSet(); + + public Collection ListRunePages { get; set; } } } diff --git a/Sources/EntityFrameWorkLib/LargeImageEntity.cs b/Sources/EntityFrameWorkLib/LargeImageEntity.cs index 26d6886..0641a02 100644 --- a/Sources/EntityFrameWorkLib/LargeImageEntity.cs +++ b/Sources/EntityFrameWorkLib/LargeImageEntity.cs @@ -8,13 +8,13 @@ namespace EntityFrameWorkLib [Key] public Guid Id { get; set; } - [Required] + //[Required] public string Base64 { get; set; } - [Required] + //[Required] public int championId { get; set; } - [Required] + //[Required] public ChampionEntity champion { get; set; } } } diff --git a/Sources/EntityFrameWorkLib/LolContext.cs b/Sources/EntityFrameWorkLib/LolContext.cs index 8d2869c..bb2011f 100644 --- a/Sources/EntityFrameWorkLib/LolContext.cs +++ b/Sources/EntityFrameWorkLib/LolContext.cs @@ -9,6 +9,9 @@ namespace EntityFrameWorkLib public DbSet Champions { get; set; } public DbSet Skill { get; set; } public DbSet LargeImage { get; set; } + public DbSet Runes { get; set; } + public DbSet RunesPage { get; set; } + public DbSet Skins { get; set; } public LolContext() { } public LolContext(DbContextOptions options) @@ -25,18 +28,28 @@ namespace EntityFrameWorkLib protected override void OnModelCreating(ModelBuilder modelBuilder) { + base.OnModelCreating(modelBuilder); //Définition de la clé primaire de ChampionEntity modelBuilder.Entity().HasKey(n => n.UniqueId); //Définition du mode de generation de la clé : génération à l'insertion modelBuilder.Entity().Property(n => n.UniqueId).ValueGeneratedOnAdd(); modelBuilder.Entity() - .HasOne(c => c.LargeImageEntity) + .HasOne(c => c.LargeImage) .WithOne(li => li.champion) .HasForeignKey(li => li.championId); - base.OnModelCreating(modelBuilder); + modelBuilder.Entity() + .Property(s => s.Name) + .ValueGeneratedOnAdd(); + + modelBuilder.Entity() + .Property(s => s.Id) + .ValueGeneratedOnAdd(); + modelBuilder.Entity() + .Property(s => s.Name) + .ValueGeneratedOnAdd(); } } diff --git a/Sources/EntityFrameWorkLib/Migrations/20230326210027_MyMigration.Designer.cs b/Sources/EntityFrameWorkLib/Migrations/20230326210027_MyMigration.Designer.cs new file mode 100644 index 0000000..003f7c7 --- /dev/null +++ b/Sources/EntityFrameWorkLib/Migrations/20230326210027_MyMigration.Designer.cs @@ -0,0 +1,225 @@ +// +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("20230326210027_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.Property("SkillEntityName") + .HasColumnType("TEXT"); + + b.HasKey("UniqueId"); + + b.HasIndex("SkillEntityName"); + + 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.RuneEntity", b => + { + b.Property("Name") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.Property("RuneFamily") + .HasColumnType("INTEGER"); + + b.HasKey("Name"); + + b.ToTable("Runes"); + }); + + modelBuilder.Entity("EntityFrameWorkLib.RunePageEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ChampionEntityUniqueId") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("RuneEntityName") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ChampionEntityUniqueId"); + + b.HasIndex("RuneEntityName"); + + b.ToTable("RunesPage"); + }); + + 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.SkinEntity", b => + { + b.Property("Name") + .ValueGeneratedOnAdd() + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("ChampionEntityUniqueId") + .HasColumnType("INTEGER"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.Property("Icon") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Price") + .HasColumnType("REAL"); + + b.HasKey("Name"); + + b.HasIndex("ChampionEntityUniqueId"); + + b.ToTable("Skins"); + }); + + modelBuilder.Entity("EntityFrameWorkLib.ChampionEntity", b => + { + b.HasOne("EntityFrameWorkLib.SkillEntity", null) + .WithMany("champions") + .HasForeignKey("SkillEntityName"); + }); + + modelBuilder.Entity("EntityFrameWorkLib.LargeImageEntity", b => + { + b.HasOne("EntityFrameWorkLib.ChampionEntity", "champion") + .WithOne("LargeImage") + .HasForeignKey("EntityFrameWorkLib.LargeImageEntity", "championId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("champion"); + }); + + modelBuilder.Entity("EntityFrameWorkLib.RunePageEntity", b => + { + b.HasOne("EntityFrameWorkLib.ChampionEntity", null) + .WithMany("ListRunePages") + .HasForeignKey("ChampionEntityUniqueId"); + + b.HasOne("EntityFrameWorkLib.RuneEntity", null) + .WithMany("ListRunePages") + .HasForeignKey("RuneEntityName"); + }); + + modelBuilder.Entity("EntityFrameWorkLib.SkinEntity", b => + { + b.HasOne("EntityFrameWorkLib.ChampionEntity", null) + .WithMany("Skins") + .HasForeignKey("ChampionEntityUniqueId"); + }); + + modelBuilder.Entity("EntityFrameWorkLib.ChampionEntity", b => + { + b.Navigation("LargeImage"); + + b.Navigation("ListRunePages"); + + b.Navigation("Skins"); + }); + + modelBuilder.Entity("EntityFrameWorkLib.RuneEntity", b => + { + b.Navigation("ListRunePages"); + }); + + modelBuilder.Entity("EntityFrameWorkLib.SkillEntity", b => + { + b.Navigation("champions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Sources/EntityFrameWorkLib/Migrations/20230326210027_MyMigration.cs b/Sources/EntityFrameWorkLib/Migrations/20230326210027_MyMigration.cs new file mode 100644 index 0000000..a4c5f62 --- /dev/null +++ b/Sources/EntityFrameWorkLib/Migrations/20230326210027_MyMigration.cs @@ -0,0 +1,175 @@ +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: "Runes", + columns: table => new + { + Name = table.Column(type: "TEXT", nullable: false), + Description = table.Column(type: "TEXT", maxLength: 500, nullable: false), + RuneFamily = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Runes", x => x.Name); + }); + + 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: "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), + SkillEntityName = table.Column(type: "TEXT", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Champions", x => x.UniqueId); + table.ForeignKey( + name: "FK_Champions_Skill_SkillEntityName", + column: x => x.SkillEntityName, + principalTable: "Skill", + principalColumn: "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.CreateTable( + name: "RunesPage", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Name = table.Column(type: "TEXT", nullable: false), + ChampionEntityUniqueId = table.Column(type: "INTEGER", nullable: true), + RuneEntityName = table.Column(type: "TEXT", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_RunesPage", x => x.Id); + table.ForeignKey( + name: "FK_RunesPage_Champions_ChampionEntityUniqueId", + column: x => x.ChampionEntityUniqueId, + principalTable: "Champions", + principalColumn: "UniqueId"); + table.ForeignKey( + name: "FK_RunesPage_Runes_RuneEntityName", + column: x => x.RuneEntityName, + principalTable: "Runes", + principalColumn: "Name"); + }); + + migrationBuilder.CreateTable( + name: "Skins", + columns: table => new + { + Name = table.Column(type: "TEXT", maxLength: 256, nullable: false), + Description = table.Column(type: "TEXT", maxLength: 500, nullable: false), + Icon = table.Column(type: "TEXT", nullable: false), + Price = table.Column(type: "REAL", nullable: false), + ChampionEntityUniqueId = table.Column(type: "INTEGER", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Skins", x => x.Name); + table.ForeignKey( + name: "FK_Skins_Champions_ChampionEntityUniqueId", + column: x => x.ChampionEntityUniqueId, + principalTable: "Champions", + principalColumn: "UniqueId"); + }); + + migrationBuilder.CreateIndex( + name: "IX_Champions_SkillEntityName", + table: "Champions", + column: "SkillEntityName"); + + migrationBuilder.CreateIndex( + name: "IX_LargeImage_championId", + table: "LargeImage", + column: "championId", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_RunesPage_ChampionEntityUniqueId", + table: "RunesPage", + column: "ChampionEntityUniqueId"); + + migrationBuilder.CreateIndex( + name: "IX_RunesPage_RuneEntityName", + table: "RunesPage", + column: "RuneEntityName"); + + migrationBuilder.CreateIndex( + name: "IX_Skins_ChampionEntityUniqueId", + table: "Skins", + column: "ChampionEntityUniqueId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "LargeImage"); + + migrationBuilder.DropTable( + name: "RunesPage"); + + migrationBuilder.DropTable( + name: "Skins"); + + migrationBuilder.DropTable( + name: "Runes"); + + migrationBuilder.DropTable( + name: "Champions"); + + migrationBuilder.DropTable( + name: "Skill"); + } + } +} diff --git a/Sources/EntityFrameWorkLib/Migrations/LolContextModelSnapshot.cs b/Sources/EntityFrameWorkLib/Migrations/LolContextModelSnapshot.cs new file mode 100644 index 0000000..a51d0b9 --- /dev/null +++ b/Sources/EntityFrameWorkLib/Migrations/LolContextModelSnapshot.cs @@ -0,0 +1,222 @@ +// +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.Property("SkillEntityName") + .HasColumnType("TEXT"); + + b.HasKey("UniqueId"); + + b.HasIndex("SkillEntityName"); + + 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.RuneEntity", b => + { + b.Property("Name") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.Property("RuneFamily") + .HasColumnType("INTEGER"); + + b.HasKey("Name"); + + b.ToTable("Runes"); + }); + + modelBuilder.Entity("EntityFrameWorkLib.RunePageEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ChampionEntityUniqueId") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("RuneEntityName") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ChampionEntityUniqueId"); + + b.HasIndex("RuneEntityName"); + + b.ToTable("RunesPage"); + }); + + 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.SkinEntity", b => + { + b.Property("Name") + .ValueGeneratedOnAdd() + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("ChampionEntityUniqueId") + .HasColumnType("INTEGER"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.Property("Icon") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Price") + .HasColumnType("REAL"); + + b.HasKey("Name"); + + b.HasIndex("ChampionEntityUniqueId"); + + b.ToTable("Skins"); + }); + + modelBuilder.Entity("EntityFrameWorkLib.ChampionEntity", b => + { + b.HasOne("EntityFrameWorkLib.SkillEntity", null) + .WithMany("champions") + .HasForeignKey("SkillEntityName"); + }); + + modelBuilder.Entity("EntityFrameWorkLib.LargeImageEntity", b => + { + b.HasOne("EntityFrameWorkLib.ChampionEntity", "champion") + .WithOne("LargeImage") + .HasForeignKey("EntityFrameWorkLib.LargeImageEntity", "championId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("champion"); + }); + + modelBuilder.Entity("EntityFrameWorkLib.RunePageEntity", b => + { + b.HasOne("EntityFrameWorkLib.ChampionEntity", null) + .WithMany("ListRunePages") + .HasForeignKey("ChampionEntityUniqueId"); + + b.HasOne("EntityFrameWorkLib.RuneEntity", null) + .WithMany("ListRunePages") + .HasForeignKey("RuneEntityName"); + }); + + modelBuilder.Entity("EntityFrameWorkLib.SkinEntity", b => + { + b.HasOne("EntityFrameWorkLib.ChampionEntity", null) + .WithMany("Skins") + .HasForeignKey("ChampionEntityUniqueId"); + }); + + modelBuilder.Entity("EntityFrameWorkLib.ChampionEntity", b => + { + b.Navigation("LargeImage"); + + b.Navigation("ListRunePages"); + + b.Navigation("Skins"); + }); + + modelBuilder.Entity("EntityFrameWorkLib.RuneEntity", b => + { + b.Navigation("ListRunePages"); + }); + + modelBuilder.Entity("EntityFrameWorkLib.SkillEntity", b => + { + b.Navigation("champions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Sources/EntityFrameWorkLib/RuneEntity.cs b/Sources/EntityFrameWorkLib/RuneEntity.cs index 6fca3d2..432bb2a 100644 --- a/Sources/EntityFrameWorkLib/RuneEntity.cs +++ b/Sources/EntityFrameWorkLib/RuneEntity.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.ObjectModel; using System.ComponentModel.DataAnnotations; using Shared; @@ -8,15 +9,17 @@ namespace EntityFrameWorkLib public class RuneEntity { [Key] - [MaxLength(256)] + //[MaxLength(256)] public string Name { get; set; } - [Required] + //[Required] [MaxLength(500)] public string Description { get; set; } - [Required] + //[Required] public RuneFamily RuneFamily { get; set; } + + public Collection ListRunePages { get; set; } } } diff --git a/Sources/EntityFrameWorkLib/SkillEntity.cs b/Sources/EntityFrameWorkLib/SkillEntity.cs index e0a15e2..74c6b8d 100644 --- a/Sources/EntityFrameWorkLib/SkillEntity.cs +++ b/Sources/EntityFrameWorkLib/SkillEntity.cs @@ -10,12 +10,14 @@ namespace EntityFrameWorkLib [MaxLength(256)] public string Name { get; set; } - [Required] + //[Required] [MaxLength(500)] public string Description { get; set; } - [Required] + //[Required] public SkillType SkillType { get; set; } + + public HashSet champions { get; set; } } } diff --git a/Sources/EntityFrameWorkLib/SkinEntity.cs b/Sources/EntityFrameWorkLib/SkinEntity.cs index 6be476d..fdbd9e8 100644 --- a/Sources/EntityFrameWorkLib/SkinEntity.cs +++ b/Sources/EntityFrameWorkLib/SkinEntity.cs @@ -9,13 +9,13 @@ namespace EntityFrameWorkLib [MaxLength(256)] public string Name { get; set; } - [Required] + //[Required] [MaxLength(500)] public string Description { get; set; } public string Icon { get; set; } - [Required] + //[Required] public float Price { get; set; } } } diff --git a/Sources/Tests/ConsoleDB/Program.cs b/Sources/Tests/ConsoleDB/Program.cs index 8f0a4b9..5983f08 100644 --- a/Sources/Tests/ConsoleDB/Program.cs +++ b/Sources/Tests/ConsoleDB/Program.cs @@ -22,7 +22,7 @@ ChampionEntity jax = new ChampionEntity Icon = "icon jax", Bio = "test bio jax", Class = ChampionClass.Fighter, - LargeImageEntity = largeImage + LargeImage = largeImage }; ChampionEntity darius = new ChampionEntity { diff --git a/Sources/Tests/ConsoleDB/projet.Champions.db b/Sources/Tests/ConsoleDB/projet.Champions.db deleted file mode 100644 index 27306d01c4fba6ae4ffd31f44fe93e157d9d6390..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 45056 zcmeI5$qwYmnV758t!j18$YsD7G<1+vYQruqzwV)mfXoCnOqH{!8N%hnaMRt z_@c4lXYe~1J{U0Ii{D{R2IgSEfZt#)g8}AZR&}d4b$fjAK^jITlfhst{J#iB1j+wr zT82^#>6@(WZsG6-dGU{5ynOlMU%h$r;>C;ix8;wv<+tvKo9AuVZ{5q^dj2o#_h0-f ze);3qfBWLYkN)e6fAl|I|K}h7)sO$fAOEKx|LZ@3|9IMhcDEDQ3G4)R0y}}7z)oN% zuoL)u3H;j+Klu39KY#g~KP#FfeTv>^O4waf@fKdw&*D71-HWynldl3lVoZ*@aBpl) zG;HpTsIi>)=9BMB_sJVwd-KUxsXux1=bwC)>nET71@*xPAOHO4FaNzdgi)P-74a+I zkG?4ILeUEMt-L;Zv$;>i9;_AoAnn7eit*F_HkF-hpjz*D~m5!ze{;p?pq1pM*Y#JpT2ta@vlGrJ|W*F z{S11y`r!QjtB(QTrT4w|*Ct~;IBD1aZkzk)Q}G9{KK?hv_qC|+EafxkJA>cbI@uq+ z?P!0zEiYgH&llTwcRPWdz)oN%uoKt`>;!fKJAs|RPGBdn6W9s-9uoNE<$Kh}@Bu~+ z2t*tR3`NM#)aA?D7R0X(zd}FS*a_?eb^<$r zoxo1u_m;p<-=jYK{+j@ApZ~vl{i_$R|JUpP_WD1*o?dI)#_o0kJAs|RPGBdn6W9st z1a<;Dft|okU?=bon!rDO_3Fhx`R6}I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0W`&DUoWK)%^pL-*hL`@j?gLub*^Y=z(_vbY*rj+teSx5 z{R={Q5P31Liu6!xg@UfdshSeWEN`s4nOm$muX^IMQf-o-#>az1blFgX&d!#OCE#Z4 zG<9W^K6=Q8>iPH*!mcTZCcA}M`KjfVJ~7Wxx7p~5_wwXQMq#r8Jht`VT#bc`pM}D; z=3~2HKw<-yXE|Va|9N`Yq9ZP3bd#gaQbDB^)h{5Cllvgm2tg|<>UOPfs%cfs$ zraFGjNQRn)c;P}W&5GvAi<=mH%L`NTWc`l1S7K0dE|~$*5%PpH6Hn9p*3^0%cx;U8 ND(QN?{`%Li{tqRqHctQm diff --git a/Sources/WebApiLol/ChampionDTO.cs b/Sources/WebApiLol/ChampionDTO.cs index ca10c5b..653aaac 100644 --- a/Sources/WebApiLol/ChampionDTO.cs +++ b/Sources/WebApiLol/ChampionDTO.cs @@ -3,7 +3,6 @@ namespace WebApiLol { public class ChampionDTO { - public int UniqueId { get; set; } public string Name { get; set; } diff --git a/Sources/WebApiLol/ChampionPageDTO.cs b/Sources/WebApiLol/ChampionPageDTO.cs new file mode 100644 index 0000000..16bcafa --- /dev/null +++ b/Sources/WebApiLol/ChampionPageDTO.cs @@ -0,0 +1,15 @@ +using System; +namespace WebApiLol +{ + public class ChampionPageDTO + { + public IEnumerable Data { get; set; } + + public int Index { get; set; } + + public int Count { get; set; } + + public int TotalCount { get; set; } + } +} + diff --git a/Sources/WebApiLol/Controllers/ChampionController.cs b/Sources/WebApiLol/Controllers/ChampionController.cs index b463652..8a7b586 100644 --- a/Sources/WebApiLol/Controllers/ChampionController.cs +++ b/Sources/WebApiLol/Controllers/ChampionController.cs @@ -1,8 +1,11 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Reflection; using System.Threading.Tasks; +using System.Xml.Linq; using Microsoft.AspNetCore.Mvc; +using Model; using StubLib; using WebApiLol.Converter; @@ -14,18 +17,35 @@ public class ChampionController : ControllerBase { private StubData.ChampionsManager ChampionsManager { get; set; } = new StubData.ChampionsManager(new StubData()); + private IChampionsManager _dataManager; private readonly ILogger _logger; - public ChampionController(ILogger logger) + public ChampionController(IDataManager manager,ILogger logger) { + _dataManager = manager.ChampionsMgr; _logger = logger; } [HttpGet] - public async Task Get() + [ProducesResponseType(typeof(ChampionPageDTO), 200)] + public async Task Get([FromQuery] int index = 0, int count = 10, string? name = "") { - var list = await ChampionsManager.GetItems(0, await ChampionsManager.GetNbItems()); - return Ok(list.Select(champion => champion?.toDTO())); + _logger.LogInformation($"methode Get de ControllerChampions appelée"); + int nbChampions = await _dataManager.GetNbItems(); + _logger.LogInformation($"Nombre de champions : {nbChampions}"); + var champs = (await _dataManager.GetItemsByName(name, index, int.MaxValue)) + .Where(champ => string.IsNullOrEmpty(name) || champ.Name.Contains(name, StringComparison.InvariantCultureIgnoreCase)) + .Take(count) + .Select(Model => Model.toDTO()); + + var page = new ChampionPageDTO + { + Data = champs, + Index = index, + Count = champs.Count(), + TotalCount = nbChampions + }; + return Ok(page); } [HttpGet("name")] diff --git a/Sources/WebApiLol/Controllers/WeatherForecastController.cs b/Sources/WebApiLol/Controllers/WeatherForecastController.cs deleted file mode 100644 index 0e39eb8..0000000 --- a/Sources/WebApiLol/Controllers/WeatherForecastController.cs +++ /dev/null @@ -1,33 +0,0 @@ -//using Microsoft.AspNetCore.Mvc; - -//namespace WebApiLol.Controllers; - -//[ApiController] -//[Route("[controller]")] -//public class WeatherForecastController : ControllerBase -//{ -// private static readonly string[] Summaries = new[] -// { -// "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" -// }; - -// private readonly ILogger _logger; - -// public WeatherForecastController(ILogger logger) -// { -// _logger = logger; -// } - -// [HttpGet(Name = "GetWeatherForecast")] -// public IEnumerable<> Get() -// { -// return Enumerable.Range(1, 5).Select(index => new WeatherForecast -// { -// Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)), -// TemperatureC = Random.Shared.Next(-20, 55), -// Summary = Summaries[Random.Shared.Next(Summaries.Length)] -// }) -// .ToArray(); -// } -//} -