public void GameOver_PressEnter_DontShowAnythingOtherThanTheGameOverInfo() { _presenter = new ImageQuizViewPresenter(_view.Object, new List <Image> { new Bitmap(1, 1) }); // should show last image _view.Setup(v => v.ImageWithBlocksIsVisible).Returns(false); _view.Raise(v => v.EnterPressed += null, this, EventArgs.Empty); // should show game over info _view.Setup(v => v.ImageWithBlocksIsVisible).Returns(true); _view.Raise(v => v.EnterPressed += null, this, EventArgs.Empty); _view.Invocations.Clear(); _view.Setup(v => v.ImageWithBlocksIsVisible).Returns(false); for (int i = 0; i <= 42; i++) { _view.Raise(v => v.EnterPressed += null, this, EventArgs.Empty); } _view.Verify(v => v.ShowInfo(It.Is <string>(s => !s.Contains("Game over"))), Times.Never); }
public void Init() { _view = new Mock <IImageQuizView>(); _images = new List <Image> { new Bitmap(1, 1), new Bitmap(2, 2), new Bitmap(3, 3) }; _presenter = new ImageQuizViewPresenter(_view.Object, _images); }
public void ImageVisible_BlocksGone_PressEnter_NoImagesLeft_GameOverInfoGetsShown_TimerGetsStopped() { var view = new Mock <IImageQuizView>(); view.Setup(v => v.AllBlocksAreGone).Returns(true); _presenter = new ImageQuizViewPresenter(view.Object, new List <Image> { new Bitmap(1, 1) }); // should show last image view.Setup(v => v.ImageWithBlocksIsVisible).Returns(false); view.Raise(v => v.EnterPressed += null, this, EventArgs.Empty); view.Invocations.Clear(); // should show game over info view.Setup(v => v.ImageWithBlocksIsVisible).Returns(true); view.Raise(v => v.EnterPressed += null, this, EventArgs.Empty); view.Verify(v => v.ShowInfo(It.Is <string>(s => s.Contains("Game over"))), Times.Once); view.Verify(v => v.EnableTimer(false), Times.Once); }
public void NoImages_ShowErrorLabel() { _presenter = new ImageQuizViewPresenter(_view.Object, new List <Image>()); _view.Verify(v => v.ShowInfo(It.Is <string>(s => s.Contains("No images were found."))), Times.Once); }