Пример #1
0
        public void CreateNewCardWithNullIdTest()
        {
            InitAppSettings();
            var card_controller = new CardController();
            var card            = card_controller.Create(nullId);

            Assert.IsNotNull(card);
        }
Пример #2
0
        public void CutDeckWithValidIdTest()
        {
            InitAppSettings();
            var card_controller = new CardController();
            var card            = card_controller.Create(validId);

            var ret = card_controller.Cut(validId);

            Assert.IsNotNull(ret);
        }
Пример #3
0
        public void ReturnDeckWithNullIdTest()
        {
            InitAppSettings();
            var card_controller = new CardController();
            var card            = card_controller.Create(validId);

            var ret = card_controller.ReturnDeck(nullId);

            Assert.IsNull(ret);
        }
Пример #4
0
        public void PopDeckWithNullIdTest()
        {
            InitAppSettings();
            var card_controller = new CardController();
            var card            = card_controller.Create(validId);

            var ret = card_controller.Pop(nullId);

            Assert.IsTrue(ret == -1);
        }
Пример #5
0
        public void PopDeckWithValidIdTest()
        {
            InitAppSettings();
            var card_controller = new CardController();
            var card            = card_controller.Create(validId);

            var ret = card_controller.Pop(validId);

            Assert.IsTrue(ret >= 0 && ret < Card.NumberOfCardsInDeck);
        }
Пример #6
0
        public void ShuffleDeckWithInValidIdTest()
        {
            InitAppSettings();
            var card_controller = new CardController();
            var card            = card_controller.Create(validId);

            var ret = card_controller.Shuffle(invalidId);

            Assert.IsNull(ret);
        }
Пример #7
0
        public void CutDeckWithNullIdInValidOffsetTest()
        {
            InitAppSettings();
            var card_controller = new CardController();
            var card            = card_controller.Create(validId);

            var ret = card_controller.Cut(nullId, invalidOffset);

            Assert.IsNull(ret);
        }
        public void CreateCard_ShouldReturnViewResult()
        {
            // Arrange
            var            mockWallet = new Mock <IWalletWebService>();
            var            mockCard   = new Mock <ICardWebService>();
            CardController controller = new CardController(mockCard.Object, mockWallet.Object);

            // Act
            var result = controller.Create(1);

            // Assert
            Assert.That(result, Is.TypeOf <ViewResult>());
        }
Пример #9
0
        public void PopDeckWithValidIdTest2()
        {
            InitAppSettings();
            var card_controller = new CardController();
            var card            = card_controller.Create(validId);

            var ret = -1;

            for (int i = 0; i <= Card.NumberOfCardsInDeck; i++)
            {
                ret = card_controller.Pop(validId);
            }
            Assert.IsTrue(ret == -1);
        }
Пример #10
0
    // TODO : Animation
    public void AddCardToHand(BaseCard card)
    {
        if (Hand.Count < MaxCardsInHand)
        {
            card.Controller = CardController.Create(card);
            Hand.Add(card);
        }
        else
        {
            // TODO : Destroy card because hand is full
        }

        // Updating the Player glows
        UpdateSprites();
    }
Пример #11
0
        public void CreateCard_Test()
        {
            var service  = new Mock <CardService>();
            var fakeCard = new Mock <CardCreateDto>();

            // Arrange
            service.Setup(x => x.Create(fakeCard.Object))
            .Returns(new CardDto());

            // Act
            var controller = new CardController(service.Object, new Mock <OrderService>().Object);
            var result     = controller.Create(fakeCard.Object);

            // Assert
            Assert.IsType <OkResult>(result);
        }
        public async Task CreateCard_ShouldCallCreateCardInBlOnce()
        {
            //Arrange
            CardViewModel cardVM = new CardViewModel
            {
                Description = "Description",
            };
            var            mockWallet = new Mock <IWalletWebService>();
            var            mockCard   = new Mock <ICardWebService>();
            CardController controller = new CardController(mockCard.Object, mockWallet.Object);

            mockCard.Setup(x => x.Create(It.IsAny <CardViewModel>())).ReturnsAsync(It.IsAny <CardViewModel>());

            //Act
            await controller.Create(cardVM);

            //Assert
            mockCard.Verify(x => x.Create(It.IsAny <CardViewModel>()), Times.Once);
        }
Пример #13
0
    public BaseCard DrawFromDeck(BaseCard card)
    {
        if (Deck.Contains(card))
        {
            if (Hand.Count < MaxCardsInHand)
            {
                // Moving the card to the Hand
                Hand.Add(card);
                Deck.Remove(card);

                // Creating the visual controller for the card
                CardController cardController = CardController.Create(card);
                card.Controller = cardController;

                // Adding the Cardcontroller to the HandController
                HandController.Add(cardController);

                // Firing OnDrawn events
                card.OnDrawn();
                EventManager.Instance.OnCardDrawn(this, card);

                // Updating the Player glows
                UpdateSprites();

                return(card);
            }
            else
            {
                // TODO : Discard the card

                // Updating the Player glows
                UpdateSprites();
            }
        }

        return(null);
    }