public void ShouldThrowOnSaveGameAsGameResultIsNull() { var ghs = new GameHistoryService(_gameContext); var ex = Assert.Throws <ArgumentNullException>(() => ghs.Save(null)); Assert.That(ex.ParamName, Is.EqualTo("gameResult")); }
public void ShouldThrowOnSaveGameAsPlayerResultZeroIsNull() { var ghs = new GameHistoryService(_gameContext); var gameResult = new GameResult() { PlayerResults = new PlayerResult[1] }; var ex = Assert.Throws <ArgumentNullException>(() => ghs.Save(gameResult)); Assert.That(ex.ParamName, Is.EqualTo("gameResult.PlayerResults.0")); }
public void ShouldSaveGameWithPlayerIdNullAsResultHasMultipleHighScores() { var ghs = new GameHistoryService(_gameContext); var gameResult = new GameResult { PlayerResults = new PlayerResult[] { GetPlayerResult(player: 234, points: 111), GetPlayerResult(player: 123, points: 111), } }; var savedGame = ghs.Save(gameResult); Assert.That(savedGame.Id, Is.GreaterThan(0)); Assert.That(savedGame.PlayerId, Is.EqualTo(null)); var foundGame = _gameContext.Games.Single(x => x.Id == savedGame.Id); Assert.That(savedGame.PlayerId, Is.EqualTo(savedGame.PlayerId)); }