public void AddUpgradesChangeTypeWhenNewResultAddedWithGreaterChangeType() { var firstResult = new ComparisonResult(SemVerChangeType.Feature, null, null, Guid.NewGuid().ToString()); var secondResult = new ComparisonResult(SemVerChangeType.Breaking, null, null, Guid.NewGuid().ToString()); var sut = new ChangeCalculatorResult(); sut.Add(firstResult); sut.Add(secondResult); sut.ChangeType.Should().Be(secondResult.ChangeType); sut.ComparisonResults.Should().HaveCount(2); sut.ComparisonResults.First().Should().Be(firstResult); sut.ComparisonResults.Skip(1).First().Should().Be(secondResult); }
public ChangeCalculatorResult CalculateChanges(IEnumerable <ITypeDefinition> oldTypes, IEnumerable <ITypeDefinition> newTypes, ComparerOptions options) { oldTypes = oldTypes ?? throw new ArgumentNullException(nameof(oldTypes)); newTypes = newTypes ?? throw new ArgumentNullException(nameof(newTypes)); var result = new ChangeCalculatorResult(); var changes = _matchProcessor.CalculateChanges(oldTypes, newTypes, options); foreach (var change in changes) { if (change.ChangeType == SemVerChangeType.None) { continue; } _logger?.LogInformation($@"{change.ChangeType}: {change.Message}"); result.Add(change); } var changeType = result.ChangeType.ToString().ToLower(CultureInfo.CurrentCulture); _logger?.LogInformation("Calculated overall result as a {0} change.", changeType); return(result); }
public void AddSetsChangeTypeToInitialResult() { var result = new ComparisonResult(SemVerChangeType.Feature, null, null, Guid.NewGuid().ToString()); var sut = new ChangeCalculatorResult(); sut.Add(result); sut.ChangeType.Should().Be(result.ChangeType); sut.ComparisonResults.Should().HaveCount(1); sut.ComparisonResults.First().Should().Be(result); }