private void _resultListView_ItemActivate(object sender, EventArgs e)
        {
            if (_resultListView.SelectedItems.Count != 1)
            {
                return;
            }
            ListViewItem currentItem = _resultListView.SelectedItems[0];

            if (null == currentItem || null == currentItem.Tag)
            {
                return;
            }

            try
            {
                FFXIVItem item = currentItem.Tag as FFXIVItem;
                System.Diagnostics.Process.Start(item.UrlGarland);
            }
            catch
            {
            }
        }
Exemple #2
0
        public void TestFullScenarioImpl(string iItemName, FFXIVItem.TypeItem iExpectedType, int iNbExpectedItems = 1, int iPosItemInList = 0, string iRealName = "", bool iIgnoreCatalyst = false, int iQuantity = 1, bool iCollectable = false, int iNbPerSlot = 1, string iCustomTeleport = "")
        {
            InitTestEnvironment();

            string elemToSearch          = iItemName;
            int    nbExpectedSearchItems = iNbExpectedItems;
            int    nbItemInList          = iPosItemInList;
            string itemFullName          = iRealName;

            if (itemFullName.Length <= 0)
            {
                itemFullName = iItemName;
            }
            FFXIVItem.TypeItem expectedType = iExpectedType;

            List <FFXIVSearchItem> listResults = GarlandTool.Search(elemToSearch, null);

            if (listResults.Count != nbExpectedSearchItems)
            {
                throw new Exception("Erreur de recherche de " + elemToSearch + ": " + listResults.Count + " items found while " + nbExpectedSearchItems + " expected.");
            }

            FFXIVItem item = listResults[nbItemInList];

            if (item.Name != itemFullName)
            {
                throw new Exception("Item name is not the expected one: " + item.Name + ", expected : " + itemFullName);
            }

            FFXIVItem itemToCraft = GarlandTool.RecBuildCraftingTree(null, item.ID);

            if (itemToCraft.Type != expectedType)
            {
                throw new Exception("Item type is not the expected one: " + itemToCraft.Type + ", expected : " + expectedType);
            }

            string        solution_dir = Service_Misc.GetExecutionPath();
            DirectoryInfo refDirectory = new DirectoryInfo(Path.Combine(solution_dir, "References"));

            if (!refDirectory.Exists)
            {
                throw new Exception("Reference directory " + refDirectory.FullName + " does not exist");
            }

            MiqoCraftCore.MiqoCraftCore.MiqobotScenarioOption options = new MiqoCraftCore.MiqoCraftCore.MiqobotScenarioOption();
            options.GatheringRotation = "HQ +10%";
            options.CraftPreset       = "recommended";
            options.NQHQPreset        = "balanced";
            options.CustomTeleport    = iCustomTeleport;
            options.Quantity          = iQuantity;
            options.NbPerNode         = iNbPerSlot;
            options.Collectable       = iCollectable;
            options.IgnoreCatalysts   = iIgnoreCatalyst;

            string fullScenario = "";
            string res          = MiqoCraftCore.MiqoCraftCore.GenerateScenario(itemToCraft, options, null, out fullScenario);

            FileInfo refFile = new FileInfo(Path.Combine(refDirectory.FullName, itemFullName + _dumpSuffix + ".txt"));

            string pathResult = refFile.FullName.Replace(".txt", "_runresult.txt");

            File.WriteAllText(pathResult, res);
            if (_updateDumps)
            {
                File.WriteAllText(refFile.FullName, res);
            }
            string fullScenarioResult = File.ReadAllText(pathResult);

            FileInfo refScenarioFile = new FileInfo(Path.Combine(refDirectory.FullName, itemFullName + _dumpSuffix + " Scenario.txt"));

            pathResult = refScenarioFile.FullName.Replace(".txt", "_runresult.txt");
            File.WriteAllText(pathResult, fullScenario);
            if (_updateDumps)
            {
                File.WriteAllText(refScenarioFile.FullName, fullScenario);
            }

            if (!refFile.Exists)
            {
                throw new Exception("Reference file " + refFile.FullName + " does not exist");
            }
            string fullScenarioReference = File.ReadAllText(refFile.FullName);

            //Testing miqobot scenario
            if (fullScenarioResult.Trim() != fullScenarioReference.Trim())
            {
                throw new Exception("Resulting scenario does not match.; See " + refFile.FullName);
            }

            //Testing plain text scenario
            fullScenarioResult = File.ReadAllText(pathResult);

            if (!refScenarioFile.Exists)
            {
                throw new Exception("Reference file " + refScenarioFile.FullName + " does not exist");
            }
            string fullScenarioTextReference = File.ReadAllText(refScenarioFile.FullName);

            if (fullScenarioResult.Trim() != fullScenarioTextReference.Trim())
            {
                throw new Exception("Resulting scenario text does not match.; See " + refScenarioFile.FullName);
            }
        }