Example #1
0
        private static void GenerateTestDecks()
        {
            _deck1      = new Deck();
            _deck1.Name = "Test1";
            _deck1.Url  = "http://www.google.com";
            _deck1.Note = "test note 1";
            _deck1.Tags = new List <string> {
                "testtag1", "testtag2"
            };
            _deck1.Class = "Mage";
            foreach (var card in GameV2.GetActualCards().Where(c => c.PlayerClass == "Mage").Take(30))
            {
                _deck1.Cards.Add(card);
            }

            _deck2      = new Deck();
            _deck2.Name = "Test2";
            _deck2.Url  = "http://www.amazon.com";
            _deck2.Note = "test note 2";
            _deck2.Tags = new List <string> {
                "testtag3", "testtag4"
            };
            _deck2.Class = "Druid";
            foreach (var card in GameV2.GetActualCards().Where(c => c.PlayerClass == "Druid").Take(30))
            {
                _deck2.Cards.Add(card);
            }
        }
        public void TestDreadscaleInGetActual()
        {
            var db    = GameV2.GetActualCards();
            var found = db.Any <Card>(c => c.LocalizedName.ToLowerInvariant().Contains("dreadscale"));

            Assert.IsTrue(found);
        }
 public void TestCardImages()
 {
     foreach (var card in GameV2.GetActualCards())
     {
         Assert.IsTrue(File.Exists("Images/" + card.CardFileName + ".png"), card.Name);
     }
 }
Example #4
0
        private void UpdateDbListView()
        {
            if (_newDeck == null)
            {
                return;
            }
            var    selectedClass = _newDeck.Class;
            string selectedNeutral;
            string selectedManaCost;
            string selectedSet;

            try
            {
                selectedNeutral = MenuFilterType.Items.Cast <RadioButton>().First(x => x.IsChecked.HasValue && x.IsChecked.Value).Content.ToString();
            }
            catch (Exception)
            {
                selectedNeutral = "ALL";
            }
            try
            {
                selectedManaCost =
                    MenuFilterMana.Items.Cast <RadioButton>().First(x => x.IsChecked.HasValue && x.IsChecked.Value).Content.ToString();
            }
            catch (Exception)
            {
                selectedManaCost = "ALL";
            }
            try
            {
                selectedSet = MenuFilterSet.Items.Cast <RadioButton>().First(x => x.IsChecked.HasValue && x.IsChecked.Value).Content.ToString();
            }
            catch (Exception)
            {
                selectedSet = "ALL";
            }
            if (selectedClass == "Select a Class")
            {
                ListViewDB.Items.Clear();
            }
            else
            {
                ListViewDB.Items.Clear();

                var formattedInput = Helper.RemoveDiacritics(TextBoxDBFilter.Text.ToLowerInvariant(), true);
                var words          = formattedInput.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

                foreach (var card in GameV2.GetActualCards())
                {
                    var cardName = Helper.RemoveDiacritics(card.LocalizedName.ToLowerInvariant(), true);
                    if (!Config.Instance.UseFullTextSearch && !cardName.Contains(formattedInput) &&
                        (!string.IsNullOrEmpty(card.RaceOrType) && formattedInput != card.RaceOrType.ToLowerInvariant()))
                    {
                        continue;
                    }
                    if (Config.Instance.UseFullTextSearch &&
                        words.Any(
                            w =>
                            !cardName.Contains(w) && !(!string.IsNullOrEmpty(card.Text) && card.Text.ToLowerInvariant().Contains(w)) &&
                            (!string.IsNullOrEmpty(card.RaceOrType) && w != card.RaceOrType.ToLowerInvariant()) &&
                            (!string.IsNullOrEmpty(card.Rarity) && w != card.Rarity.ToLowerInvariant())))
                    {
                        continue;
                    }

                    // mana filter
                    if (selectedManaCost != "ALL" && ((selectedManaCost != "9+" || card.Cost < 9) && (selectedManaCost != card.Cost.ToString())))
                    {
                        continue;
                    }
                    if (selectedSet != "ALL" && !string.Equals(selectedSet, card.Set, StringComparison.InvariantCultureIgnoreCase))
                    {
                        continue;
                    }
                    switch (selectedNeutral)
                    {
                    case "ALL":
                        if (card.GetPlayerClass == selectedClass || card.GetPlayerClass == "Neutral")
                        {
                            ListViewDB.Items.Add(card);
                        }
                        break;

                    case "CLASS ONLY":
                        if (card.GetPlayerClass == selectedClass)
                        {
                            ListViewDB.Items.Add(card);
                        }
                        break;

                    case "NEUTRAL ONLY":
                        if (card.GetPlayerClass == "Neutral")
                        {
                            ListViewDB.Items.Add(card);
                        }
                        break;
                    }
                }

                Helper.SortCardCollection(ListViewDB.Items, Config.Instance.CardSortingClassFirst);
            }
        }
 public void TestTotalCollectableCards()
 {
     // 3.0.0.9786 - TGT
     Assert.AreEqual(698, GameV2.GetActualCards().Count);
 }