diff --git a/LOLAPP/LOLAPP/View/Strat.xaml.cs b/LOLAPP/LOLAPP/View/Strat.xaml.cs index 0627729..3d82116 100644 --- a/LOLAPP/LOLAPP/View/Strat.xaml.cs +++ b/LOLAPP/LOLAPP/View/Strat.xaml.cs @@ -68,7 +68,7 @@ namespace LOLAPP.View var strat = (Strategie)button.CommandParameter; // Gérez la suppression de la stratégie spécifiée ici - // Exemple : StratList.Remove(strat); + // StratList.Remove(strat); } } } diff --git a/LOLAPP/UniTests/UniTests.csproj b/LOLAPP/UniTests/UniTests.csproj index 020de70..5e9fe29 100644 --- a/LOLAPP/UniTests/UniTests.csproj +++ b/LOLAPP/UniTests/UniTests.csproj @@ -18,10 +18,8 @@ runtime; build; native; contentfiles; analyzers; buildtransitive + all - - - diff --git a/LOLAPP/UniTestss/UniTestAbility.cs b/LOLAPP/UniTestss/UniTestAbility.cs new file mode 100644 index 0000000..aadcffb --- /dev/null +++ b/LOLAPP/UniTestss/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/UniTestss/UniTestChampions.cs b/LOLAPP/UniTestss/UniTestChampions.cs new file mode 100644 index 0000000..ba2c146 --- /dev/null +++ b/LOLAPP/UniTestss/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/UniTestss/UniTestIPersistanceManager.cs b/LOLAPP/UniTestss/UniTestIPersistanceManager.cs new file mode 100644 index 0000000..56220ac --- /dev/null +++ b/LOLAPP/UniTestss/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/UniTestss/UniTestStrategie.cs b/LOLAPP/UniTestss/UniTestStrategie.cs new file mode 100644 index 0000000..e5af6c7 --- /dev/null +++ b/LOLAPP/UniTestss/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/UniTestss/UniTestUtilisateur.cs b/LOLAPP/UniTestss/UniTestUtilisateur.cs new file mode 100644 index 0000000..99aa583 --- /dev/null +++ b/LOLAPP/UniTestss/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/UniTestss/UniTests.csproj b/LOLAPP/UniTestss/UniTests.csproj new file mode 100644 index 0000000..020de70 --- /dev/null +++ b/LOLAPP/UniTestss/UniTests.csproj @@ -0,0 +1,27 @@ + + + + net7.0 + enable + enable + + false + true + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + diff --git a/LOLAPP/UniTestss/Usings.cs b/LOLAPP/UniTestss/Usings.cs new file mode 100644 index 0000000..8c927eb --- /dev/null +++ b/LOLAPP/UniTestss/Usings.cs @@ -0,0 +1 @@ +global using Xunit; \ No newline at end of file