From c66e6516604230f76b57865b1a6b606a9674bd4d Mon Sep 17 00:00:00 2001
From: Pierre Ferreira
Date: Fri, 24 Feb 2023 16:07:32 +0100
Subject: [PATCH 1/5] Ajout de l'enum SkillType et de l'attribut et class Skill
:package:
---
Sources/EntityFramework/ChampionEntity.cs | 11 ++++++
Sources/EntityFramework/EnumSkillType.cs | 16 +++++++++
Sources/EntityFramework/Skill.cs | 42 +++++++++++++++++++++++
3 files changed, 69 insertions(+)
create mode 100644 Sources/EntityFramework/EnumSkillType.cs
create mode 100644 Sources/EntityFramework/Skill.cs
diff --git a/Sources/EntityFramework/ChampionEntity.cs b/Sources/EntityFramework/ChampionEntity.cs
index 36d33f6..a943aee 100644
--- a/Sources/EntityFramework/ChampionEntity.cs
+++ b/Sources/EntityFramework/ChampionEntity.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Collections.Immutable;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
@@ -17,9 +18,19 @@ namespace EntityFramework
public string name { get; set; }
public ChampionClass Class { get; set; }
+ public ImmutableHashSet Skills => skills.ToImmutableHashSet();
+ private HashSet skills = new HashSet();
public ChampionEntity(string name) {
this.name = name;
}
+
+
+
+ public bool AddSkill(Skill skill)
+ => skills.Add(skill);
+
+ public bool RemoveSkill(Skill skill)
+ => skills.Remove(skill);
}
}
diff --git a/Sources/EntityFramework/EnumSkillType.cs b/Sources/EntityFramework/EnumSkillType.cs
new file mode 100644
index 0000000..f8f56f8
--- /dev/null
+++ b/Sources/EntityFramework/EnumSkillType.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EntityFramework
+{
+ public enum SkillType
+ {
+ Unknown,
+ Basic,
+ Passive,
+ Ultimate
+ }
+}
diff --git a/Sources/EntityFramework/Skill.cs b/Sources/EntityFramework/Skill.cs
new file mode 100644
index 0000000..e9b1f32
--- /dev/null
+++ b/Sources/EntityFramework/Skill.cs
@@ -0,0 +1,42 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EntityFramework
+{
+ public class Skill
+ {
+ public SkillType Type { get; private set; }
+
+ public string Name
+ {
+ get => name;
+ private init
+ {
+ if (string.IsNullOrWhiteSpace(value))
+ {
+ throw new ArgumentException("a Skill needs a name");
+ }
+ name = value;
+ }
+ }
+ private readonly string name = null!;
+
+ public string Description
+ {
+ get => description;
+ set
+ {
+ if (string.IsNullOrWhiteSpace(value))
+ {
+ description = "";
+ return;
+ }
+ description = value;
+ }
+ }
+ private string description = "";
+ }
+}
From f0d5fb9b2604a052547f7c980f5ffbfb63743dce Mon Sep 17 00:00:00 2001
From: Pierre Ferreira
Date: Sun, 26 Feb 2023 14:55:08 +0100
Subject: [PATCH 2/5] :green_heart: ajout de l'image de build dans la CI
:bento:
---
.drone.yml | 28 ++++++++++++++++++++--------
1 file changed, 20 insertions(+), 8 deletions(-)
diff --git a/.drone.yml b/.drone.yml
index b773b1b..94a89f2 100644
--- a/.drone.yml
+++ b/.drone.yml
@@ -7,19 +7,31 @@ trigger:
- push
steps:
+
+ - name: build
+ image: mcr.microsoft.com/dotnet/sdk:6.0
+ volumes:
+ - name: docs
+ path: /docs
+ 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
+
# docker image build
- name: docker-build-and-push
image: plugins/docker
settings:
- dockerfile: Sources/API_LoL/Dockerfile
- context: Sources/
- registry: hub.codefirst.iut.uca.fr
- repo: hub.codefirst.iut.uca.fr/corentin.richard/entityframework_consodeservices_tp
+ dockerfile: Sources/API_LoL/Dockerfile
+ context: Sources/
+ registry: hub.codefirst.iut.uca.fr
+ repo: hub.codefirst.iut.uca.fr/corentin.richard/entityframework_consodeservices_tp
- username:
- from_secret: SECRET_REGISTRY_USERNAME
- password:
- from_secret: SECRET_REGISTRY_PASSWORD
+ username:
+ from_secret: SECRET_REGISTRY_USERNAME
+ password:
+ from_secret: SECRET_REGISTRY_PASSWORD
# docker test
- name: tests
From 0f3e4a78086785b6e60ffa048ead9549030e3d7e Mon Sep 17 00:00:00 2001
From: Pierre Ferreira
Date: Sun, 26 Feb 2023 15:32:20 +0100
Subject: [PATCH 3/5] :green_heart: mise a jour de la CI avec ajout de
code-analysis, il faut penser a mettre le master a jour car les tests ne sont
pas fonctionnel, contrairement aux autres branches :bug:
---
.drone.yml | 20 ++++++++++++++++++++
Sources/EF_UT/EntityTest.cs | 8 +++++---
Sources/EntityFramework/Skill.cs | 2 ++
3 files changed, 27 insertions(+), 3 deletions(-)
diff --git a/.drone.yml b/.drone.yml
index 94a89f2..e694160 100644
--- a/.drone.yml
+++ b/.drone.yml
@@ -42,3 +42,23 @@ steps:
- dotnet test LeagueOfLegends.sln --no-restore
depends_on: [docker-build-and-push]
+ - name: code-analysis
+ image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dronesonarplugin-dotnet6
+ commands:
+ - cd Sources/
+ - dotnet restore LeagueOfLegends.sln
+ - dotnet sonarscanner begin /k:entityframework_consodeservices_tp /d:sonar.host.url=$${PLUGIN_SONAR_HOST} /d:sonar.coverageReportPaths="coveragereport/SonarQube.xml" /d:sonar.coverage.exclusions="Tests/**" /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"
+ - reportgenerator -reports:"**/coverage.cobertura.xml" -reporttypes:SonarQube -targetdir:"coveragereport"
+ - dotnet publish LeagueOfLegends.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:
+ # accessible en ligne de commande par ${PLUGIN_SONAR_HOST}
+ sonar_host: https://codefirst.iut.uca.fr/sonar/
+ # accessible en ligne de commande par ${PLUGIN_SONAR_TOKEN}
+ sonar_token:
+ from_secret: SECRET_SONAR_LOGIN
+ depends_on: [docker-build-and-push]
+
diff --git a/Sources/EF_UT/EntityTest.cs b/Sources/EF_UT/EntityTest.cs
index 4d4ce34..d1f87b5 100644
--- a/Sources/EF_UT/EntityTest.cs
+++ b/Sources/EF_UT/EntityTest.cs
@@ -23,7 +23,7 @@ namespace EF_UT
using (var context = new LoLDbContext(options))
{
- ChampionEntity chewie = new ChampionEntity("Chewbacca","","");
+ ChampionEntity chewie = new ChampionEntity("Chewbacca", "", "");
ChampionEntity yoda = new ChampionEntity("Yoda", "", "");
ChampionEntity ewok = new ChampionEntity("Ewok", "", "");
@@ -42,6 +42,8 @@ namespace EF_UT
Assert.AreEqual("Chewbacca", context.Champions.First().Name);
}
}
+
+
[TestMethod]
public void TestUpdate()
{
@@ -52,8 +54,8 @@ namespace EF_UT
//prepares the database with one instance of the context
using (var context = new LoLDbContext(options))
{
- ChampionEntity chewie = new ChampionEntity ("Chewbacca", "", "");
- ChampionEntity yoda = new ChampionEntity ("Yoda", "", "");
+ ChampionEntity chewie = new ChampionEntity("Chewbacca", "", "");
+ ChampionEntity yoda = new ChampionEntity("Yoda", "", "");
ChampionEntity ewok = new ChampionEntity("Ewok", "", "");
context.Add(chewie);
diff --git a/Sources/EntityFramework/Skill.cs b/Sources/EntityFramework/Skill.cs
index e9b1f32..be43702 100644
--- a/Sources/EntityFramework/Skill.cs
+++ b/Sources/EntityFramework/Skill.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -10,6 +11,7 @@ namespace EntityFramework
{
public SkillType Type { get; private set; }
+ [Key]
public string Name
{
get => name;
From 7050248ff8ea91b538e2dd5a206421186251c9f0 Mon Sep 17 00:00:00 2001
From: Pierre FERREIRA
Date: Sun, 26 Feb 2023 15:43:42 +0100
Subject: [PATCH 4/5] :green_heart: fix CI
---
.drone.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.drone.yml b/.drone.yml
index e694160..138a4d0 100644
--- a/.drone.yml
+++ b/.drone.yml
@@ -19,7 +19,7 @@ steps:
- dotnet build LeagueOfLegends.sln -c Release --no-restore
- dotnet publish LeagueOfLegends.sln -c Release --no-restore -o CI_PROJECT_DIR/build/release
-# docker image build
+# docker image build
- name: docker-build-and-push
image: plugins/docker
settings:
From 14e72b7aaf0ff3f0dacf53c6539f26f39726201a Mon Sep 17 00:00:00 2001
From: Pierre FERREIRA
Date: Sun, 26 Feb 2023 15:46:45 +0100
Subject: [PATCH 5/5] :green_heart: fix CI
---
.drone.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.drone.yml b/.drone.yml
index 138a4d0..6aec404 100644
--- a/.drone.yml
+++ b/.drone.yml
@@ -60,5 +60,5 @@ steps:
# accessible en ligne de commande par ${PLUGIN_SONAR_TOKEN}
sonar_token:
from_secret: SECRET_SONAR_LOGIN
- depends_on: [docker-build-and-push]
+ depends_on: [tests]