コード例 #1
0
        public void Cards_IndexOfCard()
        {
            Deck deck = new Deck(true);
            CardValue card = CardValue.FourOfClubs;

            Assert.AreEqual(3, deck.IndexOfCard(card));
        }
コード例 #2
0
        public void Cards_IsCompleteDeck_WithoutJokers()
        {
            Deck deck = new Deck(false);
            Deck manualDeck = new Deck(new List<int>() { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52 });
            //List<int> manualDeck = new List<int>() { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52 };

            Assert.AreEqual(manualDeck.Cards.OrderBy(c => c), deck.Cards.OrderBy(c => c));
        }
コード例 #3
0
        public void Cards_AreOrdered_WithJokers()
        {
            Deck deck = new Deck(true);
            Deck manualDeck = new Deck(new List<int>() { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54 });
            //List<int> manualDeck = new List<int>() { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54 };

            Assert.AreEqual(manualDeck.Cards, deck.Cards);
        }
コード例 #4
0
        public static string Encode(string message, Deck deck)
        {
            string newMessage = Sanitize(message);
            string keystream = GenerateKeystream(deck, newMessage.Length);

            IEnumerable<int> cipherNumbers = newMessage.ConvertToNumbersList().Zip(keystream.ConvertToNumbersList(), MergeEncode);
            return cipherNumbers.ConvertToLettersList().GroupsOf(5, " ");
        }
コード例 #5
0
ファイル: Problem1.cs プロジェクト: cthibault/RubyQuiz_CSharp
        public static void Run(string message, bool encode)
        {
            Deck deck = new Deck(true);
            string output = encode ? SolitaireCipher.Encode(message, deck) : SolitaireCipher.Decode(message, deck);

            Console.WriteLine(string.Format("Original Message: {0}", message));
            Console.WriteLine(string.Format("Output: {0}", output));
            Console.WriteLine();
        }
コード例 #6
0
        public void CountCut_LessThanWholeDeck()
        {
            Deck deck = new Deck(new List<int>() { 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 2 });
            Deck manualDeck = new Deck(new List<int>() { 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 1, 3, 2 });
            //List<int> manualDeck = new List<int>() { 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 1, 3, 2 };

            deck.CountCut();

            Assert.AreEqual(manualDeck.Cards, deck.Cards);
        }
コード例 #7
0
        public static string GenerateKeystream(Deck deck, int length)
        {
            StringBuilder keystream = new StringBuilder();
            while (keystream.Length < length)
            {
                deck.MoveCardDown(CardValue.JokerA, 1);
                deck.MoveCardDown(CardValue.JokerB, 2);
                deck.TripleCut(CardValue.JokerA, CardValue.JokerB);
                deck.CountCut();

                CardValue outputCard = deck.Cards.Take((int)deck.Cards.First() + 1).Last();

                if (!Deck.IsJoker(outputCard))
                    keystream.Append(outputCard.ConvertToLetter());
            }

            return keystream.ToString();
        }
コード例 #8
0
ファイル: Deck.cs プロジェクト: cthibault/RubyQuiz_CSharp
        public bool Equals(Deck otherDeck)
        {
            if (otherDeck == null) return false;

            return Cards.SequenceEqual(otherDeck.Cards);
        }
コード例 #9
0
 public void Deck_Equal()
 {
     Deck deck = new Deck(true);
     Assert.AreEqual(new Deck(true), deck);
 }
コード例 #10
0
        public void CountCut_WholeDeck()
        {
            Deck deck = new Deck(true);
            deck.CountCut();

            Assert.AreEqual(new Deck(true).Cards, deck.Cards);
        }
コード例 #11
0
        public void TripleCut_FlopZeroSection_NodeCardsCorrectOrder()
        {
            Deck deck = new Deck(new List<int>() { 54, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53 });
            Deck manualDeck = new Deck(new List<int>() { 54, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53 });
            //List<int> manualDeck = new List<int>() { 54, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53 };

            CardValue card1 = CardValue.JokerB;
            CardValue card2 = CardValue.JokerA;
            deck.TripleCut(card1, card2);

            Assert.AreEqual(manualDeck.Cards, deck.Cards);
        }
コード例 #12
0
        public void Move_SingleCardDownTwo_WithinCardLength()
        {
            Deck deck = new Deck(true);
            Deck manualDeck = new Deck(new List<int>() { 1, 2, 3, 5, 6, 4, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54 });
            //List<int> manualDeck = new List<int>() { 1, 2, 3, 5, 6, 4, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54 };

            CardValue card = CardValue.FourOfClubs;
            deck.MoveCardDown(card, 2);

            Assert.AreEqual(manualDeck.Cards, deck.Cards);
        }
コード例 #13
0
        public void Deck_Reset()
        {
            Deck deck = new Deck(true);
            deck.MoveCardDown(CardValue.AceOfHearts, 10);
            deck.MoveCardDown(CardValue.NineOfClubs, 5);

            deck.Reset();

            Assert.AreEqual(new Deck(true), deck);
        }
コード例 #14
0
 public void Deck_NotEqual()
 {
     Deck deck = new Deck(true);
     deck.MoveCardDown(CardValue.NineOfClubs, 5);
     Assert.AreNotEqual(new Deck(true), deck);
 }