예제 #1
0
        private void TestParseAllTrees()
        {
            //Arrange
            Script tester = new Script();

            foreach (string file in Directory.EnumerateFiles("national_focus", "*.txt"))
            {
                string contents = File.ReadAllText(file);
                //Act
                FocusGridModel           model     = FocusTreeParser.CreateTreeFromScript(file, contents);
                FociGridContainer        container = new FociGridContainer(model);
                List <FociGridContainer> list      = new List <FociGridContainer> {
                    container
                };
                Dictionary <string, string> files = FocusTreeParser.ParseAllTrees(list);
                string filecontent = files.FirstOrDefault().Value;
                string fileName    = files.FirstOrDefault().Key;
                //Assert
                Assert.IsNotNull(model);
                Assert.IsTrue(model.FociList.Any());
                Assert.IsNotNull(fileName);
                Assert.IsNotNull(filecontent);
                tester.Analyse(filecontent);
                Assert.IsFalse(tester.Logger.hasErrors());
            }
        }
예제 #2
0
        private FocusGridModel TestScriptToTree()
        {
            //Act
            FocusGridModel model = FocusTreeParser.CreateTreeFromScript("usa.txt", File.ReadAllText("usa.txt"));

            //Assert
            Assert.IsNotNull(model);
            Assert.IsTrue(model.FociList.Any());
            Assert.AreEqual(model.TAG, "USA");
            Assert.AreEqual(model.VisibleName, "usa_focus");
            return(model);
        }
예제 #3
0
        private void AddFile(string param)
        {
            var dialog = new CommonOpenFileDialog();
            ResourceDictionary resourceLocalization = new ResourceDictionary();

            resourceLocalization.Source = new Uri(Configurator.getLanguageFile(), UriKind.Relative);
            dialog.Title                     = resourceLocalization["Add_Game_File"] as string;
            dialog.InitialDirectory          = Configurator.getGamePath();
            dialog.AddToMostRecentlyUsedList = false;
            dialog.AllowNonFileSystemItems   = false;
            dialog.DefaultDirectory          = "C:";
            dialog.EnsureFileExists          = true;
            dialog.EnsurePathExists          = true;
            dialog.EnsureReadOnly            = false;
            dialog.EnsureValidNames          = true;
            dialog.Multiselect               = false;
            if (dialog.ShowDialog() == CommonFileDialogResult.Ok)
            {
                switch (param)
                {
                case "FocusTree":
                {
                    Script script = new Script();
                    script.Analyse(File.ReadAllText(dialog.FileName));
                    fociContainerList.Add(FocusTreeParser.CreateTreeFromScript(dialog.FileName, script));
                    RaisePropertyChanged("fociContainerList");
                    break;
                }

                case "Localisation":
                {
                    localisationList.Add(LocalisationParser.CreateLocaleFromFile(dialog.FileName));
                    RaisePropertyChanged("fociContainerList");
                    break;
                }
                }
            }
        }