diff --git a/LOLAPP/UniTests/UniTestAbility.cs b/LOLAPP/UniTests/UniTestAbility.cs new file mode 100644 index 0000000..aadcffb --- /dev/null +++ b/LOLAPP/UniTests/UniTestAbility.cs @@ -0,0 +1,24 @@ +using Models; + +namespace Tests +{ + public class AbilityTests + { + [Fact] + public void Ability_Constructor_SetsProperties() + { + // Arrange + string name = "Capacité 1"; + string image = "image1.png"; + string description = "Description de la capacité"; + + // Act + var ability = new Ability(name, image, description); + + // Assert + Assert.Equal(name, ability.Name); + Assert.Equal(image, ability.Image); + Assert.Equal(description, ability.Description); + } + } +} diff --git a/LOLAPP/UniTests/UniTestChampions.cs b/LOLAPP/UniTests/UniTestChampions.cs new file mode 100644 index 0000000..ba2c146 --- /dev/null +++ b/LOLAPP/UniTests/UniTestChampions.cs @@ -0,0 +1,49 @@ +using Models; +using System.Collections.Generic; + +namespace Tests +{ + public class ChampionTests + { + [Fact] + public void Champion_ConstructorWithAbilities_SetsProperties() + { + // Arrange + string name = "Champion 1"; + string titre = "Titre du champion"; + string image = "image1.png"; + var abilities = new List() + { + new Ability("Capacité 1", "image1.png", "Description de la capacité 1"), + new Ability("Capacité 2", "image2.png", "Description de la capacité 2") + }; + + // Act + var champion = new Champion(name, titre, image, abilities); + + // Assert + Assert.Equal(name, champion.Name); + Assert.Equal(titre, champion.Titre); + Assert.Equal(image, champion.Image); + Assert.Equal(abilities, champion.Abilities); + } + + [Fact] + public void Champion_ConstructorWithoutAbilities_SetsProperties() + { + // Arrange + string name = "Champion 2"; + string titre = "Titre du champion"; + string image = "image2.png"; + + // Act + var champion = new Champion(name, titre, image); + + // Assert + Assert.Equal(name, champion.Name); + Assert.Equal(titre, champion.Titre); + Assert.Equal(image, champion.Image); + Assert.Empty(champion.Abilities); + } + } +} \ No newline at end of file diff --git a/LOLAPP/UniTests/UniTestIPersistanceManager.cs b/LOLAPP/UniTests/UniTestIPersistanceManager.cs new file mode 100644 index 0000000..56220ac --- /dev/null +++ b/LOLAPP/UniTests/UniTestIPersistanceManager.cs @@ -0,0 +1,49 @@ +using Moq; +using Models; + +namespace Tests +{ + public class IPersistanceManagerTests + { + [Fact] + public void ChargeDonne_ReturnsExpectedData() + { + // Arrange + var mockPersistance = new Mock(); + var expectedChampions = new List + { + new Champion("Champion 1", "Titre 1", "Image 1"), + new Champion("Champion 2", "Titre 2", "Image 2"), + }; + var expectedUtilisateurs = new List + { + new Utilisateur("Utilisateur 1"), + new Utilisateur("Utilisateur 2"), + }; + mockPersistance.Setup(p => p.Chargdon()) + .Returns((expectedChampions, expectedUtilisateurs)); + var manager = new Manager(mockPersistance.Object); + + // Act + manager.Chargdon(); + + // Assert + Assert.Equal(expectedChampions, manager._champions); + Assert.Equal(expectedUtilisateurs, manager._utilisateur); + } + + [Fact] + public void Sauvdon_CallsPersistanceManagerSauvdonMethod() + { + // Arrange + var mockPersistance = new Mock(); + var manager = new Manager(mockPersistance.Object); + + // Act + manager.Sauvdon(); + + // Assert + mockPersistance.Verify(p => p.Sauvdon(manager._champions, manager._utilisateur), Times.Once); + } + } +} diff --git a/LOLAPP/UniTests/UniTestStrategie.cs b/LOLAPP/UniTests/UniTestStrategie.cs new file mode 100644 index 0000000..e5af6c7 --- /dev/null +++ b/LOLAPP/UniTests/UniTestStrategie.cs @@ -0,0 +1,31 @@ +using Models; + +namespace Tests +{ + public class StrategieTests + { + [Fact] + public void CreerStrategie_AvecNomDescriptionEtChampions_Valide() + { + // Arrange + string nom = "Stratégie 1"; + string description = "Description de la stratégie"; + var champions = new List + { + new Champion("Champion 1", "Titre 1", "Image 1"), + new Champion("Champion 2", "Titre 2", "Image 2") + new Champion("Champion 3", "Titre 3", "Image 3") + new Champion("Champion 4", "Titre 4", "Image 4") + new Champion("Champion 5", "Titre 5", "Image 5") + }; + + // Act + var strategie = new Strategie(nom, description, champions); + + // Assert + Assert.Equal(nom, strategie.Name); + Assert.Equal(description, strategie.Description); + Assert.Equal(champions, strategie.Champions); + } + } +} diff --git a/LOLAPP/UniTests/UniTestUtilisateur.cs b/LOLAPP/UniTests/UniTestUtilisateur.cs new file mode 100644 index 0000000..99aa583 --- /dev/null +++ b/LOLAPP/UniTests/UniTestUtilisateur.cs @@ -0,0 +1,50 @@ +using Xunit; +using Moq; +using Models; + +namespace Tests +{ + public class IPersistanceManagerTests + { + [Fact] + public void ChargeDonne_ReturnsExpectedData() + { + // Arrange + var mockPersistance = new Mock(); + var expectedChampions = new List + { + new Champion("Champion 1", "Titre 1", "Image 1"), + new Champion("Champion 2", "Titre 2", "Image 2"), + }; + var expectedUtilisateurs = new List + { + new Utilisateur("Utilisateur 1"), + new Utilisateur("Utilisateur 2"), + }; + mockPersistance.Setup(p => p.Chargdon()) + .Returns((expectedChampions, expectedUtilisateurs)); + var manager = new Manager(mockPersistance.Object); + + // Act + manager.Chargdon(); + + // Assert + Assert.Equal(expectedChampions, manager._champions); + Assert.Equal(expectedUtilisateurs, manager._utilisateur); + } + + [Fact] + public void Sauvdon_CallsPersistanceManagerSauvdonMethod() + { + // Arrange + var mockPersistance = new Mock(); + var manager = new Manager(mockPersistance.Object); + + // Act + manager.Sauvdon(); + + // Assert + mockPersistance.Verify(p => p.Sauvdon(manager._champions, manager._utilisateur), Times.Once); + } + } +} diff --git a/LOLAPP/UniTests/UniTests.csproj b/LOLAPP/UniTests/UniTests.csproj new file mode 100644 index 0000000..5e9fe29 --- /dev/null +++ b/LOLAPP/UniTests/UniTests.csproj @@ -0,0 +1,25 @@ + + + + net7.0 + enable + enable + + false + true + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + diff --git a/LOLAPP/UniTests/Usings.cs b/LOLAPP/UniTests/Usings.cs new file mode 100644 index 0000000..8c927eb --- /dev/null +++ b/LOLAPP/UniTests/Usings.cs @@ -0,0 +1 @@ +global using Xunit; \ No newline at end of file diff --git a/LOLAPP/UniTetsts/UniTestIPersistanceManager - Copie (2).cs b/LOLAPP/UniTetsts/UniTestIPersistanceManager - Copie (2).cs deleted file mode 100644 index e69de29..0000000 diff --git a/LOLAPP/UniTetsts/UniTestIPersistanceManager - Copie (3).cs b/LOLAPP/UniTetsts/UniTestIPersistanceManager - Copie (3).cs deleted file mode 100644 index e69de29..0000000 diff --git a/LOLAPP/UniTetsts/UniTestIPersistanceManager - Copie (4).cs b/LOLAPP/UniTetsts/UniTestIPersistanceManager - Copie (4).cs deleted file mode 100644 index e69de29..0000000 diff --git a/LOLAPP/UniTetsts/UniTestIPersistanceManager - Copie.cs b/LOLAPP/UniTetsts/UniTestIPersistanceManager - Copie.cs deleted file mode 100644 index e69de29..0000000 diff --git a/LOLAPP/UniTetsts/UniTestIPersistanceManager.cs b/LOLAPP/UniTetsts/UniTestIPersistanceManager.cs deleted file mode 100644 index e69de29..0000000