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

pull/67/head
Rémi LAVERGNE 11 months ago
parent e240c615d2
commit fa3dc96d98

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