Exemplo n.º 1
0
        public void VerifyMultipleFilesWithGlobalExclude()
        {
            BuildCopConfiguration config     = new BuildCopConfiguration();
            buildGroupElement     buildGroup = new buildGroupElement();

            buildGroup.name    = "TestBuildGroup";
            buildGroup.enabled = true;
            buildGroup.buildFiles.excludedFiles = "signed";
            buildFilePathElement path = new buildFilePathElement();

            path.rootPath      = @"BuildFiles";
            path.excludedFiles = "default";
            buildGroup.buildFiles.paths.Add(path);
            ruleElement mockRule = new ruleElement();

            mockRule.name = "Mock";
            mockRule.type = typeof(MockRule).AssemblyQualifiedName;
            buildGroup.rules.Add(mockRule);
            config.buildGroups.Add(buildGroup);

            BuildCopReport report = BuildCopEngine.Execute(config);

            Assert.IsNotNull(report);
            IList <BuildGroupReport> groupReports = report.BuildGroupReports;

            Assert.IsNotNull(groupReports);
            Assert.AreEqual <int>(1, groupReports.Count);
            BuildGroupReport groupReport = groupReports[0];

            Assert.IsNotNull(groupReport);
            Assert.AreEqual <string>("TestBuildGroup", groupReport.BuildGroupName);
            Assert.IsNotNull(groupReport.BuildFileReports);
            Assert.AreEqual <int>(0, groupReport.BuildFileReports.Count);
        }
Exemplo n.º 2
0
        public void BuildCopShouldReportRuleExceptions()
        {
            BuildCopConfiguration config     = new BuildCopConfiguration();
            buildGroupElement     buildGroup = new buildGroupElement();

            buildGroup.name    = "TestBuildGroup";
            buildGroup.enabled = true;
            buildFilePathElement path = new buildFilePathElement();

            path.rootPath      = @"BuildFiles";
            path.searchPattern = "DefaultConsoleApplication.csproj";
            buildGroup.buildFiles.paths.Add(path);
            ruleElement mockRule = new ruleElement();

            mockRule.name        = "Mock";
            mockRule.type        = typeof(ExceptionMockRule).AssemblyQualifiedName;
            mockRule.RuleChecker = new ExceptionMockRule(mockRule);
            buildGroup.rules.Add(mockRule);
            config.buildGroups.Add(buildGroup);

            BuildCopReport report = BuildCopEngine.Execute(config);

            Assert.IsNotNull(report);

            IList <BuildGroupReport> groupReports = report.BuildGroupReports;

            Assert.IsNotNull(groupReports);
            Assert.AreEqual <int>(1, groupReports.Count);
            BuildGroupReport groupReport = groupReports[0];

            Assert.IsNotNull(groupReport);
            Assert.AreEqual <string>("TestBuildGroup", groupReport.BuildGroupName);
            Assert.IsNotNull(groupReport.BuildFileReports);
            Assert.AreEqual <int>(1, groupReport.BuildFileReports.Count);
            BuildFileReport fileReport = groupReport.BuildFileReports[0];

            Assert.IsNotNull(fileReport);
            Assert.AreEqual <string>(@"BuildFiles\DefaultConsoleApplication.csproj", fileReport.FileName);
            Assert.IsNotNull(fileReport.LogEntries);
            Assert.AreEqual <int>(1, fileReport.LogEntries.Count);
            LogEntry entry = fileReport.LogEntries[0];

            Assert.AreEqual <LogLevel>(LogLevel.Exception, entry.Level);
            Assert.AreEqual <string>("An exception occurred while analysing the build file.", entry.Message);
            Assert.IsNotNull(entry.Detail);
            Assert.IsTrue(entry.Detail.Contains("ExceptionMock was configured to throw exceptions."));
        }
