Пример #1
0
        public void FullGameDrawWinTest()
        {
            //Arrange
            GameTicTacToe   game         = new GameTicTacToe();
            ActionResulting methodReturn = new ActionResulting();
            Position        positionTurn = new Position();

            int[,] turns = { { 0, 0 }, { 1, 1 }, { 1, 0 }, { 2, 0 }, { 0, 2 }, { 0, 1 }, { 2, 1 }, { 1, 2 }, { 2, 2 } };
            int numbersTurns = 9;

            //Act
            game.StartGame();
            for (int i = 0; i < numbersTurns; i++)
            {
                positionTurn.x = turns[i, 0];
                positionTurn.y = turns[i, 1];
                methodReturn   = MovementGameTicTacToe.MovimentGame(positionTurn, game.Player, game.Id.ToString());
                game.Player    = MovementGameTicTacToe.GetNextPlayer(game.Player);
            }

            //Assert
            Assert.IsTrue(methodReturn.StatusAction);
            Assert.AreEqual("Partida finalizada!", methodReturn.MessageAction);
            Assert.AreEqual("Draw", methodReturn.Winner);
        }
Пример #2
0
        public void GameNumberErrorTest()
        {
            //Arrange
            GameTicTacToe   game         = new GameTicTacToe();
            ActionResulting methodReturn = new ActionResulting();
            Position        positionTurn = new Position();

            //Act
            game.StartGame();
            positionTurn.x = 1;
            positionTurn.y = 0;
            methodReturn   = MovementGameTicTacToe.MovimentGame(positionTurn, game.Player, "guid-invalido-de-jogo");


            //Assert
            Assert.IsFalse(methodReturn.StatusAction);
            Assert.AreEqual("Partida não encontrada", methodReturn.MessageAction);
        }
Пример #3
0
        public ActionResult <ContentReturn> PostMoviment(GameMovement turn, string id)
        {
            ActionResulting ret = turn.Movement(id);

            if (ret.StatusAction)
            {
                return(Ok(new ContentReturn
                {
                    Msg = ret.MessageAction,
                    Winner = ret.Winner
                }));
            }
            else
            {
                return(BadRequest(new ContentReturn
                {
                    Msg = ret.MessageAction
                }));
            }
        }
Пример #4
0
        public void TurnErrorTest()
        {
            //Arrange
            GameTicTacToe   game         = new GameTicTacToe();
            ActionResulting methodReturn = new ActionResulting();
            Position        positionTurn = new Position();

            int[,] turns = { { 0, 0 }, { 1, 0 } };
            int numbersTurns = 2;

            //Act
            game.StartGame();
            for (int i = 0; i < numbersTurns; i++)
            {
                positionTurn.x = turns[i, 0];
                positionTurn.y = turns[i, 1];
                methodReturn   = MovementGameTicTacToe.MovimentGame(positionTurn, game.Player, game.Id.ToString());
            }

            //Assert
            Assert.IsFalse(methodReturn.StatusAction);
            Assert.AreEqual("Não é turno do jogador", methodReturn.MessageAction);
        }
Пример #5
0
            public override IDeepCopyable CopyTo(IDeepCopyable other)
            {
                var dest = other as CarePlanActivityComponent;

                if (dest != null)
                {
                    base.CopyTo(dest);
                    if (GoalElement != null)
                    {
                        dest.GoalElement = new List <Hl7.Fhir.Model.IdRef>(GoalElement.DeepCopy());
                    }
                    if (StatusElement != null)
                    {
                        dest.StatusElement = (Code <Hl7.Fhir.Model.CarePlan.CarePlanActivityStatus>)StatusElement.DeepCopy();
                    }
                    if (ProhibitedElement != null)
                    {
                        dest.ProhibitedElement = (Hl7.Fhir.Model.FhirBoolean)ProhibitedElement.DeepCopy();
                    }
                    if (ActionResulting != null)
                    {
                        dest.ActionResulting = new List <Hl7.Fhir.Model.ResourceReference>(ActionResulting.DeepCopy());
                    }
                    if (NotesElement != null)
                    {
                        dest.NotesElement = (Hl7.Fhir.Model.FhirString)NotesElement.DeepCopy();
                    }
                    if (Detail != null)
                    {
                        dest.Detail = (Hl7.Fhir.Model.ResourceReference)Detail.DeepCopy();
                    }
                    if (Simple != null)
                    {
                        dest.Simple = (Hl7.Fhir.Model.CarePlan.CarePlanActivitySimpleComponent)Simple.DeepCopy();
                    }
                    return(dest);
                }
                else
                {
                    throw new ArgumentException("Can only copy to an object of the same type", "other");
                }
            }