Exemplo n.º 1
0
        public void SuccessfulCompileFile()
        {
            MCSCompiler compiler = new MCSCompiler(_dmcsAssemblyFullPath, new EmptyReportPrinter());

            bool compileResult = compiler.Compile(System.IO.Path.Combine(_pathToTestData, "FileWithValidSouceCode.cs"));

            Assert.IsTrue(compileResult);
        }
Exemplo n.º 2
0
        public void CreateCompilerFromInvalidAssembly()
        {
            bool isTestSuccessful = false;

            try
            {
                MCSCompiler compiler =
                    new MCSCompiler(_pathToTests + @"\ParseTree.exe", new EmptyReportPrinter());
            }
            catch
            {
                isTestSuccessful = true;
            }
            Assert.IsTrue(isTestSuccessful);
        }
Exemplo n.º 3
0
        public void TestMethod1()
        {
            Stream outputStream = File.OpenWrite("C:\\xml_output.xml");
            XMLFormatBuilder xmlBuilder = new XMLFormatBuilder(outputStream);
            FormatTextVisitor ftv = new FormatTextVisitor(xmlBuilder, null);
            xmlBuilder.WriteStartDocument();
            string _pathToTests = System.Reflection.Assembly.GetExecutingAssembly().Location;
            _pathToTests = System.IO.Path.GetDirectoryName(_pathToTests);

            string _dmcsAssemblyFullPath = System.IO.Path.Combine(_pathToTests, "dmcs.exe");

            MCSCompiler compiler = new MCSCompiler(_dmcsAssemblyFullPath, new EmptyReportPrinter());
            compiler.Compile(_pathToTests + @"\Testdata\FileWithValidSouceCode.cs");

            MCSClassElement se = new MCSClassElement("root", compiler.TreeRoot);
            se.Visit(ftv);
            xmlBuilder.WriteEndDocument();
            xmlBuilder.Close();
            outputStream.Close();
        }
        public override void Process(SourceCodeProject project)
        {
            MCSCompiler compiler = new MCSCompiler(Utils.GetDmcsAssemblyPath(), _reporter);
            if (!compiler.SuccessfulCreated)
            {
                return;
            }

            _formatter.WriteStartDocument();
            _formatter.WriteStartCustomElement("Project", "Name", project.Name);

            int filesProcessed = 0;

            DoProgress(0);

            foreach (SourceFile file in project)
            {
                if (!compiler.Compile(file.FileFullPath))
                {
                    continue;
                }

                FormatTextVisitor visitor = new FormatTextVisitor(_formatter, _processors);

                _formatter.WriteStartCustomElement("SourceFile", "Name", file.PathInProject);

                MCSClassElement root = new MCSClassElement("Root", compiler.TreeRoot);
                root.Visit(visitor);

                _formatter.WriteEndElement();

                filesProcessed++;

                DoProgress(filesProcessed * 100 / project.FilesCount);
            }

            _formatter.WriteEndElement();
            _formatter.WriteEndDocument();
        }
Exemplo n.º 5
0
        public void CreateCompilerFromValidAssembly()
        {
            MCSCompiler compiler = new MCSCompiler(_dmcsAssemblyFullPath, new EmptyReportPrinter());

            Assert.IsTrue(compiler.SuccessfulCreated);
        }