|
|
@ -26,7 +26,7 @@ namespace Tests.Model_UTs
|
|
|
|
Player player;
|
|
|
|
Player player;
|
|
|
|
|
|
|
|
|
|
|
|
// Act
|
|
|
|
// Act
|
|
|
|
Action action = () => player = new(" ");
|
|
|
|
void action() => player = new(" ");
|
|
|
|
|
|
|
|
|
|
|
|
// Assert
|
|
|
|
// Assert
|
|
|
|
Assert.Throws<ArgumentException>(action);
|
|
|
|
Assert.Throws<ArgumentException>(action);
|
|
|
@ -39,7 +39,7 @@ namespace Tests.Model_UTs
|
|
|
|
Player player;
|
|
|
|
Player player;
|
|
|
|
|
|
|
|
|
|
|
|
// Act
|
|
|
|
// Act
|
|
|
|
Action action = () => player = new("");
|
|
|
|
void action() => player = new("");
|
|
|
|
|
|
|
|
|
|
|
|
// Assert
|
|
|
|
// Assert
|
|
|
|
Assert.Throws<ArgumentException>(action);
|
|
|
|
Assert.Throws<ArgumentException>(action);
|
|
|
@ -50,9 +50,10 @@ namespace Tests.Model_UTs
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Arrange
|
|
|
|
// Arrange
|
|
|
|
Player player;
|
|
|
|
Player player;
|
|
|
|
|
|
|
|
string name = null;
|
|
|
|
|
|
|
|
|
|
|
|
// Act
|
|
|
|
// Act
|
|
|
|
Action action = () => player = new(null);
|
|
|
|
void action() => player = new Player(name);
|
|
|
|
|
|
|
|
|
|
|
|
// Assert
|
|
|
|
// Assert
|
|
|
|
Assert.Throws<ArgumentException>(action);
|
|
|
|
Assert.Throws<ArgumentException>(action);
|
|
|
@ -98,6 +99,23 @@ namespace Tests.Model_UTs
|
|
|
|
Assert.False(player.Equals(point));
|
|
|
|
Assert.False(player.Equals(point));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
|
|
|
public void TestGoesThruIfObjIsPlayer()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// Arrange
|
|
|
|
|
|
|
|
Object p1;
|
|
|
|
|
|
|
|
Player p2;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Act
|
|
|
|
|
|
|
|
p1 = new Player("Marvin");
|
|
|
|
|
|
|
|
p2 = new("Clyde");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Assert
|
|
|
|
|
|
|
|
Assert.False(p1.Equals(p2));
|
|
|
|
|
|
|
|
Assert.False(p2.Equals(p1));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
[Fact]
|
|
|
|
public void TestEqualsFalseIfNotSameName()
|
|
|
|
public void TestEqualsFalseIfNotSameName()
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -193,5 +211,34 @@ namespace Tests.Model_UTs
|
|
|
|
Assert.True(p1.GetHashCode().Equals(p2.GetHashCode()));
|
|
|
|
Assert.True(p1.GetHashCode().Equals(p2.GetHashCode()));
|
|
|
|
Assert.True(p2.GetHashCode().Equals(p1.GetHashCode()));
|
|
|
|
Assert.True(p2.GetHashCode().Equals(p1.GetHashCode()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
|
|
|
public void TestCopyConstructorExactCopy()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// Arrange
|
|
|
|
|
|
|
|
Player p1;
|
|
|
|
|
|
|
|
Player p2;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Act
|
|
|
|
|
|
|
|
p1 = new("Elyse");
|
|
|
|
|
|
|
|
p2 = new(p1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Assert
|
|
|
|
|
|
|
|
Assert.True(p1.Equals(p2));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
|
|
|
public void TestCopyConstructorIfNullThenException()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// Arrange
|
|
|
|
|
|
|
|
Player p1;
|
|
|
|
|
|
|
|
Player p2 = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Act
|
|
|
|
|
|
|
|
void action() => p1 = new Player(p2);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Assert
|
|
|
|
|
|
|
|
Assert.Throws<ArgumentException>(action);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|