Exemplo n.º 1
0
        public void Generate_WhenNoParamsGiven_ReturnsFullPreset()
        {
            var factory = new CardsFactory();
            var cards   = factory.Generate();

            Assert.That(cards.Count == 52);
        }
Exemplo n.º 2
0
        public void PickACardTest2()
        {
            int pickTimes           = -2;
            int ecpectedCardsAmount = pickTimes;

            Game targetGame   = new Game();
            int  playerButton = 1;

            for (int i = 0; i < pickTimes; i++)
            {
                targetGame.PickACard(playerButton);
            }
            int          actualCardslAmount = 0;
            CardsManager theManager         = targetGame.cardManager1;
            CardsFactory theFactory         = targetGame.cardFactory1;

            if (pickTimes <= 0)
            {
                ecpectedCardsAmount = 0;
            }
            else if (pickTimes < targetGame.cardManager1.cards.Count)
            {
                actualCardslAmount = theManager.cards.Count;
            }
            else if (pickTimes > theManager.cards.Count && theFactory.cards.Count > 0)
            {
                ecpectedCardsAmount = 5;
                actualCardslAmount  = theManager.cards.Count;
            }

            Assert.AreEqual(ecpectedCardsAmount, actualCardslAmount);
        }
Exemplo n.º 3
0
        public void Generate_AssignsColorsProperly(int index, Color desiredColor)
        {
            var factory = new CardsFactory();
            var cards   = factory.Generate();

            Assert.That(cards[index].Color == desiredColor);
        }
Exemplo n.º 4
0
        public void Generate_WhenParamGreaterThanFullPresetSize_ReturnsEmptySet(int length)
        {
            var factory = new CardsFactory();
            var cards   = factory.Generate(length);

            Assert.That(cards.Count == 0);
        }
Exemplo n.º 5
0
        public void Generate_WhenNonPositiveParamGiven_ReturnsEmptySet(int length)
        {
            var factory = new CardsFactory();
            var cards   = factory.Generate(length);

            Assert.That(cards.Count == 0);
        }
Exemplo n.º 6
0
        public void Generate_WhenParamGiven_ReturnsSubsetOfGivenLength(int length)
        {
            var factory = new CardsFactory();
            var cards   = factory.Generate(length);

            Assert.That(cards.Count == length);
        }
 public GameStarterService(IConfiguration config,
                           GameFactory gameFactory,
                           CardsFactory cardsFactory)
 {
     _appId        = config["MicrosoftAppId"];
     _appPassword  = config["MicrosoftAppPassword"];
     _gameFactory  = gameFactory;
     _cardsFactory = cardsFactory;
 }
        public void When_creating_new_list_of_cards_Should_be_shuffled()
        {
            var firstListOfCards  = CardsFactory.GetShuffledCards().ToList();
            var secondListOfCards = CardsFactory.GetShuffledCards().ToList();

            //ToDo add extension method for not in same order
            firstListOfCards.Should().BeEquivalentTo(secondListOfCards);
            //firstListOfCards.Should().BeEquivalentTo(secondListOfCards,
            //    options => options.WithStrictOrdering());
        }
Exemplo n.º 9
0
        public void CardFactoryConstructorTest()
        {
            const int cardNumber     = 10;
            string    expectedString = "杀手蜂";

            CardsFactory actualCardFactory = new CardsFactory("../../../duel/duelInfo.txt", 1);
            string       actualString      = actualCardFactory.cards[cardNumber - 1].ChineseName;

            Assert.AreEqual(expectedString, actualString);
        }
Exemplo n.º 10
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            CardsFactory  cardsFactory = new CardsFactory();
            Stack <ICard> cards        = cardsFactory.GetCardStack();

            Console.WriteLine(cards.ToString());
            //TODO: create factory for each component int board factory
            //TODO: create menu containing action class for each action from interface IACTiON and validation class for input validation in menu - type IValidation
        }
Exemplo n.º 11
0
        public void CardFactoryConstructorTest1()
        {
            string expectedChineseName = null;

            string       cardsInfoFileLocation = "C:\\Users\\yuwei\\Desktop\\duelInf"; //the test of wrong location
            CardsFactory target            = new CardsFactory(cardsInfoFileLocation, 1);
            Card         actualCard        = target.PopACard();
            string       actualChineseName = actualCard.ChineseName;

            Assert.AreEqual(expectedChineseName, actualChineseName);
        }
Exemplo n.º 12
0
        public void ShowCardsAmountTest()
        {
            string expectedCardsAmount = "剩余卡牌数:5";

            Form1 targetForm = new Form1();

            targetForm.InitGame();
            CardsFactory target = targetForm.duelGame.cardFactory1;

            target.ShowCardsAmount();
            string actualCardsAmount = DuelTextBoxes.managerBoxes[20].Text;

            Assert.AreEqual(expectedCardsAmount, actualCardsAmount);
        }
