Ejemplo n.º 1
0
        public void WhenPieceIsAddedToChain_IfThisPMsPiece_IsOnProperty_IsTrue()
        {
            GamePiecePM systemUnderTest = CreateSystem();

            systemUnderTest.OnPieceAddedToChain(MockPiece);

            Assert.IsTrue(systemUnderTest.ViewModel.GetPropertyValue <bool>(GamePiecePM.IS_ON_PROPERTY));
        }
Ejemplo n.º 2
0
        public void WhenCreating_PieceTypeProperty_MatchesPieceType()
        {
            MockPiece.PieceType.Returns(3);

            GamePiecePM systemUnderTest = CreateSystem();

            Assert.AreEqual("3", systemUnderTest.ViewModel.GetPropertyValue <string>(GamePiecePM.PIECE_TYPE_PROPERTY));
        }
Ejemplo n.º 3
0
        public void WhenDisposing_UnsubscribesToExpectedMessages()
        {
            GamePiecePM systemUnderTest = CreateSystem();

            systemUnderTest.Dispose();

            MyMessenger.Instance.Received().RemoveListener <IGamePiece>(GameMessages.PIECE_ADDED_TO_CHAIN, Arg.Any <Callback <IGamePiece> >());
        }
Ejemplo n.º 4
0
        public void GetAnimState_ReturnsExpected_BasedOnState(GamePieceStates i_state, string i_expectedValue)
        {
            GamePiecePM systemUnderTest = CreateSystem();

            string state = systemUnderTest.GetAnimState(i_state);

            Assert.AreEqual(i_expectedValue, state);
        }
Ejemplo n.º 5
0
 private void CreateGamePiecePMs()
 {
     foreach (IGamePiece piece in GameBoard.BoardPieces)
     {
         IGamePiecePM piecePM = new GamePiecePM(piece);
         GamePiecePMs.Add(piecePM);
     }
 }
Ejemplo n.º 6
0
        public void WhenPieceIsAddedToChain_IfNotPMsPiece_IsOnProperty_IsFalse()
        {
            IGamePiece  notSamePiece    = Substitute.For <IGamePiece>();
            GamePiecePM systemUnderTest = CreateSystem();

            systemUnderTest.OnPieceAddedToChain(notSamePiece);

            Assert.IsFalse(systemUnderTest.ViewModel.GetPropertyValue <bool>(GamePiecePM.IS_ON_PROPERTY));
        }
Ejemplo n.º 7
0
        public void WhenPieceAnimation_IsComplete_PieceState_IsSelectable()
        {
            GamePiecePM systemUnderTest = CreateSystem();

            systemUnderTest.ViewModel.SetProperty(GamePiecePM.IS_ON_PROPERTY, Color.yellow);

            systemUnderTest.OnAnimationComplete();

            MockPiece.Received().State = GamePieceStates.Selectable;
        }
Ejemplo n.º 8
0
        public void WhenPieceAnimation_IsComplete_IsOnProperty_IsFalse()
        {
            GamePiecePM systemUnderTest = CreateSystem();

            systemUnderTest.ViewModel.SetProperty(GamePiecePM.IS_ON_PROPERTY, Color.yellow);

            systemUnderTest.OnAnimationComplete();

            Assert.IsFalse(systemUnderTest.ViewModel.GetPropertyValue <bool>(GamePiecePM.IS_ON_PROPERTY));
        }
Ejemplo n.º 9
0
        public void WhenModelUpdated_PropertiesAsExpected()
        {
            MockPiece.PieceType.Returns(0);
            MockPiece.State = GamePieceStates.Correct;
            GamePiecePM systemUnderTest = CreateSystem();

            Assert.AreEqual("0", systemUnderTest.ViewModel.GetPropertyValue <string>(GamePiecePM.PIECE_TYPE_PROPERTY));
            Assert.AreEqual(GamePiecePM.CHAIN_COMPLETE_TRIGGER, systemUnderTest.ViewModel.GetPropertyValue <string>(GamePiecePM.TRIGGER_PROPERTY + "0"));

            MockPiece.PieceType.Returns(1);
            MockPiece.State.Returns(GamePieceStates.Incorrect);
            MockPiece.ModelUpdated += Raise.Event <ModelUpdateHandler>();

            Assert.AreEqual("1", systemUnderTest.ViewModel.GetPropertyValue <string>(GamePiecePM.PIECE_TYPE_PROPERTY));
            Assert.AreEqual(GamePiecePM.CHAIN_DROPPED_TRIGGER, systemUnderTest.ViewModel.GetPropertyValue <string>(GamePiecePM.TRIGGER_PROPERTY + "1"));
        }
Ejemplo n.º 10
0
        public void WhenCreating_IsOnProperty_IsFalse()
        {
            GamePiecePM systemUnderTest = CreateSystem();

            Assert.IsFalse(systemUnderTest.ViewModel.GetPropertyValue <bool>(GamePiecePM.IS_ON_PROPERTY));
        }
Ejemplo n.º 11
0
        private GamePiecePM CreateSystem()
        {
            GamePiecePM systemUnderTest = new GamePiecePM(MockPiece);

            return(systemUnderTest);
        }