public void WhenConvertingWithProjectMeausreShouldAppendProjectMeasure() { this.measureConverter = new MeasureConverter <int>(new DateTime(2018, 9, 17), new DateTime(2018, 9, 18), metric, mockMeasureAggregatorProject.Object, "//prefix/"); var dailyCodeChurn1 = new DailyCodeChurn() { Timestamp = "2018/09/17 00:00:00", FileName = "file1", Added = 10, Deleted = 10 }; var dailyCodeChurn2 = new DailyCodeChurn() { Timestamp = "2018/09/17 00:00:00", FileName = "file2", Added = 5, Deleted = 5 }; var measures = new SonarMeasuresJson(); this.measureConverter.ProcessProjectMeasure(measures); this.measureConverter.ProcessProjectMeasure(measures); Assert.Single(measures.MeasuresProject.Where(m => m.MetricKey == "key")); }
public void WhenGettingExtensionAndFileNameNullShouldReturnExpectedValue() { var churn = new DailyCodeChurn(); churn.FileName = null; Assert.Null(churn.Extension); }
public void WhenGettingExtensionAndFileNameEmptyShouldReturnExpectedValue() { var churn = new DailyCodeChurn(); churn.FileName = ""; Assert.Equal("", churn.Extension); }
public void WhenGettingExtensionShouldReturnExpectedValue() { var churn = new DailyCodeChurn(); churn.FileName = "//somepath/bin/Latest/BuildSystem/Wrappers/DatabaseExport.ps1"; Assert.Equal(".ps1", churn.Extension); }
public void WhenProcessingSonarGenericMetricsCosmosDbCommandLineArgsShouldProcessMeasureConverters() { var codeChurn = new DailyCodeChurn { FileName = SomeFileName, NumberOfChanges = 12, ChangesBefore = 2, Added = 1, Deleted = 4 }; var sonarGenericMetricsCosmosDbCommandLineArgs = new SonarGenericMetricsCosmosDbCommandLineArgs(); var mockedData = new Dictionary <DateTime, Dictionary <string, DailyCodeChurn> > { { new DateTime(), new Dictionary <string, DailyCodeChurn> { { SomeFileName, codeChurn } } } }; processor = new SonarGenericMetricsProcessor(parserMock.Object, measureConverters, jsonExporterMock.Object, new Mock <ILogger>().Object, new DataConverter()); processor.Process(sonarGenericMetricsCosmosDbCommandLineArgs, mockedData); this.measureConverter1Mock.Verify(m => m.ProcessFileMeasure(codeChurn, It.IsAny <SonarMeasuresJson>()), Times.Once()); this.measureConverter1Mock.Verify(m => m.ProcessProjectMeasure(It.IsAny <SonarMeasuresJson>()), Times.Once()); }
public void WhenGettingExtensionForBigFilePathShouldReturnExpectedValue() { var churn = new DailyCodeChurn(); churn.FileName = "//sunrise/bin/Latest/Tools/AssemblyCache/GameTestLibrary.Opus.TestDependencies/AnyCPU/v1/GameTestLibrary.Opus.Exceptions.dll"; Assert.Equal(".dll", churn.Extension); }
private AuthorsData CreateAuthorsData(DailyCodeChurn dailyCodeChurn) { return(new AuthorsData { Authors = dailyCodeChurn.Authors, Timestamp = dailyCodeChurn.Timestamp }); }
public bool HasValue(DailyCodeChurn dailyCodeChurn) { if (dailyCodeChurn.BugDatabase == null) { return(false); } return(dailyCodeChurn.BugDatabase.NumberOfChangesInFixes > 0); }
public void WhenGettingGetFileLongNameShouldReturnExpectedValue() { var dailyCodeChurn = new DailyCodeChurn { Timestamp = "2018/09/05 00:00:00", FileName = "some-file-name" }; Assert.Equal("2018-09-05_some-file-name", dailyCodeChurn.GetFileLongName()); }
public bool HasValue(DailyCodeChurn dailyCodeChurn) { if (dailyCodeChurn.BugDatabase == null) { return(false); } return(dailyCodeChurn.BugDatabase.TotalLinesChangedInFixes > 0); }
public List <AuthorsData> GetValueForNewMeasure(DailyCodeChurn dailyCodeChurn) { var value = new List <AuthorsData> { CreateAuthorsData(dailyCodeChurn) }; return(value); }
public void WhenCallingHasValueAndNoAuthorsShouldReturnFalse() { var dailyCodeChurn = new DailyCodeChurn() { Timestamp = "2019/06/20 00:00:00", FileName = "file1" }; Assert.False(this.measureAggregator.HasValue(dailyCodeChurn)); }
public void WhenCallingHasValueAndNoBugDatabaseValueShouldReturnFalse() { var dailyCodeChurn = new DailyCodeChurn() { Timestamp = "2018/09/17 00:00:00", FileName = "file1" }; Assert.False(this.measureAggregator.HasValue(dailyCodeChurn)); }
public void WhenComparingAndDatesAreDifferentShouldConsiderDate() { var churn1 = new DailyCodeChurn { Timestamp = "2018/09/05 00:00:00" }; var churn2 = new DailyCodeChurn { Timestamp = "2018/09/04 00:00:00" }; Assert.Equal(-1, churn2.CompareTo(churn1)); }
public void WhenComparingAndDatesAreEqualShouldConsiderFileName() { var churn1 = new DailyCodeChurn { FileName = "b" }; var churn2 = new DailyCodeChurn { FileName = "a" }; Assert.Equal(-1, churn2.CompareTo(churn1)); }
public void WhenCallingAHasValueAndHasValueShouldReturnTrue() { var dailyCodeChurn = new DailyCodeChurn() { Timestamp = "2018/09/17 00:00:00", FileName = "file1", NumberOfChangesWithFixes = 1 }; Assert.True(this.measureAggregator.HasValue(dailyCodeChurn)); }
public void WhenGettingValueForNewMeasureShouldReturnNumberOfChanges() { var dailyCodeChurn = new DailyCodeChurn() { Timestamp = "2018/09/17 00:00:00", FileName = "file1", NumberOfChangesWithFixes = 6 }; Assert.Equal(6, this.measureAggregator.GetValueForNewMeasure(dailyCodeChurn)); }
public void WhenCallingHasValueAndNoValueShouldReturnFalse() { var dailyCodeChurn = new DailyCodeChurn() { Timestamp = "2018/09/17 00:00:00", FileName = "file1", AddedWithFixes = 0, DeletedWithFixes = 0 }; Assert.False(this.measureAggregator.HasValue(dailyCodeChurn)); }
public void WhenCallingAHasValueAndHasValueShouldReturnTrue() { var dailyCodeChurn = new DailyCodeChurn() { Timestamp = "2018/09/17 00:00:00", FileName = "file1", Added = 6, Deleted = 1 }; Assert.True(this.measureAggregator.HasValue(dailyCodeChurn)); }
public void WhenConvertingShouldAdd() { var dailyCodeChurn = new DailyCodeChurn() { Timestamp = "2018/09/17 12:00:00", FileName = "file1" }; var measures = new SonarMeasuresJson(); this.measureConverter.ProcessFileMeasure(dailyCodeChurn, measures); Assert.Equal("file1", (Assert.Single(measures.MeasuresRaw) as Measure <string>).Value); }
public void WhenGettingValueForExistingMeasureShouldSumWithExistingValue() { var dailyCodeChurn = new DailyCodeChurn() { Timestamp = "2018/09/17 00:00:00", FileName = "file1", NumberOfChangesWithFixes = 1 }; var measure = new Measure <int>(); measure.Value = 3; Assert.Equal(4, this.measureAggregator.GetValueForExistingMeasure(dailyCodeChurn, measure)); }
public void WhenConvertingWithinRangeAndDiffrentCaseShouldRemoveFilePrefix() { var dailyCodeChurn = new DailyCodeChurn() { Timestamp = "2018/09/17 00:00:00", FileName = "//PREfix/file" }; var measures = new SonarMeasuresJson(); this.measureConverter.ProcessFileMeasure(dailyCodeChurn, measures); Assert.Equal("file", measures.MeasuresRaw.Where(m => m.MetricKey == "key").Single().File); }
public void WhenConvertingANonProjectAggregatorWithProjectMeausreShouldDoNothing() { this.measureConverter = new MeasureConverterRaw <string>(metric, mockMeasureAggregator.Object, "//prefix/"); var dailyCodeChurn = new DailyCodeChurn() { Timestamp = "2018/09/17 00:00:00", FileName = "file1" }; var measures = new SonarMeasuresJson(); this.measureConverter.ProcessProjectMeasure(measures); Assert.Empty(measures.MeasuresProject.Where(m => m.MetricKey == "key")); }
public void WhenGettingValueForNewMeasureShouldReturnNumberOfChanges() { var dailyCodeChurn = new DailyCodeChurn() { Timestamp = "2018/09/17 00:00:00", FileName = "file1", BugDatabase = new DailyCodeChurnBugDatabase { AddedInFixes = 6, DeletedInFixes = 1 } }; Assert.Equal(7, this.measureAggregator.GetValueForNewMeasure(dailyCodeChurn)); }
public void WhenConvertingWithinRangeAndNoFilePrefixShouldConvert() { this.measureConverter = new MeasureConverterRaw <string>(metric, mockMeasureAggregator.Object, null); var dailyCodeChurn = new DailyCodeChurn() { Timestamp = "2018/09/17 00:00:00", FileName = "//prefix/file" }; var measures = new SonarMeasuresJson(); this.measureConverter.ProcessFileMeasure(dailyCodeChurn, measures); Assert.Equal("//prefix/file", measures.MeasuresRaw.Where(m => m.MetricKey == "key").Single().File); }
public void WhenConvertingAndBeforeRangeShouldDoNothing() { var dailyCodeChurn = new DailyCodeChurn() { Timestamp = "2018/09/16 12:00:00", FileName = "file1", Added = 10, Deleted = 10 }; var measures = new SonarMeasuresJson(); this.measureConverter.ProcessFileMeasure(dailyCodeChurn, measures); Assert.Empty(measures.Measures); }
public void WhenConvertingWithinRangeShouldAppendMetrics() { var dailyCodeChurn = new DailyCodeChurn() { Timestamp = "2018/09/17 00:00:00", FileName = "file1", Added = 10, Deleted = 10 }; var measures = new SonarMeasuresJson(); this.measureConverter.ProcessFileMeasure(dailyCodeChurn, measures); Assert.NotEmpty(measures.Metrics.Where(m => m.MetricKey == "key")); }
public void WhenCallingAHasValueAndHasValueShouldReturnTrue() { var dailyCodeChurn = new DailyCodeChurn() { Timestamp = "2018/09/17 00:00:00", FileName = "file1", BugDatabase = new DailyCodeChurnBugDatabase { AddedInFixes = 0, DeletedInFixes = 0, NumberOfChangesInFixes = 1 } }; Assert.True(this.measureAggregator.HasValue(dailyCodeChurn)); }
public void WhenConvertingWithinRangeShouldAppendMeasures() { var dailyCodeChurn = new DailyCodeChurn() { Timestamp = "2018/09/17 00:00:00", FileName = "file1", Added = 10, Deleted = 10 }; var measures = new SonarMeasuresJson(); this.measureConverter.ProcessFileMeasure(dailyCodeChurn, measures); Assert.Equal(dailyCodeChurn.TotalLinesChanged, measures.Measures.Where(m => m.MetricKey == "key" && m.File == dailyCodeChurn.FileName).Select(m => m as Measure <int>).Single().Value); }
public void WhenConvertingAndInRangeAndValueZeroShouldDoNothing() { var dailyCodeChurn = new DailyCodeChurn() { Timestamp = "2018/09/17 12:00:00", FileName = "file1", Added = 0, Deleted = 0, NumberOfChanges = 0 }; var measures = new SonarMeasuresJson(); this.measureConverter.ProcessFileMeasure(dailyCodeChurn, measures); Assert.Empty(measures.Measures); }