Exemplo n.º 3
0
        public void BuildCopShouldExecuteFormatters()
        {
            BuildCopConfiguration config     = new BuildCopConfiguration();
            buildGroupElement     buildGroup = new buildGroupElement();

            buildGroup.name    = "TestBuildGroup";
            buildGroup.enabled = true;
            buildFilePathElement path = new buildFilePathElement();

            path.rootPath      = @"BuildFiles";
            path.searchPattern = "DefaultConsoleApplication.csproj";
            buildGroup.buildFiles.paths.Add(path);
            ruleElement mockRule = new ruleElement();

            mockRule.name        = "Mock";
            mockRule.type        = typeof(MockRule).AssemblyQualifiedName;
            mockRule.RuleChecker = new MockRule(mockRule);
            buildGroup.rules.Add(mockRule);
            config.buildGroups.Add(buildGroup);
            formatterElement formatter = new formatterElement();

            formatter.type            = typeof(MockFormatter).AssemblyQualifiedName;
            formatter.minimumLogLevel = LogLevel.Information;
            formatter.Formatter       = new MockFormatter(formatter);
            config.formatters.Add(formatter);

            MockFormatter.LastReport = null;
            BuildCopEngine.Execute(config);
            BuildCopReport lastReport = MockFormatter.LastReport;

            Assert.IsNotNull(lastReport);
            Assert.AreEqual <string>(typeof(BuildCopEngine).Assembly.GetName().Version.ToString(), lastReport.EngineVersion);
            Assert.IsTrue(DateTime.Now - lastReport.GeneratedTime < TimeSpan.FromMinutes(1));
            IList <BuildGroupReport> groupReports = lastReport.BuildGroupReports;

            Assert.IsNotNull(groupReports);
            Assert.AreEqual <int>(1, groupReports.Count);
            BuildGroupReport groupReport = groupReports[0];

            Assert.IsNotNull(groupReport);
            Assert.AreEqual <string>("TestBuildGroup", groupReport.BuildGroupName);
            Assert.IsNotNull(groupReport.BuildFileReports);
            Assert.AreEqual <int>(1, groupReport.BuildFileReports.Count);
            CheckMockFileReport(groupReport.BuildFileReports[0], @"BuildFiles\DefaultConsoleApplication.csproj");
        }
Exemplo n.º 4
0
        public void BuildCopShouldExecuteSharedRules()
        {
            BuildCopConfiguration config     = new BuildCopConfiguration();
            buildGroupElement     buildGroup = new buildGroupElement();

            buildGroup.name    = "TestBuildGroup";
            buildGroup.enabled = true;
            buildFilePathElement path = new buildFilePathElement();

            path.rootPath      = @"BuildFiles";
            path.searchPattern = "DefaultConsoleApplication.csproj";
            buildGroup.buildFiles.paths.Add(path);
            ruleElement mockRule = new ruleElement();

            mockRule.name        = "Mock";
            mockRule.RuleChecker = new MockRule(mockRule);
            buildGroup.rules.Add(mockRule);
            ruleElement sharedMockRule = new ruleElement();

            sharedMockRule.name        = "Mock";
            sharedMockRule.type        = typeof(MockRule).AssemblyQualifiedName;
            sharedMockRule.RuleChecker = new MockRule(sharedMockRule);
            config.sharedRules.Add(sharedMockRule);
            config.buildGroups.Add(buildGroup);

            BuildCopReport report = BuildCopEngine.Execute(config);

            Assert.IsNotNull(report);

            IList <BuildGroupReport> groupReports = report.BuildGroupReports;

            Assert.IsNotNull(groupReports);
            Assert.AreEqual <int>(1, groupReports.Count);
            BuildGroupReport groupReport = groupReports[0];

            Assert.IsNotNull(groupReport);
            Assert.AreEqual <string>("TestBuildGroup", groupReport.BuildGroupName);
            Assert.IsNotNull(groupReport.BuildFileReports);
            Assert.AreEqual <int>(1, groupReport.BuildFileReports.Count);
            CheckMockFileReport(groupReport.BuildFileReports[0], @"BuildFiles\DefaultConsoleApplication.csproj");
        }
Exemplo n.º 5
0
        public void BuildCopShouldExcludeRulesOnOutputTypeWithProjectTypeGuids()
        {
            BuildCopConfiguration config     = new BuildCopConfiguration();
            buildGroupElement     buildGroup = new buildGroupElement();

            buildGroup.name    = "TestBuildGroup";
            buildGroup.enabled = true;
            buildFilePathElement path = new buildFilePathElement();

            path.rootPath      = @"BuildFiles";
            path.searchPattern = "SignedConsoleApplication.csproj";
            buildGroup.buildFiles.paths.Add(path);
            ruleElement mockRule = new ruleElement();

            mockRule.name = "Mock";
            mockRule.type = typeof(MockRule).AssemblyQualifiedName;
            mockRule.excludedOutputTypes = "Dummy;Web";
            buildGroup.rules.Add(mockRule);
            config.buildGroups.Add(buildGroup);

            BuildCopReport report = BuildCopEngine.Execute(config);

            Assert.IsNotNull(report);

            IList <BuildGroupReport> groupReports = report.BuildGroupReports;

            Assert.IsNotNull(groupReports);
            Assert.AreEqual <int>(1, groupReports.Count);
            BuildGroupReport groupReport = groupReports[0];

            Assert.IsNotNull(groupReport);
            Assert.AreEqual <string>("TestBuildGroup", groupReport.BuildGroupName);
            Assert.IsNotNull(groupReport.BuildFileReports);
            Assert.AreEqual <int>(1, groupReport.BuildFileReports.Count);
            Assert.AreEqual <int>(0, groupReport.BuildFileReports[0].LogEntries.Count);
        }