Exemplo n.º 1
0
        private bool Test(int index)
        {
            bool           result            = false;
            string         inputFileName     = string.Format(@"..\..\InputFiles\xsd\Xsd{0:00}.Hello.xsd", index);
            string         expectedFileName  = string.Format(@"..\..\ExpectedFiles\soal\Xsd{0:00}.soal", index);
            string         outputFileName    = string.Format(@"..\..\OutputFiles\soal\Xsd{0:00}.Hello.soal", index);
            string         outputLogFileName = string.Format(@"..\..\OutputFiles\soal\Xsd{0:00}.Hello.log", index);
            string         outputDirectory   = string.Format(@"..\..\OutputFiles\soal", index);
            DiagnosticBag  diagnostics       = new DiagnosticBag();
            ImmutableModel model             = SoalImporter.Import(inputFileName, diagnostics);

            using (StreamWriter writer = new StreamWriter(outputLogFileName))
            {
                foreach (var msg in diagnostics.AsEnumerable())
                {
                    writer.WriteLine(msg);
                }
            }
            Assert.IsFalse(diagnostics.HasAnyErrors());
            Directory.CreateDirectory(outputDirectory);
            SoalPrinter printer    = new SoalPrinter(model.Symbols);
            string      outputSoal = printer.Generate();

            File.WriteAllText(outputFileName, outputSoal);
            string expectedSoal = null;

            using (StreamReader reader = new StreamReader(expectedFileName))
            {
                expectedSoal = reader.ReadToEnd();
            }
            Assert.AreEqual(expectedSoal, outputSoal);
            return(result);
        }
Exemplo n.º 2
0
        private bool Test(int index)
        {
            bool   result            = false;
            string inputFileName     = string.Format(@"..\..\InputFiles\wsdl\Wsdl{0:00}.Hello.wsdl", index);
            string expectedFileName  = string.Format(@"..\..\ExpectedFiles\soal\Wsdl{0:00}.soal", index);
            string outputFileName    = string.Format(@"..\..\OutputFiles\soal\Wsdl{0:00}.Hello.soal", index);
            string outputLogFileName = string.Format(@"..\..\OutputFiles\soal\Wsdl{0:00}.Hello.log", index);
            string outputDirectory   = string.Format(@"..\..\OutputFiles\soal", index);

            Directory.CreateDirectory(outputDirectory);

            DiagnosticBag  diagnostics = new DiagnosticBag();
            ImmutableModel model       = SoalImporter.Import(inputFileName, diagnostics);

            using (StreamWriter writer = new StreamWriter(outputLogFileName))
            {
                foreach (var msg in diagnostics.AsEnumerable())
                {
                    writer.WriteLine(msg);
                }
            }
            Assert.IsFalse(diagnostics.HasAnyErrors());
            Directory.CreateDirectory(outputDirectory);
            SoalPrinter printer    = new SoalPrinter(model.Symbols);
            string      outputSoal = printer.Generate();

            File.WriteAllText(outputFileName, outputSoal);
            string expectedSoal = null;

            using (StreamReader reader = new StreamReader(expectedFileName))
            {
                expectedSoal = reader.ReadToEnd();
            }
            int firstDiff = -1;
            int line      = 1;
            int column    = 1;
            int max       = Math.Max(expectedSoal.Length, outputSoal.Length);

            for (int i = 0; i < max; i++)
            {
                if (expectedSoal[i] != outputSoal[i])
                {
                    firstDiff = i;
                    break;
                }
                ++column;
                if (expectedSoal[i] == '\n')
                {
                    ++line;
                    column = 1;
                }
            }
            Assert.AreEqual(expectedSoal, outputSoal);
            return(result);
        }
Exemplo n.º 3
0
 static void Main(string[] args)
 {
     try
     {
         string inputFileName  = null;
         string outputFileName = null;
         for (int i = 0; i < args.Length; i++)
         {
             if (args[i].StartsWith("-"))
             {
                 if (i + 1 < args.Length)
                 {
                     if (args[i] == "-o")
                     {
                         outputFileName = args[++i];
                     }
                     else
                     {
                         Console.WriteLine("Unknown option: '" + args[i] + "'");
                     }
                 }
                 else
                 {
                     Console.WriteLine("Unknown option: '" + args[i] + "'");
                 }
             }
             else
             {
                 inputFileName = args[i];
             }
         }
         if (inputFileName == null)
         {
             Console.WriteLine("Usage:");
             Console.WriteLine("  SoalImport.exe [options] [input.wsdl or input.xsd]");
             Console.WriteLine("Options:");
             Console.WriteLine("  -o [output.soal]: output SOAL file");
             return;
         }
         if (outputFileName == null)
         {
             outputFileName = Path.ChangeExtension(inputFileName, ".soal");
         }
         if (!File.Exists(inputFileName))
         {
             Console.WriteLine("Could not find file: " + inputFileName);
             return;
         }
         DiagnosticBag  importDiagnostics = new DiagnosticBag();
         ImmutableModel model             = SoalImporter.Import(inputFileName, importDiagnostics);
         foreach (var msg in importDiagnostics.AsEnumerable())
         {
             Console.WriteLine(msg);
         }
         //if (!ModelCompilerContext.Current.Diagnostics.HasErrors())
         {
             SoalPrinter printer = new SoalPrinter(model.Symbols);
             using (StreamWriter writer = new StreamWriter(outputFileName))
             {
                 writer.WriteLine(printer.Generate());
             }
         }
     }
     catch (System.Exception ex)
     {
         Console.WriteLine(ex);
     }
 }