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

            foreach (string file in Directory.EnumerateFiles("events", "*.txt"))
            {
                string contents = File.ReadAllText(file);
                //Act
                EventTabModel         model     = EventParser.CreateEventFromScript(file, contents);
                EventContainer        container = new EventContainer(model);
                List <EventContainer> list      = new List <EventContainer> {
                    container
                };
                Dictionary <string, string> files = EventParser.ParseAllEvents(list);
                string filecontent = files.FirstOrDefault().Value;
                string fileName    = files.FirstOrDefault().Key;
                //Assert
                Assert.IsNotNull(model);
                Assert.IsTrue(model.EventList.Any());
                Assert.IsNotNull(fileName);
                Assert.IsNotNull(filecontent);
                tester.Analyse(filecontent);
                Assert.IsFalse(tester.Logger.hasErrors());
            }
        }
예제 #2
0
        public void ExportProject(string paramFilename)
        {
            string path = paramFilename + FOCUS_TREE_PATH;

            Directory.CreateDirectory(path);
            //For each parsed focus trees
            foreach (KeyValuePair <string, string> item in
                     FocusTreeParser.ParseAllTrees(fociContainerList))
            {
                using (TextWriter tw = new StreamWriter(path + item.Key + ".txt"))
                {
                    tw.Write(item.Value);
                }
            }
            path = paramFilename + LOCALISATION_PATH;
            Directory.CreateDirectory(Path.GetDirectoryName(path));
            LocalisationContainer loct = null;

            //For each parsed localisation files
            foreach (KeyValuePair <string, string> item in
                     LocalisationParser.ParseEverything(localisationList))
            {
                //localisationList.IndexOf(loct, 0);
                //fork
                //fixed localization files save in UTF-8 with BOM format
                loct = localisationList[0];
                using (Stream stream = File.OpenWrite(path + item.Key + "_" + loct.LanguageName + ".yml")) //save in file name eg.'test_l_english.yml'
                    using (TextWriter tw = new StreamWriter(stream, new UTF8Encoding(true)))
                    {
                        tw.Write(item.Value);
                    }
            }
            path = paramFilename + EVENTS_PATH;
            Directory.CreateDirectory(Path.GetDirectoryName(path));
            //For each parsed event file
            foreach (KeyValuePair <string, string> item in
                     EventParser.ParseAllEvents(eventList))
            {
                //using (TextWriter tw = new StreamWriter(path + item.Key + ".txt"))
                //fork need to be UTF-8 with BOM
                using (TextWriter tw = new StreamWriter(path + item.Key + ".txt", false, new UTF8Encoding(true)))
                {
                    tw.Write(item.Value);
                }
            }
            //For each parsed script file
            foreach (KeyValuePair <string, string> item in
                     ScriptParser.ParseEverything(scriptList))
            {
                using (TextWriter tw = new StreamWriter(paramFilename + "\\" + item.Key + ".txt"))
                {
                    tw.Write(item.Value);
                }
            }
        }
예제 #3
0
        public void ExportProject(string paramFilename)
        {
            string path = paramFilename + FOCUS_TREE_PATH;

            Directory.CreateDirectory(path);
            //For each parsed focus trees
            foreach (KeyValuePair <string, string> item in
                     FocusTreeParser.ParseAllTrees(fociContainerList))
            {
                using (TextWriter tw = new StreamWriter(path + item.Key + ".txt"))
                {
                    tw.Write(item.Value);
                }
            }
            path = paramFilename + LOCALISATION_PATH;
            Directory.CreateDirectory(Path.GetDirectoryName(path));
            //For each parsed localisation files
            foreach (KeyValuePair <string, string> item in
                     LocalisationParser.ParseEverything(localisationList))
            {
                using (Stream stream = File.OpenWrite(path + item.Key + ".yml"))
                    using (TextWriter tw = new StreamWriter(stream, new UTF8Encoding()))
                    {
                        tw.Write(item.Value);
                    }
            }
            path = paramFilename + EVENTS_PATH;
            Directory.CreateDirectory(Path.GetDirectoryName(path));
            //For each parsed event file
            foreach (KeyValuePair <string, string> item in
                     EventParser.ParseAllEvents(eventList))
            {
                using (TextWriter tw = new StreamWriter(path + item.Key + ".txt"))
                {
                    tw.Write(item.Value);
                }
            }
            //For each parsed script file
            foreach (KeyValuePair <string, string> item in
                     ScriptParser.ParseEverything(scriptList))
            {
                using (TextWriter tw = new StreamWriter(paramFilename + "\\" + item.Key + ".txt"))
                {
                    tw.Write(item.Value);
                }
            }
        }
예제 #4
0
        private void TestEventToScript(EventTabModel model)
        {
            //Arrange
            EventContainer        container = new EventContainer(model);
            List <EventContainer> list      = new List <EventContainer> {
                container
            };
            //Act
            Dictionary <string, string> files = EventParser.ParseAllEvents(list);
            string filecontent = files.FirstOrDefault().Value;
            string fileName    = files.FirstOrDefault().Key;

            //Assert
            Assert.IsNotNull(filecontent);
            Assert.IsNotNull(fileName);
            Assert.AreEqual(fileName, "Baltic");
        }