public void Execute_ExistingButEmptyReport_ShouldLogErrorOnLoad_DefaultBuildServerIsLocal() { // arrange var logger = GetLogger(); var fileSystem = new MockFileSystem(new Dictionary <string, MockFileData> { { "report.xml", MockFileData.NullObject } }); var localBuildServer = new LocalBuildServer(logger); var mockBuildServer = GetMockBuildServer(); var buildServers = new List <IBuildServer> { localBuildServer, mockBuildServer }; var buildServerCommand = new BuildServerCommand(logger, fileSystem, buildServers, localBuildServer, Enumerable.Empty <IReportParser>()); var remainingArgs = buildServerCommand.GetActualOptions().Parse(new[] { "report.xml" }); // act var exitCode = buildServerCommand.Run(remainingArgs.ToArray()); // assert Assert.Equal(2, exitCode); var logs = _loggerOutput.ToString(); Assert.Contains("\t- Local console", logs); Assert.Contains("An exception happened when loading the report 'System.Xml.XmlException: Root element is missing.", logs); }
public void Execute_MultipleReports_ShouldWriteMessageFromIssues() { // arrange var logger = GetLogger(); var fileSystem = new MockFileSystem(new Dictionary <string, MockFileData> { { "report.xml", new MockFileData("<root></root>") }, { "report2.xml", new MockFileData("<root></root>") } }); var localBuildServer = new LocalBuildServer(logger); var mockBuildServer = GetMockBuildServer(true); var buildServers = new List <IBuildServer> { localBuildServer, mockBuildServer }; var parsers = new List <IReportParser> { GetMockReportParser(true, true, true) }; var buildServerCommand = new BuildServerCommand(logger, fileSystem, buildServers, localBuildServer, parsers); var remainingArgs = buildServerCommand.GetActualOptions().Parse(new[] { "report.xml", "report2.xml", "--debug" }); // act var exitCode = buildServerCommand.Run(remainingArgs.ToArray()); // assert Assert.Equal(4, exitCode); var logs = _loggerOutput.ToString(); Assert.Contains("3 issues was found", logs); Assert.Contains("Message1", logs); Assert.Contains("Message2", logs); Assert.Contains("Message3", logs); Assert.Contains("Message4", logs); Assert.Contains("Message5", logs); Assert.Contains("Message6", logs); }
public void Execute_ParserCantParse_ShouldLogError() { // arrange var logger = GetLogger(); var fileSystem = new MockFileSystem(new Dictionary <string, MockFileData> { { "report.xml", new MockFileData("<root></root>") } }); var localBuildServer = new LocalBuildServer(logger); var mockBuildServer = GetMockBuildServer(true); var buildServers = new List <IBuildServer> { localBuildServer, mockBuildServer }; var parsers = new List <IReportParser> { GetMockReportParser() }; var buildServerCommand = new BuildServerCommand(logger, fileSystem, buildServers, localBuildServer, parsers); var remainingArgs = buildServerCommand.GetActualOptions().Parse(new[] { "report.xml" }); // act var exitCode = buildServerCommand.Run(remainingArgs.ToArray()); // assert Assert.Equal(3, exitCode); var logs = _loggerOutput.ToString(); Assert.Contains("The adequate parser for this report was not found. You are welcome to address us an issue.", logs); }
public void Execute_IncludeSource_BuildServerShouldIncludeSource() { // arrange var logger = GetLogger(); var fileSystem = new MockFileSystem(new Dictionary <string, MockFileData> { { "report.xml", new MockFileData("<root></root>") } }); var localBuildServer = new LocalBuildServer(logger); var mockBuildServer = GetMockBuildServer(true); var buildServers = new List <IBuildServer> { localBuildServer, mockBuildServer }; var parsers = new List <IReportParser> { GetMockReportParser(true, false) }; var buildServerCommand = new BuildServerCommand(logger, fileSystem, buildServers, localBuildServer, parsers); var remainingArgs = buildServerCommand.GetActualOptions().Parse(new[] { "report.xml", "--includesource" }); // act var exitCode = buildServerCommand.Run(remainingArgs.ToArray()); // assert Assert.Equal(0, exitCode); var logs = _loggerOutput.ToString(); Assert.Contains("Message1 - Source1", logs); Assert.Contains("Message2 - Source2", logs); Assert.Contains("Message3 - Source3", logs); }
public void Execute_NoArguments_ShouldLogError_NoReportSpecified() { // arrange var logger = GetLogger(); var buildServerCommand = new BuildServerCommand(logger, new MockFileSystem(), Enumerable.Empty<IBuildServer>(), new LocalBuildServer(logger), Enumerable.Empty<IReportParser>()); buildServerCommand.GetActualOptions().Parse(new string[] { }); // act var exitCode = buildServerCommand.Run(new string[] { }); // assert Assert.Equal(1, exitCode); Assert.Equal("No report was specified. You must indicate at least one report file.", _loggerOutput.ToString().Trim()); }
public void Execute_NoArguments_ShouldLogError_NoReportSpecified() { // arrange var logger = GetLogger(); var buildServerCommand = new BuildServerCommand(logger, new MockFileSystem(), Enumerable.Empty <IBuildServer>(), new LocalBuildServer(logger), Enumerable.Empty <IReportParser>()); buildServerCommand.GetActualOptions().Parse(new string[] { }); // act var exitCode = buildServerCommand.Run(new string[] { }); // assert Assert.Equal(1, exitCode); Assert.Equal("No report was specified. You must indicate at least one report file.", _loggerOutput.ToString().Trim()); }
public void Execute_NonExistingReport_ShouldLogError_ReportNotFound() { // arrange var logger = GetLogger(); var fileSystem = new MockFileSystem(); var buildServerCommand = new BuildServerCommand(logger, fileSystem, Enumerable.Empty<IBuildServer>(), new LocalBuildServer(logger), Enumerable.Empty<IReportParser>()); var remainingArgs = buildServerCommand.GetActualOptions().Parse(new[] { "report.xml" }); // act var exitCode = buildServerCommand.Run(remainingArgs.ToArray()); // assert Assert.Equal(1, exitCode); var logs = _loggerOutput.ToString(); Assert.Contains("The report 'report.xml' was not found.", logs); }
public void Execute_NonExistingReport_ShouldLogError_ReportNotFound() { // arrange var logger = GetLogger(); var fileSystem = new MockFileSystem(); var buildServerCommand = new BuildServerCommand(logger, fileSystem, Enumerable.Empty <IBuildServer>(), new LocalBuildServer(logger), Enumerable.Empty <IReportParser>()); var remainingArgs = buildServerCommand.GetActualOptions().Parse(new[] { "report.xml" }); // act var exitCode = buildServerCommand.Run(remainingArgs.ToArray()); // assert Assert.Equal(1, exitCode); var logs = _loggerOutput.ToString(); Assert.Contains("The report 'report.xml' was not found.", logs); }
public void Execute_ExistingButEmptyReport_ShouldLogErrorOnLoad_DefaultBuildServerIsLocal() { // arrange var logger = GetLogger(); var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData> { { "report.xml", MockFileData.NullObject } }); var localBuildServer = new LocalBuildServer(logger); var mockBuildServer = GetMockBuildServer(); var buildServers = new List<IBuildServer> { localBuildServer, mockBuildServer }; var buildServerCommand = new BuildServerCommand(logger, fileSystem, buildServers, localBuildServer, Enumerable.Empty<IReportParser>()); var remainingArgs = buildServerCommand.GetActualOptions().Parse(new[] { "report.xml" }); // act var exitCode = buildServerCommand.Run(remainingArgs.ToArray()); // assert Assert.Equal(2, exitCode); var logs = _loggerOutput.ToString(); Assert.Contains("\t- Local console", logs); Assert.Contains("An exception happened when loading the report 'System.Xml.XmlException: Root element is missing.", logs); }
public void Execute_MultipleReports_ShouldWriteMessageFromIssues() { // arrange var logger = GetLogger(); var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData> { { "report.xml", new MockFileData("<root></root>") }, { "report2.xml", new MockFileData("<root></root>") } }); var localBuildServer = new LocalBuildServer(logger); var mockBuildServer = GetMockBuildServer(true); var buildServers = new List<IBuildServer> { localBuildServer, mockBuildServer }; var parsers = new List<IReportParser> { GetMockReportParser(true, true, true) }; var buildServerCommand = new BuildServerCommand(logger, fileSystem, buildServers, localBuildServer, parsers); var remainingArgs = buildServerCommand.GetActualOptions().Parse(new[] { "report.xml", "report2.xml", "--debug" }); // act var exitCode = buildServerCommand.Run(remainingArgs.ToArray()); // assert Assert.Equal(4, exitCode); var logs = _loggerOutput.ToString(); Assert.Contains("3 issues was found", logs); Assert.Contains("Message1", logs); Assert.Contains("Message2", logs); Assert.Contains("Message3", logs); Assert.Contains("Message4", logs); Assert.Contains("Message5", logs); Assert.Contains("Message6", logs); }
public void Execute_IncludeSource_BuildServerShouldIncludeSource() { // arrange var logger = GetLogger(); var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData> { { "report.xml", new MockFileData("<root></root>") } }); var localBuildServer = new LocalBuildServer(logger); var mockBuildServer = GetMockBuildServer(true); var buildServers = new List<IBuildServer> { localBuildServer, mockBuildServer }; var parsers = new List<IReportParser> { GetMockReportParser(true, false) }; var buildServerCommand = new BuildServerCommand(logger, fileSystem, buildServers, localBuildServer, parsers); var remainingArgs = buildServerCommand.GetActualOptions().Parse(new[] { "report.xml", "--includesource" }); // act var exitCode = buildServerCommand.Run(remainingArgs.ToArray()); // assert Assert.Equal(0, exitCode); var logs = _loggerOutput.ToString(); Assert.Contains("Message1 - Source1", logs); Assert.Contains("Message2 - Source2", logs); Assert.Contains("Message3 - Source3", logs); }
public void Execute_ParserCantParse_ShouldLogError() { // arrange var logger = GetLogger(); var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData> { { "report.xml", new MockFileData("<root></root>") } }); var localBuildServer = new LocalBuildServer(logger); var mockBuildServer = GetMockBuildServer(true); var buildServers = new List<IBuildServer> { localBuildServer, mockBuildServer }; var parsers = new List<IReportParser> { GetMockReportParser() }; var buildServerCommand = new BuildServerCommand(logger, fileSystem, buildServers, localBuildServer, parsers); var remainingArgs = buildServerCommand.GetActualOptions().Parse(new[] { "report.xml" }); // act var exitCode = buildServerCommand.Run(remainingArgs.ToArray()); // assert Assert.Equal(3, exitCode); var logs = _loggerOutput.ToString(); Assert.Contains("The adequate parser for this report was not found. You are welcome to address us an issue.", logs); }