RenderViolationList() public method

public RenderViolationList ( ViolationList violationList ) : void
violationList StyleCop.Baboon.Analyzer.ViolationList
return void
コード例 #1
0
ファイル: Program.cs プロジェクト: nelsonsar/StyleCop.Baboon
        private static int Analyze(string settings, string projectPath, string[] ignoredPaths)
        {
            var fileSystemHandler = new FileSystemHandler();
            var outputWriter = new StandardOutputWriter();

            if (false == fileSystemHandler.Exists(settings))
            {
                outputWriter.WriteLineWithSeparator("Given settings file does not exist. Exiting...", string.Empty);

                return SettingsFileDoesNotExistErrorCode;
            }

            if (false == fileSystemHandler.Exists(projectPath))
            {
                outputWriter.WriteLineWithSeparator("Given path to analyze does not exist. Exiting...", string.Empty);

                return InvalidPathToAnalyzeErrorCode;
            }

            var analyzer = new StyleCopAnalyzer();
            var projectFactory = new ProjectFactory(new FileSystemHandler());
            var project = projectFactory.CreateFromPathWithCustomSettings(projectPath, settings, ignoredPaths);
            var violations = analyzer.GetViolationsFromProject(project);

            var renderer = new ConsoleRenderer(outputWriter);

            renderer.RenderViolationList(violations);

            if (violations.Empty)
            {
                return NoViolationsFound;
            }

            return ViolationsFound;
        }
コード例 #2
0
        public void OutputsOnlySummaryWhenNoViolationFound()
        {
            var outputWriter = new Mock<IOutputWriter>();

            var renderer = new ConsoleRenderer(outputWriter.Object);

            renderer.RenderViolationList(WithNoViolation());

            outputWriter.Verify(o => o.WriteLine("StyleCop.Baboon by Nelson Senna."), Times.Once);
            outputWriter.Verify(o => o.WriteLineWithSeparator("No violations found! Great job!", string.Empty), Times.Once);
        }
コード例 #3
0
        public void RenderViolationList()
        {
            var expectedViolationMessage = "Line 666: [SA666] You can't do this.";

            var outputWriter = new Mock<IOutputWriter>();

            var renderer = new ConsoleRenderer(outputWriter.Object);

            renderer.RenderViolationList(WithOneViolation());

            outputWriter.Verify(o => o.WriteLine("StyleCop.Baboon by Nelson Senna."), Times.Once);
            outputWriter.Verify(o => o.WriteLineWithSeparator("File: Test.cs", string.Empty), Times.Once);
            outputWriter.Verify(o => o.WriteColoredLine(expectedViolationMessage, ConsoleColor.DarkRed), Times.Once);
            outputWriter.Verify(o => o.WriteLine("Violations found: 1"), Times.Once);
            outputWriter.Verify(o => o.WriteLineWithSeparator("Files analyzed: 1, Total violations: 1", string.Empty), Times.Once);
        }