From 8d1b434eea4cafbfea7b916cb8a913aa3cb27720 Mon Sep 17 00:00:00 2001 From: "Jade.VAN_BRABANDT" Date: Wed, 10 Jan 2024 10:23:14 +0100 Subject: [PATCH 1/3] Feat : implementing test sln --- Blazor/Blazor.sln | 56 ++++++++++++++++++++----------------- Blazor/Test/GlobalUsings.cs | 1 + Blazor/Test/Test.csproj | 19 +++++++++++++ Blazor/Test/UnitTest1.cs | 11 ++++++++ 4 files changed, 62 insertions(+), 25 deletions(-) create mode 100644 Blazor/Test/GlobalUsings.cs create mode 100644 Blazor/Test/Test.csproj create mode 100644 Blazor/Test/UnitTest1.cs diff --git a/Blazor/Blazor.sln b/Blazor/Blazor.sln index 2c17fbd..6b4e33c 100644 --- a/Blazor/Blazor.sln +++ b/Blazor/Blazor.sln @@ -1,25 +1,31 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.8.34330.188 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Blazor", "Blazor\Blazor.csproj", "{F9B19564-ED8F-49F7-97D7-2132F92DE3C2}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {F9B19564-ED8F-49F7-97D7-2132F92DE3C2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F9B19564-ED8F-49F7-97D7-2132F92DE3C2}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F9B19564-ED8F-49F7-97D7-2132F92DE3C2}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F9B19564-ED8F-49F7-97D7-2132F92DE3C2}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {75BB0A32-C002-4B33-88B3-421A9369D9CB} - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.8.34330.188 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Blazor", "Blazor\Blazor.csproj", "{F9B19564-ED8F-49F7-97D7-2132F92DE3C2}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test", "Test\Test.csproj", "{FC6D090C-6922-4F72-8DD2-AE8FEDD773A5}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F9B19564-ED8F-49F7-97D7-2132F92DE3C2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F9B19564-ED8F-49F7-97D7-2132F92DE3C2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F9B19564-ED8F-49F7-97D7-2132F92DE3C2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F9B19564-ED8F-49F7-97D7-2132F92DE3C2}.Release|Any CPU.Build.0 = Release|Any CPU + {FC6D090C-6922-4F72-8DD2-AE8FEDD773A5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FC6D090C-6922-4F72-8DD2-AE8FEDD773A5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FC6D090C-6922-4F72-8DD2-AE8FEDD773A5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FC6D090C-6922-4F72-8DD2-AE8FEDD773A5}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {75BB0A32-C002-4B33-88B3-421A9369D9CB} + EndGlobalSection +EndGlobal diff --git a/Blazor/Test/GlobalUsings.cs b/Blazor/Test/GlobalUsings.cs new file mode 100644 index 0000000..ab67c7e --- /dev/null +++ b/Blazor/Test/GlobalUsings.cs @@ -0,0 +1 @@ +global using Microsoft.VisualStudio.TestTools.UnitTesting; \ No newline at end of file diff --git a/Blazor/Test/Test.csproj b/Blazor/Test/Test.csproj new file mode 100644 index 0000000..3a5cdc0 --- /dev/null +++ b/Blazor/Test/Test.csproj @@ -0,0 +1,19 @@ + + + + net7.0 + enable + enable + + false + true + + + + + + + + + + diff --git a/Blazor/Test/UnitTest1.cs b/Blazor/Test/UnitTest1.cs new file mode 100644 index 0000000..20b9e62 --- /dev/null +++ b/Blazor/Test/UnitTest1.cs @@ -0,0 +1,11 @@ +namespace Test +{ + [TestClass] + public class UnitTest1 + { + [TestMethod] + public void TestMethod1() + { + } + } +} \ No newline at end of file From e9037399f42f5b8b4a810949b11c95705398e217 Mon Sep 17 00:00:00 2001 From: Jade VAN BRABANDT Date: Wed, 10 Jan 2024 10:24:48 +0100 Subject: [PATCH 2/3] CI : Trying to implement test to CI --- .drone.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.drone.yml b/.drone.yml index 53d61fd..fa3c0bf 100755 --- a/.drone.yml +++ b/.drone.yml @@ -19,10 +19,7 @@ steps: commands: - cd Blazor/ - dotnet restore Blazor.sln - - dotnet sonarscanner begin /k:MuscuMaths /d:sonar.host.url=$${PLUGIN_SONAR_HOST} /d:sonar.login=$${PLUGIN_SONAR_TOKEN} - - dotnet test Blazor.sln --logger trx --no-restore /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura --collect "XPlat Code Coverage" - - reportgenerator -reports:"/coverage.cobertura.xml" -reporttypes:SonarQube -targetdir:"coveragereport" -verbosity:Verbose - + - dotnet test Blazor.sln --no-restore depends_on: [build] - name: code-analysis @@ -30,8 +27,11 @@ steps: commands: - cd Blazor/ - dotnet restore Blazor.sln + - dotnet sonarscanner begin /k:MuscuMaths /d:sonar.host.url=$${PLUGIN_SONAR_HOST} /d:sonar.login=$${PLUGIN_SONAR_TOKEN} /d:sonar.coverageReportPaths="coveragereport/SonarQube.xml" - dotnet sonarscanner begin /k:MuscuMaths /d:sonar.host.url=$${PLUGIN_SONAR_HOST} /d:sonar.login=$${PLUGIN_SONAR_TOKEN} - dotnet build Blazor.sln -c Release --no-restore + - dotnet test Blazor.sln --logger trx --no-restore /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura --collect "XPlat Code Coverage" + - reportgenerator -reports:"**/coverage.cobertura.xml" -reporttypes:SonarQube -targetdir:"coveragereport" -verbosity:Verbose - dotnet publish Blazor.sln -c Release --no-restore -o $CI_PROJECT_DIR/build/release - dotnet sonarscanner end /d:sonar.login=$${PLUGIN_SONAR_TOKEN} secrets: [ PLUGIN_SONAR_TOKEN ] From 27a5fea5db125f11675cd45cf6e0eec3da630f48 Mon Sep 17 00:00:00 2001 From: "yvan.calatayud" Date: Wed, 10 Jan 2024 17:18:08 +0100 Subject: [PATCH 3/3] feat : Component CardViewQuestion and BackButton --- Blazor/Blazor/Components/BackButton.razor | 1 + Blazor/Blazor/Components/BackButton.razor.cs | 18 ++++++++ .../Blazor/Components/CardViewQuestion.razor | 6 +++ .../Components/CardViewQuestion.razor.cs | 16 +++++++ .../Blazor/Components/DisplayQuestions.razor | 32 -------------- .../Pages/Admins/EditAdministrator.razor | 42 ++++++++++++------- .../Blazor/Pages/Chapters/EditChapter.razor | 41 +++++++++++------- Blazor/Blazor/Pages/Players/EditPlayer.razor | 42 ++++++++++++------- .../Pages/Questions/DisplayQuestions.razor | 37 ++++++++++++++++ .../Questions}/DisplayQuestions.razor.cs | 5 +-- 10 files changed, 157 insertions(+), 83 deletions(-) create mode 100644 Blazor/Blazor/Components/BackButton.razor create mode 100644 Blazor/Blazor/Components/BackButton.razor.cs create mode 100644 Blazor/Blazor/Components/CardViewQuestion.razor create mode 100644 Blazor/Blazor/Components/CardViewQuestion.razor.cs delete mode 100644 Blazor/Blazor/Components/DisplayQuestions.razor create mode 100644 Blazor/Blazor/Pages/Questions/DisplayQuestions.razor rename Blazor/Blazor/{Components => Pages/Questions}/DisplayQuestions.razor.cs (93%) diff --git a/Blazor/Blazor/Components/BackButton.razor b/Blazor/Blazor/Components/BackButton.razor new file mode 100644 index 0000000..6339d42 --- /dev/null +++ b/Blazor/Blazor/Components/BackButton.razor @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Blazor/Blazor/Components/BackButton.razor.cs b/Blazor/Blazor/Components/BackButton.razor.cs new file mode 100644 index 0000000..b2ade6a --- /dev/null +++ b/Blazor/Blazor/Components/BackButton.razor.cs @@ -0,0 +1,18 @@ +using Microsoft.AspNetCore.Components; + +namespace Blazor.Components +{ + public partial class BackButton + { + + [Parameter] + public string RedirectionPage { get; set; } + + [Inject] + public required NavigationManager NavigationManager { get; set; } + private void Back() + { + NavigationManager.NavigateTo(RedirectionPage, true); + } + } +} diff --git a/Blazor/Blazor/Components/CardViewQuestion.razor b/Blazor/Blazor/Components/CardViewQuestion.razor new file mode 100644 index 0000000..0574549 --- /dev/null +++ b/Blazor/Blazor/Components/CardViewQuestion.razor @@ -0,0 +1,6 @@ + +
+ @CardHeader + @CardBody + @CardFooter +
diff --git a/Blazor/Blazor/Components/CardViewQuestion.razor.cs b/Blazor/Blazor/Components/CardViewQuestion.razor.cs new file mode 100644 index 0000000..220bb56 --- /dev/null +++ b/Blazor/Blazor/Components/CardViewQuestion.razor.cs @@ -0,0 +1,16 @@ +using Microsoft.AspNetCore.Components; + +namespace Blazor.Components +{ + public partial class CardViewQuestion + { + [Parameter] + public RenderFragment CardBody { get; set; } + + [Parameter] + public RenderFragment CardFooter { get; set; } + + [Parameter] + public RenderFragment CardHeader { get; set; } + } +} diff --git a/Blazor/Blazor/Components/DisplayQuestions.razor b/Blazor/Blazor/Components/DisplayQuestions.razor deleted file mode 100644 index fdf398d..0000000 --- a/Blazor/Blazor/Components/DisplayQuestions.razor +++ /dev/null @@ -1,32 +0,0 @@ -@page "/displayquestions/{QuestionId:int}" - -@if (question != null) -{ -
-

Question n°@question.Id

-
-
-
@question.Content
-
- -
- @foreach (var answer in answers) - { -
- @if (answer.Id == question.IdAnswerGood) - { -

@answer.Content

- } - else - { -

@answer.Content

- } -
- - } -
-} -else -{ -

Question not found

-} diff --git a/Blazor/Blazor/Pages/Admins/EditAdministrator.razor b/Blazor/Blazor/Pages/Admins/EditAdministrator.razor index 3c83798..672a5dc 100644 --- a/Blazor/Blazor/Pages/Admins/EditAdministrator.razor +++ b/Blazor/Blazor/Pages/Admins/EditAdministrator.razor @@ -1,21 +1,31 @@ @page "/editAdministrator/{Id:int}" -

