From 3e80afc3dd1f9e08c6e92f05006bc337a64eda5d Mon Sep 17 00:00:00 2001 From: victor perez ngounou Date: Sat, 24 Sep 2022 15:10:05 +0200 Subject: [PATCH] Test unitaire joueur --- Sources/BowlingLib/Class1.cs | 11 --------- Sources/BowlingLib/Model/Joueur.cs | 2 +- Sources/Tests/BowlingAppUnitTest/UnitTest1.cs | 16 ------------- .../BowlingAppUnitTest/UnitTestJoueur.cs | 24 +++++++++++++++++++ Sources/global.json | 7 ++++++ 5 files changed, 32 insertions(+), 28 deletions(-) delete mode 100644 Sources/BowlingLib/Class1.cs delete mode 100644 Sources/Tests/BowlingAppUnitTest/UnitTest1.cs create mode 100644 Sources/Tests/BowlingAppUnitTest/UnitTestJoueur.cs create mode 100644 Sources/global.json diff --git a/Sources/BowlingLib/Class1.cs b/Sources/BowlingLib/Class1.cs deleted file mode 100644 index 31eb072..0000000 --- a/Sources/BowlingLib/Class1.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; - -namespace HelloWorldLib -{ - /// - ///a sample class - /// - public class Class1 - { - } -} diff --git a/Sources/BowlingLib/Model/Joueur.cs b/Sources/BowlingLib/Model/Joueur.cs index 879038f..5bfd53d 100644 --- a/Sources/BowlingLib/Model/Joueur.cs +++ b/Sources/BowlingLib/Model/Joueur.cs @@ -16,7 +16,7 @@ namespace BowlingLib.Model if (pseudo == null || pseudo == "") { - throw new Exception("Le pseudo ne peut pas être vide"); + throw new ArgumentException("Le pseudo ne peut pas être vide"); } } diff --git a/Sources/Tests/BowlingAppUnitTest/UnitTest1.cs b/Sources/Tests/BowlingAppUnitTest/UnitTest1.cs deleted file mode 100644 index 69d7a2a..0000000 --- a/Sources/Tests/BowlingAppUnitTest/UnitTest1.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using HelloWorldLib; -using Xunit; - -namespace HelloWordLib_UnitTests -{ - public class UnitTest1 - { - [Fact] - public void Test1() - { - Class1 c = new Class1(); - Assert.NotNull(c); - } - } -} diff --git a/Sources/Tests/BowlingAppUnitTest/UnitTestJoueur.cs b/Sources/Tests/BowlingAppUnitTest/UnitTestJoueur.cs new file mode 100644 index 0000000..510031d --- /dev/null +++ b/Sources/Tests/BowlingAppUnitTest/UnitTestJoueur.cs @@ -0,0 +1,24 @@ +using System; +using BowlingLib.Model; +using Xunit; + +namespace Test.BowlingAppUnitTest +{ + public class UnitTestJoueur + { + [Fact] + public void TestConstructeur() + { + Joueur j = new Joueur("Paul"); + Assert.NotNull(j); + Assert.Equal(j.Pseudo, "Paul"); + Assert.NotEqual(j.Pseudo, "joel"); + } + + [Fact] + public void TestInvalidJoueur() + { + Assert.Throws(() => new Joueur(null)); + } + } +} diff --git a/Sources/global.json b/Sources/global.json new file mode 100644 index 0000000..87aef9f --- /dev/null +++ b/Sources/global.json @@ -0,0 +1,7 @@ +{ + "sdk": { + "version": "6.0.0", + "rollForward": "latestMajor", + "allowPrerelease": false + } +} \ No newline at end of file