Exemplo n.º 1
0
        public void JMATsunamiConverterTest(string sourcePath, string expectedPath)
        {
            StreamReader reader  = new StreamReader(sourcePath, Encoding.UTF8);
            string       content = reader.ReadToEnd();

            reader.Close();

            Core   core = JMATsunamiConverter.fromString(content);
            string json = JsonConvert.SerializeObject(core, Formatting.Indented).Replace("\r", "");

            if (!File.Exists(expectedPath))
            {
                StreamWriter writer = new StreamWriter(expectedPath, false, Encoding.UTF8);
                writer.Write(json);
                writer.Close();

                Assert.Ignore();
                return;
            }

            StreamReader expectedReader = new StreamReader(expectedPath, Encoding.UTF8);
            string       expectedJson   = expectedReader.ReadToEnd().Replace("\r", "");

            expectedReader.Close();

            Assert.AreEqual(expectedJson, json);
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            if (args.Length < 1)
            {
                Console.Error.WriteLine("usage: TsunamiAnalyzer <input.html> [<output.json>]");
                return;
            }

            string inputFileName  = args[0];
            string outputFileName = (args.Length >= 2) ? args[1] : null;

            Console.Error.WriteLine("Convert from " + inputFileName + " to " + outputFileName + ".");

            // ファイル読み込み
            StreamReader reader  = new StreamReader(inputFileName, Encoding.UTF8);
            string       content = reader.ReadToEnd();

            reader.Close();

            // Console.WriteLine (content);

            Core   core = JMATsunamiConverter.fromString(content);
            string json = JsonConvert.SerializeObject(core, Formatting.Indented);

            if (outputFileName != null)
            {
                // ファイル書き込み
                StreamWriter writer = new StreamWriter(outputFileName, false, new UTF8Encoding(false));
                writer.Write(json);
                writer.Close();
            }
            else
            {
                Console.WriteLine(json);
            }

            Console.Error.WriteLine("Finish at " + DateTime.Now.ToString());
        }