public void PublishCCWithBothReportDirectoryAndAdditioanlFilesInputs() { SetupMocks(); var reportDirectory = Path.Combine(Path.GetTempPath(), "reportDirectory"); var summaryFile = Path.Combine(reportDirectory, "summary.xml"); try { Directory.CreateDirectory(reportDirectory); File.WriteAllText(summaryFile, "test"); var publishCCCommand = new CodeCoverageCommandExtension(); publishCCCommand.Initialize(_hc); var command = new Command("codecoverage", "publish"); command.Properties.Add("codecoveragetool", "mockCCTool"); command.Properties.Add("summaryfile", summaryFile); command.Properties.Add("reportdirectory", reportDirectory); command.Properties.Add("additionalcodecoveragefiles", summaryFile); publishCCCommand.ProcessCommand(_ec.Object, command); Assert.Equal(0, _warnings.Count); Assert.Equal(0, _errors.Count); _mockCodeCoveragePublisher.Verify(x => x.PublishCodeCoverageSummaryAsync(It.IsAny <IEnumerable <CodeCoverageStatistics> >(), It.IsAny <string>(), It.IsAny <CancellationToken>())); _mockCodeCoveragePublisher.Verify(x => x.PublishCodeCoverageFilesAsync(It.IsAny <IAsyncCommandContext>(), It.IsAny <Guid>(), It.IsAny <long>(), It.Is <List <Tuple <string, string> > >(files => files.Count == 2), It.IsAny <bool>(), It.IsAny <CancellationToken>())); } finally { Directory.Delete(reportDirectory, true); } }
public void Publish_CoberturaNewIndexFile() { SetupMocks(); var reportDirectory = Path.Combine(Path.GetTempPath(), "reportDirectory"); var coberturaXml = Path.Combine(reportDirectory, "coberturaValid.xml"); try { Directory.CreateDirectory(reportDirectory); File.WriteAllText(coberturaXml, CodeCoverageTestConstants.ValidCoberturaXml); File.WriteAllText((Path.Combine(reportDirectory, "index.html")), string.Empty); File.WriteAllText((Path.Combine(reportDirectory, "frame-summary.html")), string.Empty); var publishCCCommand = new CodeCoverageCommandExtension(); publishCCCommand.Initialize(_hc); var command = new Command("codecoverage", "publish"); command.Properties.Add("codecoveragetool", "cobertura"); command.Properties.Add("summaryfile", coberturaXml); command.Properties.Add("reportdirectory", reportDirectory); publishCCCommand.ProcessCommand(_ec.Object, command); Assert.Equal(0, _warnings.Count); Assert.Equal(0, _errors.Count); _mockCodeCoveragePublisher.Verify(x => x.PublishCodeCoverageSummaryAsync(It.IsAny <IEnumerable <CodeCoverageStatistics> >(), It.IsAny <string>(), It.IsAny <CancellationToken>())); _mockCodeCoveragePublisher.Verify(x => x.PublishCodeCoverageFilesAsync(It.IsAny <IAsyncCommandContext>(), It.IsAny <Guid>(), It.IsAny <long>(), It.IsAny <List <Tuple <string, string> > >(), It.Is <bool>(browsable => browsable == true), It.IsAny <CancellationToken>())); Assert.True(File.Exists(Path.Combine(reportDirectory, "frame-summary.html"))); Assert.True(File.Exists(Path.Combine(reportDirectory, "indexnew.html"))); } finally { Directory.Delete(reportDirectory, true); } }
public void PublishCCFilesWithOnlyAdditionalFilesInput() { SetupMocks(); var summaryFile = Path.GetTempFileName(); try { File.WriteAllText(summaryFile, "test"); var publishCCCommand = new CodeCoverageCommandExtension(); publishCCCommand.Initialize(_hc); var command = new Command("codecoverage", "publish"); command.Properties.Add("codecoveragetool", "mockCCTool"); command.Properties.Add("summaryfile", summaryFile); command.Properties.Add("additionalcodecoveragefiles", summaryFile); publishCCCommand.ProcessCommand(_ec.Object, command); Assert.Equal(0, _warnings.Count); Assert.Equal(0, _errors.Count); _mockCodeCoveragePublisher.Verify(x => x.PublishCodeCoverageSummaryAsync(It.IsAny <IEnumerable <CodeCoverageStatistics> >(), It.IsAny <string>(), It.IsAny <CancellationToken>())); _mockCodeCoveragePublisher.Verify(x => x.PublishCodeCoverageFilesAsync(It.IsAny <IAsyncCommandContext>(), It.IsAny <Guid>(), It.IsAny <long>(), It.Is <List <Tuple <string, string> > >(files => files.Count == 2), It.IsAny <bool>(), It.IsAny <CancellationToken>())); } finally { File.Delete(summaryFile); } }
public void PublishesCCFilesWhenCodeCoverageDataIsNull() { SetupMocks(); var summaryFile = Path.GetTempFileName(); try { File.WriteAllText(summaryFile, "test"); var publishCCCommand = new CodeCoverageCommandExtension(); publishCCCommand.Initialize(_hc); var command = new Command("codecoverage", "publish"); command.Properties.Add("codecoveragetool", "mockCCTool"); command.Properties.Add("summaryfile", summaryFile); _mocksummaryReader.Setup(x => x.GetCodeCoverageSummary(It.IsAny <IExecutionContext>(), It.IsAny <string>())) .Returns((List <CodeCoverageStatistics>)null); publishCCCommand.ProcessCommand(_ec.Object, command); Assert.Equal(1, _warnings.Count); Assert.Equal(0, _errors.Count); _mockCodeCoveragePublisher.Verify(x => x.PublishCodeCoverageFilesAsync(It.IsAny <IAsyncCommandContext>(), It.IsAny <Guid>(), It.IsAny <long>(), It.IsAny <List <Tuple <string, string> > >(), It.IsAny <bool>(), It.IsAny <CancellationToken>())); } finally { File.Delete(summaryFile); } }
public void Publish_WithIndexHtmAndHtmlFileInReportDirectory() { using (var _hc = SetupMocks()) { var reportDirectory = Path.Combine(Path.GetTempPath(), "reportDirectory"); var summaryFile = Path.Combine(reportDirectory, "summary.xml"); try { Directory.CreateDirectory(reportDirectory); File.WriteAllText(summaryFile, "test"); File.WriteAllText((Path.Combine(reportDirectory, "index.htm")), string.Empty); File.WriteAllText((Path.Combine(reportDirectory, "index.html")), string.Empty); var publishCCCommand = new CodeCoverageCommandExtension(); publishCCCommand.Initialize(_hc); var command = new Command("codecoverage", "publish"); command.Properties.Add("codecoveragetool", "mockCCTool"); command.Properties.Add("summaryfile", summaryFile); command.Properties.Add("reportdirectory", reportDirectory); publishCCCommand.ProcessCommand(_ec.Object, command); Assert.Equal(0, _warnings.Count); Assert.Equal(0, _errors.Count); _mockCodeCoveragePublisher.Verify(x => x.PublishCodeCoverageSummaryAsync(It.IsAny <IAsyncCommandContext>(), It.IsAny <IEnumerable <CodeCoverageStatistics> >(), It.IsAny <string>(), It.IsAny <CancellationToken>())); _mockCodeCoveragePublisher.Verify(x => x.PublishCodeCoverageFilesAsync(It.IsAny <IAsyncCommandContext>(), It.IsAny <Guid>(), It.IsAny <string>(), It.IsAny <long>(), It.IsAny <List <Tuple <string, string> > >(), It.Is <bool>(browsable => browsable == true), It.IsAny <CancellationToken>())); Assert.True(File.Exists(Path.Combine(reportDirectory, "index.html"))); Assert.True(File.Exists(Path.Combine(reportDirectory, "index.htm"))); } finally { Directory.Delete(reportDirectory, true); } } }
public void PublishCodeCoverageWithNoSummaryFileInput() { SetupMocks(); var publishCCCommand = new CodeCoverageCommandExtension(); publishCCCommand.Initialize(_hc); var command = new Command("codecoverage", "publish"); Assert.Throws <ArgumentException>(() => publishCCCommand.ProcessCommand(_ec.Object, command)); }
public void PublishCodeCoverageWithNoCCTool() { SetupMocks(); var publishCCCommand = new CodeCoverageCommandExtension(); publishCCCommand.Initialize(_hc); var command = new Command("codecoverage", "publish"); command.Properties.Add("summaryfile", "a.xml"); Assert.Throws <ArgumentException>(() => publishCCCommand.ProcessCommand(_ec.Object, command)); }
public void EnableCCWhenNoCodeCoverageToolShouldPass() { SetupMocks(); var enableCCCommand = new CodeCoverageCommandExtension(); enableCCCommand.Initialize(_hc); var command = new Command("codecoverage", "enable"); enableCCCommand.ProcessCommand(_ec.Object, command); Assert.Equal(_errors.Count, 0); Assert.Equal(_warnings.Count, 0); }
public void PublishCodeCoverageWithRelease() { SetupMocks(); var publishCCCommand = new CodeCoverageCommandExtension(); publishCCCommand.Initialize(_hc); var command = new Command("codecoverage", "publish"); _variables.Set("system.hostType", "release"); publishCCCommand.ProcessCommand(_ec.Object, command); Assert.Equal(1, _warnings.Count); Assert.Equal(0, _errors.Count); }
public void EnableCCWithSpacesInClassFilterThrowsException() { SetupMocks(); var enableCCCommand = new CodeCoverageCommandExtension(); enableCCCommand.Initialize(_hc); var command = new Command("codecoverage", "enable"); command.Properties.Add("buildtool", "mockBuildTool"); command.Properties.Add("classfilter", " , , ,, , "); command.Properties.Add("codecoveragetool", "mockCCTool"); Assert.Throws <ArgumentException>(() => enableCCCommand.ProcessCommand(_ec.Object, command)); }
public void EnableCCWithInvalidCodeCoverageToolThrowsException() { SetupMocks(); var enableCCCommand = new CodeCoverageCommandExtension(); enableCCCommand.Initialize(_hc); var command = new Command("codecoverage", "enable"); command.Properties.Add("buildtool", "mockBuildTool"); command.Properties.Add("buildfile", Path.GetTempFileName()); command.Properties.Add("codecoveragetool", "invalidCCTool"); Assert.Throws <ArgumentException>(() => enableCCCommand.ProcessCommand(_ec.Object, command)); }
public void EnableCCFailsWithErrorWhenBuildFileDoesnotExist() { SetupMocks(); var enableCCCommand = new CodeCoverageCommandExtension(); enableCCCommand.Initialize(_hc); var command = new Command("codecoverage", "enable"); command.Properties.Add("buildtool", "mockBuildTool"); command.Properties.Add("buildfile", "invalid.xml"); command.Properties.Add("codecoveragetool", "mockCCTool"); Assert.Throws <FileNotFoundException>(() => enableCCCommand.ProcessCommand(_ec.Object, command)); }
public void EnableCCWithValidClassExcludeFilterShouldPass() { SetupMocks(); var enableCCCommand = new CodeCoverageCommandExtension(); enableCCCommand.Initialize(_hc); var command = new Command("codecoverage", "enable"); command.Properties.Add("buildtool", "mockBuildTool"); command.Properties.Add("classfilter", _excludeFilter); command.Properties.Add("codecoveragetool", "mockCCTool"); command.Properties.Add("buildfile", Path.GetTempFileName()); enableCCCommand.ProcessCommand(_ec.Object, command); _mockCodeCoverageEnabler.Verify(x => x.EnableCodeCoverage(It.IsAny <IExecutionContext>(), It.Is <CodeCoverageEnablerInputs>(ccInputs => ccInputs.Exclude == _excludes && string.IsNullOrWhiteSpace(ccInputs.Include)))); Assert.Equal(0, _warnings.Count); Assert.Equal(0, _errors.Count); }