EditAdministrator

+@using Blazor.Components; - - - + -

- - -

+
+
+

EditAdministrator

- - + + + + +
+ +
+
+ +
+ + +
+
+
\ No newline at end of file diff --git a/Blazor/Blazor/Pages/Chapters/EditChapter.razor b/Blazor/Blazor/Pages/Chapters/EditChapter.razor index c1f51ba..42533af 100644 --- a/Blazor/Blazor/Pages/Chapters/EditChapter.razor +++ b/Blazor/Blazor/Pages/Chapters/EditChapter.razor @@ -1,18 +1,27 @@ @page "/editChapter/{Id:int}" -

Edit Chapter

- - - - - - -

- -

- - -
\ No newline at end of file +@using Blazor.Components; + + + + +
+
+

Edit Chapter

+ + + + +

+ +

+ + +
+
+
+ + diff --git a/Blazor/Blazor/Pages/Players/EditPlayer.razor b/Blazor/Blazor/Pages/Players/EditPlayer.razor index 212a9da..c6f95bb 100644 --- a/Blazor/Blazor/Pages/Players/EditPlayer.razor +++ b/Blazor/Blazor/Pages/Players/EditPlayer.razor @@ -1,21 +1,31 @@ @page "/editPlayer/{Id:int}" -

Edit Player

