public ConfigurationViewModel() { DisplayName = "Configuration"; this.unitOfWork = new UnitOfWork( Helpers.SettingsHelper.GetSettingValue("EquipmentFile"), Helpers.SettingsHelper.GetSettingValue("CardFile"), Helpers.SettingsHelper.GetSettingValue("CharacterFile")); }
/// <summary> /// Quick helper to construct verification data for Card Viewmodels (xml data file). /// </summary> public static void CardViewModelSerialiser() { // Not strictly a Unit Test, useful environment to drive testing. UnitOfWork unitOfWork = new UnitOfWork(null, Path.GetFullPath("Data/DataFiles/Cards.csv"), null); // Construct card ViewModels from card names contained in test card list. HashSet<Card> cardList = new HashSet<Card>(unitOfWork.Cards.GetAll()); List<CardViewModel> cardVMs = cardList .ToList() .ConvertAll(c => new CardViewModel(c)); XDocument output = new XDocument(new XElement("Root")); foreach (CardViewModel cardVM in cardVMs) { XDocument root = new XDocument( new XElement("CardVM", new XElement("Name", cardVM.Card.Name), new XElement("HasDoubleCardBox", cardVM.HasDoubleCardBox), new XElement("IsArmorBoxVisible", cardVM.IsArmorBoxVisible), new XElement("IsArmorBox2Visible", cardVM.IsArmorBox2Visible), new XElement("IsBlockBoxVisible", cardVM.IsBlockBoxVisible), new XElement("IsBlockBox2Visible", cardVM.IsBlockBox2Visible), new XElement("IsBoostBoxVisible", cardVM.IsBoostBoxVisible), new XElement("IsBoostBox2Visible", cardVM.IsBoostBox2Visible), new XElement("IsDrawbackBoxVisible", cardVM.IsDrawbackBoxVisible), new XElement("IsDrawbackBox2Visible", cardVM.IsDrawbackBox2Visible), new XElement("IsMoveBoxVisible", cardVM.IsMoveBoxVisible), new XElement("IsRangeBoxVisible", cardVM.IsRangeBoxVisible), new XElement("IsDamageBoxVisible", cardVM.IsDamageBoxVisible), new XElement("IsTriggerBoxVisible", cardVM.IsTriggerBoxVisible), new XElement("IsTriggerBox2Visible", cardVM.IsTriggerBox2Visible), new XElement("IsTriggerTextVisible", cardVM.IsTriggerTextVisible), new XElement("IsTriggerText2Visible", cardVM.IsTriggerText2Visible)) ); output.Root.Add(root.Elements()); } File.WriteAllText("CardVMData.xml", output.ToString()); }
public CardMaximiserViewModel() { DisplayName = "Card Maximiser"; this.unitOfWork = new UnitOfWork( Helpers.SettingsHelper.GetSettingValue("EquipmentFile"), Helpers.SettingsHelper.GetSettingValue("CardFile"), Helpers.SettingsHelper.GetSettingValue("CharacterFile")); deckBuilder = new DeckBuilder.DeckBuilder(unitOfWork); this.TemplatedCharacters = new List<Character>(); this.TemplatedCharacters = unitOfWork.Characters.GetAllTemplateCharacters(); this.Cards = new List<Card>(); this.Cards = unitOfWork.Cards.GetAll().OrderBy(x => x.Name); GeneratedCombinationsView = new ObservableCollection<ItemCombinationWithInfoViewModel>(); // Default settings. ResultNumber = 30; WikiResultPageSplit = 10; IsItemOptimisationEnabled = true; }
public void CardIndicatorsBehaveCorrectly() { // Not strictly a Unit Test, useful environment to drive testing. UnitOfWork unitOfWork = new UnitOfWork(null, Path.GetFullPath("Data/DataFiles/Cards.csv"), null); // Get properties. var cardVMProperties = typeof(CardViewModel).GetProperties(); // Properties we're testing. HashSet<PropertyInfo> props = new HashSet<PropertyInfo>() { cardVMProperties.Where(x => x.Name == "HasDoubleCardBox").Single(), cardVMProperties.Where(x => x.Name == "IsArmorBoxVisible").Single(), cardVMProperties.Where(x => x.Name == "IsArmorBox2Visible").Single(), cardVMProperties.Where(x => x.Name == "IsBlockBoxVisible").Single(), cardVMProperties.Where(x => x.Name == "IsBlockBox2Visible").Single(), cardVMProperties.Where(x => x.Name == "IsBoostBoxVisible").Single(), cardVMProperties.Where(x => x.Name == "IsBoostBox2Visible").Single(), cardVMProperties.Where(x => x.Name == "IsDrawbackBoxVisible").Single(), cardVMProperties.Where(x => x.Name == "IsDrawbackBox2Visible").Single(), cardVMProperties.Where(x => x.Name == "IsMoveBoxVisible").Single(), cardVMProperties.Where(x => x.Name == "IsRangeBoxVisible").Single(), cardVMProperties.Where(x => x.Name == "IsDamageBoxVisible").Single(), cardVMProperties.Where(x => x.Name == "IsTriggerBoxVisible").Single(), cardVMProperties.Where(x => x.Name == "IsTriggerBox2Visible").Single(), cardVMProperties.Where(x => x.Name == "IsTriggerTextVisible").Single(), cardVMProperties.Where(x => x.Name == "IsTriggerText2Visible").Single() }; // Construct card ViewModels from card names contained in test card list. List<Card> cardList = new List<Card>(unitOfWork.Cards.GetAll()); List<CardViewModel> testVMs = cardList .ConvertAll(c => new CardViewModel(c)); // Load xml data file - contains (assumed correct) property info). XDocument cardVMInfo = XDocument.Load("Resources/CardVMData.xml"); foreach (var vm in testVMs) { Console.WriteLine(string.Format("Card: {0}.", vm.Card.Name)); var cardNode = cardVMInfo.Descendants("CardVM") .Where(x => x.Descendants("Name") .SingleOrDefault().Value == vm.Card.Name); // Hint at data file regenerate required. if (cardNode == null) { Console.WriteLine(string.Format("Card: {0} not found within parsed xml data.", vm.Card.Name)); continue; } if (vm.Card.Name == "Enabling Aura" || vm.Card.Name == "Greased Armor" || vm.Card.Name == "Parrying Cut" || vm.Card.Name == "Repulsive" || vm.Card.Name == "Spell Train" || vm.Card.Name == "Easily Daunted" || vm.Card.Name == "Attractive") { Console.WriteLine(string.Format("Card: {0} cannot be verified in game, skipping.", vm.Card.Name)); continue; } // Compare each property. foreach (var property in props) { // Fail if we can't find on of these properties. bool xmlResult = bool.Parse(cardNode.Descendants(property.Name).Single().Value); bool cardVMResult = (bool)property.GetValue(vm); Assert.AreEqual(xmlResult, cardVMResult, string.Format("Compared Property {0}: Expected ({1}) - Result ({2}) - Card {3}", property.Name, xmlResult, cardVMResult, vm.Card.Name)); Console.WriteLine(string.Format("Compared Property {0}: Expected ({1}) - Result ({2}).", property.Name, xmlResult, cardVMResult)); } } }
public DeckBuilder(UnitOfWork unitOfWork) { this.unitOfWork = unitOfWork; }