Пример #1
0
        public void IsSolved_SolvedPlayfield_ReturnsTrue()
        {
            // arrange
            IGame testedGame = new Impl.Game(_defaultGameSettings);

            // act
            bool isTestPlayfieldSolved = testedGame.IsSolved();

            // assert
            Assert.IsTrue(isTestPlayfieldSolved);
        }
Пример #2
0
        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));
        }
Пример #3
0
        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);
        }
Пример #4
0
        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);
        }
Пример #5
0
        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);
        }
Пример #6
0
        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));
        }
Пример #7
0
        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);
        }