|
|
@ -73,7 +73,7 @@ namespace Tests.Model_UTs
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
[Fact]
|
|
|
|
public void TestAddwhenNullThenThrowsException()
|
|
|
|
public void TestAddWhenNullThenThrowsException()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Arrange
|
|
|
|
// Arrange
|
|
|
|
|
|
|
|
|
|
|
@ -90,7 +90,7 @@ namespace Tests.Model_UTs
|
|
|
|
[InlineData("")]
|
|
|
|
[InlineData("")]
|
|
|
|
[InlineData(null)]
|
|
|
|
[InlineData(null)]
|
|
|
|
[InlineData(" ")]
|
|
|
|
[InlineData(" ")]
|
|
|
|
public void TestGetOneByNameIfInvalidThrowsException(string name)
|
|
|
|
public void TestGetOneByNameWhenInvalidThenThrowsException(string name)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Arrange
|
|
|
|
// Arrange
|
|
|
|
|
|
|
|
|
|
|
@ -103,7 +103,7 @@ namespace Tests.Model_UTs
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
[Fact]
|
|
|
|
public void TestGetOneByNameIfValidButNotExistThenReturnNull()
|
|
|
|
public void TestGetOneByNameWhenValidButNotExistThenReturnNull()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Arrange
|
|
|
|
// Arrange
|
|
|
|
|
|
|
|
|
|
|
@ -116,7 +116,7 @@ namespace Tests.Model_UTs
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
[Fact]
|
|
|
|
public void TestGetOneByNameIfValidThenReturnGame()
|
|
|
|
public void TestGetOneByNameWhenValidThenReturnGame()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Arrange
|
|
|
|
// Arrange
|
|
|
|
GameRunner gameRunner = new(new PlayerManager(), new DieManager());
|
|
|
|
GameRunner gameRunner = new(new PlayerManager(), new DieManager());
|
|
|
@ -131,42 +131,45 @@ namespace Tests.Model_UTs
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
[Fact]
|
|
|
|
public void TestRemoveWorksIfExists()
|
|
|
|
public void TestWhenRemoveExistsThenSucceeds()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Arrange
|
|
|
|
// Arrange
|
|
|
|
|
|
|
|
Game game = new("blargh", new PlayerManager(), stubGameRunner.GetAll().First().Dice);
|
|
|
|
|
|
|
|
stubGameRunner.Add(game);
|
|
|
|
|
|
|
|
|
|
|
|
// Act
|
|
|
|
// Act
|
|
|
|
|
|
|
|
stubGameRunner.Remove(game);
|
|
|
|
|
|
|
|
|
|
|
|
// Assert
|
|
|
|
// Assert
|
|
|
|
|
|
|
|
Assert.DoesNotContain(game, stubGameRunner.GetAll());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
[Fact]
|
|
|
|
public void TestRemoveThrowsExceptionIfGivenNull()
|
|
|
|
public void TestRemoveWhenGivenNullThenThrowsException()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Arrange
|
|
|
|
// Arrange
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Act
|
|
|
|
// Act
|
|
|
|
|
|
|
|
void action() => stubGameRunner.Remove(null);
|
|
|
|
|
|
|
|
|
|
|
|
// Assert
|
|
|
|
// Assert
|
|
|
|
|
|
|
|
Assert.Throws<ArgumentNullException>(action);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
[Fact]
|
|
|
|
public void TestRemoveFailsSilentlyIfGivenNonExistent()
|
|
|
|
public void TestRemoveWhenGiveenNonExistentThenFailsSilently()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Arrange
|
|
|
|
// Arrange
|
|
|
|
|
|
|
|
Game notGame = new("blargh", new PlayerManager(), stubGameRunner.GetAll().First().Dice);
|
|
|
|
|
|
|
|
IEnumerable<Game> expected = stubGameRunner.GetAll();
|
|
|
|
|
|
|
|
|
|
|
|
// Act
|
|
|
|
// Act
|
|
|
|
|
|
|
|
stubGameRunner.Remove(notGame);
|
|
|
|
|
|
|
|
IEnumerable<Game> actual = stubGameRunner.GetAll();
|
|
|
|
|
|
|
|
|
|
|
|
// Assert
|
|
|
|
// Assert
|
|
|
|
|
|
|
|
Assert.Equal(actual, expected);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
[Fact]
|
|
|
@ -182,23 +185,6 @@ namespace Tests.Model_UTs
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Theory]
|
|
|
|
|
|
|
|
[InlineData("Filibert", "filibert")]
|
|
|
|
|
|
|
|
[InlineData("Filibert", " fiLibert")]
|
|
|
|
|
|
|
|
[InlineData("Filibert", "FIlibert ")]
|
|
|
|
|
|
|
|
[InlineData(" Filibert", " filiBErt ")]
|
|
|
|
|
|
|
|
public void TestUpdateDiscreetlyUpdatesCaseAndIgnoresExtraSpaceIfOtherwiseSame(string n1, string n2)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// Arrange
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Act
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Assert
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Theory]
|
|
|
|
[Theory]
|
|
|
|
[InlineData("")]
|
|
|
|
[InlineData("")]
|
|
|
|
[InlineData(" ")]
|
|
|
|
[InlineData(" ")]
|
|
|
|