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: 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..df9864d 100644 --- a/Sources/EntityFrameWorkLib/ChampionEntity.cs +++ b/Sources/EntityFrameWorkLib/ChampionEntity.cs @@ -1,6 +1,8 @@ using System; +using System.Collections.ObjectModel; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; +using Shared; namespace EntityFrameWorkLib { @@ -10,10 +12,24 @@ 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 ChampionClassEntity championClass { get; set; } - } + + //[Required] + public ChampionClass Class { 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/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/LargeImageEntity.cs b/Sources/EntityFrameWorkLib/LargeImageEntity.cs new file mode 100644 index 0000000..0641a02 --- /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..bb2011f 100644 --- a/Sources/EntityFrameWorkLib/LolContext.cs +++ b/Sources/EntityFrameWorkLib/LolContext.cs @@ -6,32 +6,52 @@ 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 DbSet Runes { get; set; } + public DbSet RunesPage { get; set; } + public DbSet Skins { 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) + { + 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.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/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/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 index 86cbf85..a51d0b9 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,183 @@ namespace EntityFrameWorkLib.Migrations .IsRequired() .HasColumnType("TEXT"); - b.Property("championClass") - .HasColumnType("INTEGER"); + 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 new file mode 100644 index 0000000..432bb2a --- /dev/null +++ b/Sources/EntityFrameWorkLib/RuneEntity.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.ObjectModel; +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; } + + public Collection ListRunePages { get; set; } + } +} + 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/EntityFrameWorkLib/SkillEntity.cs b/Sources/EntityFrameWorkLib/SkillEntity.cs new file mode 100644 index 0000000..74c6b8d --- /dev/null +++ b/Sources/EntityFrameWorkLib/SkillEntity.cs @@ -0,0 +1,23 @@ +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; } + + public HashSet champions { 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..fdbd9e8 --- /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; } + } +} + 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 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/ConsoleDB/Program.cs b/Sources/Tests/ConsoleDB/Program.cs index c9fdc38..5983f08 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+3AT4jt3ILm3AcnOdiAcRjJC0kS6gEQcqUSCzEqCDAIcFNROJzQhi9sDzefjpwRaSQkcVaPgmjwF7ukz4ao9FY7SsqJ6JrVCXxuf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RALJLg6gmdWNx2RYLNZLkROSKhHRIlKarQ7XTBS7L4qZb83F5PCDKBkY3Th0/RIxslyjHbwXC925TL70VHoL7APkB1t59GeAslVVuknZGGYT3AX19TRgLJqMlLA1giFkvdJRjmDWKEfzhGMXIxkMU9Gvuqq93OKQLZrUfyrD72nurNMzCLsbqKQMXY6ya2WRHIRDCLsShFoGLsdRPbrAhkIpjFWJQiUDH2uoltVgQyEcxiLEoRqBh73cQ2KwKZCGYxFqUIVIy9bmKbFYFMBLMYi1IEKsZeN7HNikAmglmMRSkCFWOvm9hmRSATwSzGohSBirHXTWyzIpCJYBZjUYpAxdjrJrZZEchEMIuxKEWgYux1E9usCGQimMVYlCJQMfa6iW1WBDIRzGIsShGoGHvdxDYrApkIZjEW9f+b81XHPCcvvwAAAABJRU5ErkJggg==" +}; ChampionEntity jax = new ChampionEntity { Name = "jax", Icon = "icon jax", - Bio = "test bio jax" + Bio = "test bio jax", + Class = ChampionClass.Fighter, + LargeImage = 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/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/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 new file mode 100644 index 0000000..48dde60 --- /dev/null +++ b/Sources/Tests/TestUnitaireLOL/TestEf.cs @@ -0,0 +1,178 @@ +using System; +using System.Collections.ObjectModel; +using EntityFrameWorkLib; +using Microsoft.Data.Sqlite; +using Microsoft.EntityFrameworkCore; +using Model; +using Shared; + +namespace TestUnitaireLOL +{ + public class TestEf + { + //[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() + { + 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)) + { + 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 + { + UniqueId = 0, + Name = "Zeus", + Bio = "Dieu de la foudre", + Skins = new Collection() + }; + + SkinEntity item = new SkinEntity + { + 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 cb2bdfc..8b4fdcb 100644 --- a/Sources/Tests/TestUnitaireLOL/TestUnitaireLOL.csproj +++ b/Sources/Tests/TestUnitaireLOL/TestUnitaireLOL.csproj @@ -19,7 +19,11 @@ runtime; build; native; contentfiles; analyzers; buildtransitive all - + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + @@ -28,5 +32,7 @@ + + 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/Tests/TestUnitaireLOL/projet.Champions.db b/Sources/Tests/TestUnitaireLOL/projet.Champions.db new file mode 100644 index 0000000..b980d53 Binary files /dev/null and b/Sources/Tests/TestUnitaireLOL/projet.Champions.db differ diff --git a/Sources/Tests/TestUnitaireLOL/projet.Champions.db-shm b/Sources/Tests/TestUnitaireLOL/projet.Champions.db-shm new file mode 100644 index 0000000..fe9ac28 Binary files /dev/null and b/Sources/Tests/TestUnitaireLOL/projet.Champions.db-shm differ diff --git a/Sources/Tests/ConsoleDB/projet.Champions.db b/Sources/Tests/TestUnitaireLOL/projet.Champions.db-wal similarity index 100% rename from Sources/Tests/ConsoleDB/projet.Champions.db rename to Sources/Tests/TestUnitaireLOL/projet.Champions.db-wal 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 { 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/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 @@ - +