Exemplo n.º 13
0
        public void PopACardTest1()
        {
            string expectedChineseName = "Empty";

            int          PopedNumber = 11;
            CardsFactory target      = new CardsFactory("C:\\Users\\yuwei\\Desktop\\duelInfo.txt", 1);

            Card actual = target.PopACard();

            for (int i = 1; i < PopedNumber; i++)
            {
                actual = target.PopACard();
            }

            Assert.AreEqual(expectedChineseName, actual.ChineseName);
        }
Exemplo n.º 14
0
        public void PopACardTest()
        {
            string expectedChineseName = "杀手蜂";

            int          PopedNumber = 10;
            CardsFactory target      = new CardsFactory("../../../duel/duelInfo.txt", 1);

            Card actual = target.PopACard();

            for (int i = 1; i < PopedNumber; i++)
            {
                actual = target.PopACard();
            }

            Assert.AreEqual(expectedChineseName, actual.ChineseName);
        }
Exemplo n.º 15
0
        public void GetCardsTest()
        {
            var line     = "8C TS KC 9H 4S 7D 2S 5D 3S AC";
            var expected = new[]
            {
                new Card(new MinorCardNomination(8), Suit.Clubs),
                new Card(new MinorCardNomination(10), Suit.Spades),
                new Card(new MajorCardNomination(MajorCardType.King), Suit.Clubs),
                new Card(new MinorCardNomination(9), Suit.Hearts),
                new Card(new MinorCardNomination(4), Suit.Spades),
                new Card(new MinorCardNomination(7), Suit.Diamonds),
                new Card(new MinorCardNomination(2), Suit.Spades),
                new Card(new MinorCardNomination(5), Suit.Diamonds),
                new Card(new MinorCardNomination(3), Suit.Spades),
                new Card(new MajorCardNomination(MajorCardType.Ace), Suit.Clubs),
            };

            var selectMany = CardsFactory.GetCardSets(line).SelectMany(cards => cards).ToArray();

            Assert.IsTrue(selectMany.Zip(expected, (card1, card2) => card1 == card2).All(b => b));
        }
Exemplo n.º 16
0
        // Send a Rich Card response to the user based on their choice.
        // This method is only called when a valid prompt response is parsed from the user's response to the ChoicePrompt.
        private async Task <DialogTurnResult> ShowCardStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            _logger.LogInformation("MainDialog.ShowCardStepAsync");

            // Cards are sent as Attachments in the Bot Framework.
            // So we need to create a list of attachments for the reply activity.
            var attachments = new List <Attachment>();

            // Reply to the activity we received with an activity.
            var reply = MessageFactory.Attachment(attachments);

            // Decide which type of card(s) we are going to show the user
            switch (((FoundChoice)stepContext.Result).Value)
            {
            case "Adaptive Card":
                // Display an Adaptive Card
                reply.Attachments.Add(CardsFactory.CreateAdaptiveCardAttachment());
                break;

            case "Animation Card":
                // Display an AnimationCard.
                reply.Attachments.Add(CardsFactory.GetAnimationCard().ToAttachment());
                break;

            case "Audio Card":
                // Display an AudioCard
                reply.Attachments.Add(CardsFactory.GetAudioCard().ToAttachment());
                break;

            case "Hero Card":
                // Display a HeroCard.
                reply.Attachments.Add(CardsFactory.GetHeroCard().ToAttachment());
                break;

            case "Receipt Card":
                // Display a ReceiptCard.
                reply.Attachments.Add(CardsFactory.GetReceiptCard().ToAttachment());
                break;

            case "Signin Card":
                // Display a SignInCard.
                reply.Attachments.Add(CardsFactory.GetSigninCard().ToAttachment());
                break;

            case "Thumbnail Card":
                // Display a ThumbnailCard.
                reply.Attachments.Add(CardsFactory.GetThumbnailCard().ToAttachment());
                break;

            case "Video Card":
                // Display a VideoCard
                reply.Attachments.Add(CardsFactory.GetVideoCard().ToAttachment());
                break;

            default:
                // Display a carousel of all the rich card types.
                reply.AttachmentLayout = AttachmentLayoutTypes.Carousel;
                reply.Attachments.Add(CardsFactory.CreateAdaptiveCardAttachment());
                reply.Attachments.Add(CardsFactory.GetAnimationCard().ToAttachment());
                reply.Attachments.Add(CardsFactory.GetAudioCard().ToAttachment());
                reply.Attachments.Add(CardsFactory.GetHeroCard().ToAttachment());
                reply.Attachments.Add(CardsFactory.GetReceiptCard().ToAttachment());
                reply.Attachments.Add(CardsFactory.GetSigninCard().ToAttachment());
                reply.Attachments.Add(CardsFactory.GetThumbnailCard().ToAttachment());
                reply.Attachments.Add(CardsFactory.GetVideoCard().ToAttachment());
                break;
            }

            // Send the card(s) to the user as an attachment to the activity
            await stepContext.Context.SendActivityAsync(reply, cancellationToken);

            // Give the user instructions about what to do next
            await stepContext.Context.SendActivityAsync(MessageFactory.Text("Type anything to see another card."), cancellationToken);

            return(await stepContext.EndDialogAsync());
        }
Exemplo n.º 17
0
 private void Construct(CardsFactory cardsFactory) =>
 _cardsFactory = cardsFactory;