public void IsSolved_SolvedPlayfield_ReturnsTrue() { // arrange IGame testedGame = new Impl.Game(_defaultGameSettings); // act bool isTestPlayfieldSolved = testedGame.IsSolved(); // assert Assert.IsTrue(isTestPlayfieldSolved); }
public void RestoreSettingsFromMemento_TestSettings_SettingsInGameRestoredFromMemento() { // arrange Mock <IPlayfield> playfieldStub = new Mock <IPlayfield>(); GameMemento testMemento = new GameMemento(_testGameSettings, 15, playfieldStub.Object); IGame testedGame = new Impl.Game(_defaultGameSettings); // act testedGame.RestoreFromMemento(testMemento); // assert Assert.That(testedGame.Settings, Is.EqualTo(testMemento.Settings)); }
public void IsSolved_UnsolvedPlayfield_ReturnsFalse() { // arrange IGame testedGame = new Impl.Game(_defaultGameSettings); Manipulator.GetInstance().MakeMove(testedGame.Playfield, Direction.Up, false); // act bool isTestPlayfieldSolved = testedGame.IsSolved(); // assert Assert.IsFalse(isTestPlayfieldSolved); }
public void IncrementMovesNumber_NumberBeforeIncrementation_ReturnsNumberBeforeIncrementationPlusOne() { // arrange IGame testedGame = new Impl.Game(_defaultGameSettings); int movesBefore = testedGame.Moves; int expectedValue = movesBefore + 1; // act testedGame.IncrementMovesNumber(); // assert Assert.AreEqual(expectedValue, testedGame.Moves); }
public void IsSolved_SolvedPlayfield_GameWonEventInvoked() { // arrange IGame testedGame = new Impl.Game(_defaultGameSettings); bool wasEventInvoked = false; testedGame.NotifyOnGameWon += () => wasEventInvoked = true; // act bool isTestPlayfieldSolved = testedGame.IsSolved(); // assert Assert.IsTrue(wasEventInvoked); }
public void RestorePlayfieldFromMemento_TestPlayfield_PlayfieldInGameRestoredFromMemento(Frame[,] randomBoard) { // arrange Mock <IPlayfield> playfieldStub = new Mock <IPlayfield>(); playfieldStub.SetupGet(x => x.Board).Returns(randomBoard); GameMemento mementoStub = new GameMemento(_defaultGameSettings, 15, playfieldStub.Object); IGame testedGame = new Impl.Game(_defaultGameSettings); // act testedGame.RestoreFromMemento(mementoStub); // assert Assert.That(testedGame.Playfield, Is.EqualTo(mementoStub.Playfield)); }
public void IsSolved_UnolvedPlayfield_NoEventInvokation() { // arrange IGame testedGame = new Impl.Game(_defaultGameSettings); Manipulator.GetInstance().MakeMove(testedGame.Playfield, Direction.Up, false); bool wasEventCalled = false; testedGame.NotifyOnGameWon += () => wasEventCalled = true; // act bool isTestPlayfieldSolved = testedGame.IsSolved(); // assert Assert.IsFalse(wasEventCalled); }