Merge branch 'master' of https://codefirst.iut.uca.fr/git/corentin.richard/EntityFramework_ConsoDeServices_TP into pagination
continuous-integration/drone/push Build is failing Details

pull/10/head
Corentin R 2 years ago
commit 7070a34768

@ -7,19 +7,31 @@ trigger:
- push
steps:
# docker image build
- 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
@ -30,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: [tests]

@ -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);

@ -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;
@ -27,6 +28,8 @@ namespace EntityFramework
[Required]
public string Icon { get; set; }
public ImmutableHashSet<Skill> Skills => skills.ToImmutableHashSet();
private HashSet<Skill> skills = new HashSet<Skill>();
public ChampionEntity(string name,string bio,string icon) {
this.Name = name;
@ -38,5 +41,13 @@ namespace EntityFramework
{
return Name;
}
public bool AddSkill(Skill skill)
=> skills.Add(skill);
public bool RemoveSkill(Skill skill)
=> skills.Remove(skill);
}
}

@ -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
}
}

@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EntityFramework
{
public class Skill
{
public SkillType Type { get; private set; }
[Key]
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 = "";
}
}
Loading…
Cancel
Save