⚙️ Mise à jour des tests de Player
continuous-integration/drone/push Build is failing Details

pull/67/head
Rémi LAVERGNE 1 year ago
parent e240c615d2
commit fa3dc96d98

@ -3,27 +3,41 @@ using Models.Game;
public class PlayerTests public class PlayerTests
{ {
[Theory]
[InlineData("Player", "DefaultProfilePicture")]
[InlineData("John Doe", "N/A.png")]
public void Constructor_WithPseudoAndProfilePicture_SetsPseudoAndProfilePictureCorrectly(string pseudo, string profilePicture)
{
var player = new Player(pseudo, profilePicture);
Assert.Equal(pseudo, player.Pseudo);
Assert.Equal(profilePicture, player.ProfilePicture);
}
[Fact] [Fact]
public void PlayerConstructorTest() public void Constructor_WithPseudoAndWithoutProfilePicture_SetsPseudoAndDefaultProfilePicture()
{ {
Player player = new Player(); var player = new Player("MyPlayer");
Assert.NotNull(player); Assert.Equal("MyPlayer", player.Pseudo);
Assert.Equal("Player", player.Pseudo);
Assert.Equal("DefaultProfilePicture", player.ProfilePicture); Assert.Equal("DefaultProfilePicture", player.ProfilePicture);
Player player2 = new Player("John Doe", "N/A.png");
Assert.Equal("John Doe", player2.Pseudo);
Assert.Equal("N/A.png", player2.ProfilePicture);
} }
[Fact] [Theory]
public void PlayerIsEqualTest() [InlineData("John Doe", "John Doe", true)]
[InlineData("John Doe", "Jane Doe", false)]
public void Equals_WithSameOrDifferentPseudo_ReturnsExpectedResult(string pseudo1, string pseudo2, bool expectedResult)
{ {
Player player = new Player("John"); var player1 = new Player(pseudo1);
Player player2 = new Player("John", "DefaultProfilePicture"); var player2 = new Player(pseudo2);
Player player3 = new Player("Inconnu","N/A"); Assert.Equal(expectedResult, player1.Equals(player2));
}
Assert.Equal(player, player2); [Theory]
Assert.NotEqual(player, player3); [InlineData("John Doe", "John Doe", true)]
[InlineData("John Doe", "Jane Doe", false)]
public void GetHashCode_ReturnsSameOrDifferentHashCodeForPseudo(string pseudo1, string pseudo2, bool expectedResult)
{
var player1 = new Player(pseudo1);
var player2 = new Player(pseudo2);
Assert.Equal(expectedResult, player1.GetHashCode() == player2.GetHashCode());
} }
} }
Loading…
Cancel
Save