+@using Blazor.Components; - - - + -

- - -

+
+
+

Edit Player

- - + + + + +
+ +
+
+ Password: + + +
+ + +
+
+
\ No newline at end of file diff --git a/Blazor/Blazor/Pages/Questions/DisplayQuestions.razor b/Blazor/Blazor/Pages/Questions/DisplayQuestions.razor new file mode 100644 index 0000000..0e4df0f --- /dev/null +++ b/Blazor/Blazor/Pages/Questions/DisplayQuestions.razor @@ -0,0 +1,37 @@ +@page "/displayquestions/{QuestionId:int}" + +@using Blazor.Components; + + + +
+

Question n°@question.Id

+
+
+
@question.Content
+
+
+ +
+ @foreach (var answer in answers) + { +
+ @if (answer.Id == question.IdAnswerGood) + { +

@answer.Content

+ } + else + { +

@answer.Content

+ } +
+ } +
+
+ + + + +
diff --git a/Blazor/Blazor/Components/DisplayQuestions.razor.cs b/Blazor/Blazor/Pages/Questions/DisplayQuestions.razor.cs similarity index 93% rename from Blazor/Blazor/Components/DisplayQuestions.razor.cs rename to Blazor/Blazor/Pages/Questions/DisplayQuestions.razor.cs index af7486b..19f1bf5 100644 --- a/Blazor/Blazor/Components/DisplayQuestions.razor.cs +++ b/Blazor/Blazor/Pages/Questions/DisplayQuestions.razor.cs @@ -1,11 +1,10 @@ using Blazor.Models; using Blazor.Pages; -using Blazor.Pages.Questions; using Blazor.ViewClasses; using Microsoft.AspNetCore.Components; using static System.Net.WebRequestMethods; -namespace Blazor.Components +namespace Blazor.Pages.Questions { public partial class DisplayQuestions { @@ -30,7 +29,7 @@ namespace Blazor.Components IEnumerable foundQuestions = questions.Where(q => q.Id == QuestionId); - + foreach (var q in foundQuestions) { answers.Add(new Answer(q.A_id, q.A_content, q.Id));