public void GameViewNewGameButtonClicked_WhenButtonClickedAndGameParameterIsNotNull_ShouldUpdateViewEliminateEach() { //Arrange var mockView = new Mock <IChildrensGameView>(); var mockRepo = new Mock <IGameRepository>(); var mockGameManager = new Mock <IChildrensGameManager>(); mockRepo.Setup(m => m.GetGameParameter()).Returns(Task.FromResult(new GameParameter())); var presenter = new ChildrensGamePresenter(mockView.Object, mockRepo.Object, mockGameManager.Object); //Act presenter.GameViewNewGameButtonClicked(mockView.Object, EventArgs.Empty); //Assert mockView.VerifySet(m => m.EliminateEach = It.IsAny <decimal>(), Times.Once); }
public void GameViewNewGameButtonClicked_WhenButtonClicked_ShouldCallRepositoryGetGameParameter() { //Arrange var mockView = new Mock <IChildrensGameView>(); var mockRepo = new Mock <IGameRepository>(); var mockGameManager = new Mock <IChildrensGameManager>(); mockRepo.Setup(m => m.GetGameParameter()).Verifiable(); var presenter = new ChildrensGamePresenter(mockView.Object, mockRepo.Object, mockGameManager.Object); //Act presenter.GameViewNewGameButtonClicked(mockView.Object, EventArgs.Empty); //Assert mockRepo.Verify(m => m.GetGameParameter(), Times.Once); }
public void GameViewNewGameButtonClicked_WhenButtonClickedAndGameParameterIsNull_ShouldCallViewShowErrorMessage() { //Arrange var mockView = new Mock <IChildrensGameView>(); var mockRepo = new Mock <IGameRepository>(); mockView.Setup(m => m.ShowErrorMessage(It.IsAny <string>())).Verifiable(); mockRepo.Setup(m => m.GetGameParameter()).Returns(Task.FromResult <GameParameter>(null)); var mockGameManager = new Mock <IChildrensGameManager>(); var presenter = new ChildrensGamePresenter(mockView.Object, mockRepo.Object, mockGameManager.Object); //Act presenter.GameViewNewGameButtonClicked(mockView.Object, EventArgs.Empty); //Assert mockView.Verify(m => m.ShowErrorMessage(It.IsAny <string>()), Times.Once); }
public void GameViewNewGameButtonClicked_WhenButtonClickedAndGameResultIsNotNull_ShouldUpdateViewWinner() { //Arrange var mockView = new Mock <IChildrensGameView>(); var mockRepo = new Mock <IGameRepository>(); var mockGameManager = new Mock <IChildrensGameManager>(); mockRepo.Setup(m => m.GetGameParameter()).Returns(Task.FromResult(new GameParameter())); mockRepo.Setup(m => m.SetGameResult(It.IsAny <GameResult>())).Returns(Task.FromResult(new GameResultPostResponse())); mockGameManager.Setup(m => m.CalculateGameResult(It.IsAny <GameParameter>())).Returns(Task.FromResult(new GameResult())); var presenter = new ChildrensGamePresenter(mockView.Object, mockRepo.Object, mockGameManager.Object); //Act presenter.GameViewNewGameButtonClicked(mockView.Object, EventArgs.Empty); //Assert mockView.VerifySet(m => m.Winner = It.IsAny <string>(), Times.Once); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); //Initialise view var view = new ChildrensGameView(); //Intialise repository IGameRepository repository = new GameRestRepository(Properties.Settings.Default.GameParameterAPIAddress); //Initialise game manager IChildrensGameManager gameManager = new ChildrensGameManager(); //Initialise presenter var presenter = new ChildrensGamePresenter(view, repository, gameManager); Application.Run(view); }
public void GameViewNewGameButtonClicked_WhenButtonClicked_ShouldCallRepositorySetGameResult() { //Arrange var mockView = new Mock <IChildrensGameView>(); var mockRepo = new Mock <IGameRepository>(); var mockGameManager = new Mock <IChildrensGameManager>(); mockView.Setup(m => m.HideLoading()).Verifiable(); mockRepo.Setup(m => m.GetGameParameter()).Returns(Task.FromResult(new GameParameter())); mockRepo.Setup(m => m.SetGameResult(It.IsAny <GameResult>())).Returns(Task.FromResult(new GameResultPostResponse())); mockRepo.Setup(m => m.SetGameResult(It.IsAny <GameResult>())).Verifiable(); var presenter = new ChildrensGamePresenter(mockView.Object, mockRepo.Object, mockGameManager.Object); //Act presenter.GameViewNewGameButtonClicked(mockView.Object, EventArgs.Empty); //Assert mockRepo.Verify(m => m.SetGameResult(It.IsAny <GameResult>()), Times.Once); }