/// <summary> ///Test for calculating the scores of strike balls ///</summary> public void CalculateStrike() { // Arrange Score score = new Score(); var frames = new List <Frame> { new Frame { FirstRoll = 10, SecondRoll = 0 }, new Frame { FirstRoll = 6, SecondRoll = 1 }, }; var gameManagerMock = new Mock <IGameManager>(); gameManagerMock.Setup(m => m.CalculateScore(frames)).Returns(score); var scoreController = new ScoreController(gameManagerMock.Object); // Act var actionResult = scoreController.CalculateScore(frames); // Assert var contentResult = Xunit.Assert.IsType <OkNegotiatedContentResult <Score> >(actionResult); contentResult.Content.Should().Equals(24); }
// ========= PUBLIC METHODS ========= // Attempts a continuation save and warns player if it isn't successful - returns true if successful, false otherwise public bool ContinuationSave() { if (!persistenceController.SaveGame(null)) { warningType = SaveLoadType.CONTINUATION_SAVE; OpenWarningDialogue(); return(false); } else { // Prepare a string for player prefs describing the continuation status for the current player string gameStatus; ScoreMode scoreMode; if (CurrentGameStatus == GameStatus.PLAYING) { gameStatus = "Game in progress (Current score: "; scoreMode = ScoreMode.INTERIM; } else { gameStatus = "Game ended (Final score: "; scoreMode = ScoreMode.FINAL; } int[] score = scoreController.CalculateScore(scoreMode); PlayerPrefs.SetString("Player" + PlayerPrefs.GetInt("CurrentPlayer") + "Status", gameStatus + score[0] + " of a possible " + score[1] + " in " + Turns + " turn" + (Turns != 1 ? "s)" : ")")); return(true); } }