public void WhenCreatingNewObjectWithBugDatabaseCacheAndbugDatabaseNotSetShouldThrow() { var args = new P4ExtractCommandLineArgs() { BugDatabaseDLL = "some/path/to.dll" }; Action newObjectAction = () => this.processor = new PerforceCodeChurnProcessor(processWrapperMock.Object, changesParserMock.Object, describeParserMock.Object, commandLineParserMock.Object, bugDatabseMock.Object, loggerMock.Object, stopWatchMock.Object, outputProcessorMock.Object, args); Assert.Throws <Exception>(newObjectAction); }
public void WhenCollectingBugDatabaseCacheAndNoOutputFileShouldThrowException() { this.commandLineArgs = new P4ExtractCommandLineArgs() { BugDatabaseDLL = "some/path/to.dll" }; Action collect = () => new PerforceCodeChurnProcessor(processWrapperMock.Object, changesParserMock.Object, describeParserMock.Object, commandLineParserMock.Object, bugDatabseMock.Object, loggerMock.Object, stopWatchMock.Object, outputProcessorMock.Object, commandLineArgs); var exception = Assert.Throws <Exception>(collect); Assert.Equal("Dll specified without known output file", exception.Message); }
public void WhenCollectingBugDatabaseCacheAndDllIsEmptyShouldReturn() { this.commandLineArgs = new P4ExtractCommandLineArgs() { BugDatabaseDLL = string.Empty }; this.processor = new PerforceCodeChurnProcessor(processWrapperMock.Object, changesParserMock.Object, describeParserMock.Object, commandLineParserMock.Object, bugDatabseMock.Object, loggerMock.Object, stopWatchMock.Object, outputProcessorMock.Object, commandLineArgs); processor.QueryBugDatabase(); this.bugDatabseMock.Verify(b => b.ProcessBugDatabase(It.IsAny <string>(), It.IsAny <IEnumerable <string> >()), Times.Never); }
public void WhenCollectingBugDatabaseCacheAndbugDatabaseNotSetShouldThrow() { this.commandLineArgs = new P4ExtractCommandLineArgs() { BugDatabaseDLL = "some/path/to.dll", BugDatabaseOutputFile = "some/path/to/output/files" }; this.processor = new PerforceCodeChurnProcessor(processWrapperMock.Object, changesParserMock.Object, describeParserMock.Object, commandLineParserMock.Object, null, loggerMock.Object, stopWatchMock.Object, outputProcessorMock.Object, commandLineArgs); Action collect = () => processor.QueryBugDatabase(); Assert.Throws <NullReferenceException>(collect); }
public void WhenCollectingBugDatabaseCacheAndBugCacheNullShouldReturn() { this.commandLineArgs = new P4ExtractCommandLineArgs() { BugDatabaseDLL = "some/path/to.dll", BugDatabaseOutputFile = "some/path/to/output/files" }; this.bugDatabseMock .Setup(b => b.ProcessBugDatabase(It.IsAny <string>(), It.IsAny <IEnumerable <string> >())) .Returns((Dictionary <DateTime, Dictionary <string, WorkItem> >)null); this.processor = new PerforceCodeChurnProcessor(processWrapperMock.Object, changesParserMock.Object, describeParserMock.Object, commandLineParserMock.Object, bugDatabseMock.Object, loggerMock.Object, stopWatchMock.Object, outputProcessorMock.Object, commandLineArgs); processor.QueryBugDatabase(); this.loggerMock.Verify(l => l.LogToConsole(It.IsAny <string>()), Times.Never); }
public void WhenCollectingBugDatabaseCacheShouldProcessOutput() { this.commandLineArgs = new P4ExtractCommandLineArgs() { BugDatabaseDLL = "some/path/to.dll", BugDatabaseOutputFile = "some/path/to/output/files" }; this.bugDatabseMock .Setup(b => b.ProcessBugDatabase(It.IsAny <string>(), It.IsAny <IEnumerable <string> >())) .Returns(new Dictionary <DateTime, Dictionary <string, WorkItem> >()); this.processor = new PerforceCodeChurnProcessor(processWrapperMock.Object, changesParserMock.Object, describeParserMock.Object, commandLineParserMock.Object, bugDatabseMock.Object, loggerMock.Object, stopWatchMock.Object, outputProcessorMock.Object, commandLineArgs); processor.QueryBugDatabase(); this.outputProcessorMock .Verify(o => o.ProcessOutput(this.commandLineArgs.BugDatabaseOutputType, this.commandLineArgs.BugDatabaseOutputFile, It.IsAny <Dictionary <DateTime, Dictionary <string, WorkItem> > >()), Times.Once); }
private static int RunPerforceCodeChurnProcessor(P4ExtractCommandLineArgs a) { var processWrapper = new ProcessWrapper(); var changesParser = new ChangesParser(); var describeParser = new DescribeParser(); var commandLineParser = new CommandLineParser(); var logger = new ConsoleLoggerWithTimestamp(); var stopWatch = new StopWatchWrapper(); var outputProcessor = new JsonOutputProcessor(new DataConverter(), new FileStreamFactory(), logger); var bugDatabaseFactory = new BugDatabaseFactory(); var bugDatabaseDllLoader = new BugDatabaseDllLoader(logger, bugDatabaseFactory); var webRequest = new WebRequest(new HttpClientWrapperFactory(bugDatabaseFactory)); var fileSystem = new FileSystem(); var jsonParser = new JsonListParser <WorkItem>(new FileStreamFactory()); var bugDatabaseProcessor = new BugDatabaseProcessor(bugDatabaseDllLoader, webRequest, fileSystem, jsonParser, logger, a.BugDatabaseOutputFile); var processor = new PerforceCodeChurnProcessor(processWrapper, changesParser, describeParser, commandLineParser, bugDatabaseProcessor, logger, stopWatch, outputProcessor, a); processor.QueryBugDatabase(); return(processor.Extract()); }
public GivenAPerforceCodeChurnProcessor() { var invokeLines = new List <string>(); this.processWrapperMock = new Mock <IProcessWrapper>(); this.processWrapperMock.Setup(m => m.Invoke("changes", "commandline")).Returns(new Tuple <int, List <string> >(0, invokeLines)); this.changesParserMock = new Mock <IChangesParser>(); this.changesParserMock.Setup(m => m.Parse(invokeLines)).Returns(new List <int>()); this.describeParserMock = new Mock <IDescribeParser>(); this.commandLineParserMock = new Mock <ICommandLineParser>(); this.commandLineParserMock.Setup(m => m.ParseCommandLine("changes commandline")).Returns(new Tuple <string, string>("changes", "commandline")); this.commandLineParserMock.Setup(m => m.ParseCommandLine("describe 1")).Returns(new Tuple <string, string>("describe", "1")); this.commandLineParserMock.Setup(m => m.ParseCommandLine("describe 2")).Returns(new Tuple <string, string>("describe", "2")); this.commandLineParserMock.Setup(m => m.ParseCommandLine("describe 3")).Returns(new Tuple <string, string>("describe", "3")); this.loggerMock = new Mock <ILogger>(); this.stopWatchMock = new Mock <IStopWatch>(); this.outputProcessorMock = new Mock <IOutputProcessor>(); this.outputProcessorMock.Setup(m => m.ProcessOutput(OutputType.SingleFile, It.IsAny <string>(), It.IsAny <Dictionary <DateTime, Dictionary <string, DailyCodeChurn> > >())).Callback <OutputType, string, Dictionary <DateTime, Dictionary <string, DailyCodeChurn> > >( (outputType, file, output) => { this.output = output; } ); this.bugDatabseMock = new Mock <IBugDatabaseProcessor>(); this.commandLineArgs = new P4ExtractCommandLineArgs { OutputType = OutputType.SingleFile, OutputFile = "filename", P4ChangesCommandLine = "changes commandline", P4DescribeCommandLine = "describe {0}" }; this.processor = new PerforceCodeChurnProcessor(processWrapperMock.Object, changesParserMock.Object, describeParserMock.Object, commandLineParserMock.Object, bugDatabseMock.Object, loggerMock.Object, stopWatchMock.Object, outputProcessorMock.Object, commandLineArgs); }
public PerforceCodeChurnProcessor(IProcessWrapper processWrapper, IChangesParser changesParser, IDescribeParser describeParser, ICommandLineParser commandLineParser, IBugDatabaseProcessor bugDatabaseProcessor, ILogger logger, IStopWatch stopWatch, IOutputProcessor outputProcessor, P4ExtractCommandLineArgs args) : this(processWrapper, changesParser, describeParser, commandLineParser, bugDatabaseProcessor, logger, stopWatch, outputProcessor, args.OutputFile, args.OutputType, args.BugDatabaseDLL, args.BugDatabaseOutputFile, args.BugDatabaseDllArgs, args.P4ChangesCommandLine, args.P4DescribeCommandLine, args.BugRegexes) { if (string.IsNullOrWhiteSpace(bugDatabaseDLL) == false && string.IsNullOrWhiteSpace(bugDatabaseOutputFile)) { throw new Exception("Dll specified without known output file"); } this.bugDatabaseOutputFile = args.BugDatabaseOutputFile; this.bugDatabaseOutputType = args.BugDatabaseOutputType; }