示例#1
0
        /// <summary>
        /// Entry Point
        /// </summary>
        /// <param name="args">DocumentationFileName TestReportFileName</param>
        static void Main(string[] args)
        {
            try
            {
                //Display Starting Message
                Output.WriteStartingMessage(startingTime);

                ProgramArguments pArgs = new ProgramArguments(args);
                //Detect if all arguments were populated to continue
                if (string.IsNullOrEmpty(pArgs.ProjectFileName) || string.IsNullOrEmpty(pArgs.TestReportFile))
                {
                    Output.WriteEndingMessage(startingTime);
                    return;
                }

                Project    projectTested = new Project();
                FileParser parser        = new FileParser();
                parser.MessageRaised += new EventHandler <MessageEventArgs>(parser_MessageRaised);
                //Parse the project file
                projectTested = parser.ParseProjectFile(projectTested, pArgs.ProjectFileName);
                if (projectTested.Error)
                {
                    Output.WriteEndingMessage(startingTime);
                    return;
                }
                //Parse the documentation file into objects on memory
                //TODO: Refactor two parameters to one
                projectTested = parser.ParseDocumentationFile(projectTested, projectTested.DocumentationFile);
                if (projectTested.Error)
                {
                    Output.WriteEndingMessage(startingTime);
                    return;
                }
                //Parse the MSTest file into object on memory
                projectTested = parser.ParseMSTestFile(projectTested, pArgs.TestReportFile, pArgs.TestCategory);
                if (projectTested.Error)
                {
                    Output.WriteEndingMessage(startingTime);
                    return;
                }
                //Generates the html report
                Report reportManager = new Report(projectTested);
                reportManager.MessageRaised += new EventHandler <MessageEventArgs>(parser_MessageRaised);

                string reportContent = reportManager.PrepareReportContent(pArgs.ScenarioTemplateFileName, pArgs.FeatureTemplateFileName, pArgs.TestReportTemplateFileName);
                if (projectTested.Error)
                {
                    Output.WriteEndingMessage(startingTime);
                    return;
                }
                string reportFileName = reportManager.SaveReportOnDisc(reportContent, pArgs.TestCategory);

                //Print all ok on screen if no errors or warnings were written
                if (!Output.ErrorWarningWasWritten)
                {
                    Output.WriteMessage(new Message(MessageType.Information, ResourceLabel.StringInformationNoErrorOrSuggestion, null));
                }

                //Print Report Name on screen
                Output.WriteMessage(new Message(MessageType.Information, ResourceLabel.StringInformationReportGeneratedSuccessfully, new string[] { reportFileName }));
                Output.WriteEndingMessage(startingTime);
            }
            catch (Exception ex)
            {
                //Write unhandled error out on console
                Output.WriteMessage(new Message(MessageType.Error, ex.Message));
                Output.WriteEndingMessage(startingTime);
            }
        }
示例#2
0
 /// <summary>
 /// Event Handler responsible of write message on the console
 /// </summary>
 /// <param name="sender">Object who raise the event</param>
 /// <param name="e">Customer MessageEventArgs with the message to write</param>
 static void parser_MessageRaised(object sender, MessageEventArgs e)
 {
     //Write the message on console
     Output.WriteMessage(e.MsgRaised);
 }