public void VerifyEnumeratorStopsAtMinVersion() { var now = DateTimeOffset.Now; var minVersion = "1.5.0"; var changeVersion2 = new DefaultChange("2.0.0", "Added", "Some 2.0.0 Summary", now); var changeVersion1Pt5 = new DefaultChange(minVersion, "Added", "Some 1.5.0 Summary", now.AddDays(-1)); var changeVersion1 = new DefaultChange("1.0.0", "Added", "Some 1.0.0 Summary", now.AddDays(-2)); var changes = new List <IChange> { changeVersion2, changeVersion1Pt5, changeVersion1 }; var expectedChanges = new List <IChange> { changeVersion2, changeVersion1Pt5 }; var filteredChanges = new FilteredChanges <IChange>(changes, minVersion, new HashSet <string>()); Assert.That(filteredChanges, Is.EquivalentTo(expectedChanges)); }
public string Generate(string minVersion = null, IEnumerable <string> tagsToExclude = null) { var toExclude = tagsToExclude?.ToList() ?? new List <string>(); foreach (var reader in _readers) { var values = reader.Values(); if (minVersion != null || toExclude.Any()) { values = new FilteredChanges <IChange>(values, minVersion, toExclude); } _cache.Add(values); } var results = _cache.GetAsValueDictionary(); return(_renderer.Render(_template, results)); }
public void VerifyEnumeratorSkipsExcludedTags() { var now = DateTimeOffset.Now; var excludedTag = "Maintenance"; var changeVersion2 = new DefaultChange("2.0.0", "Added", "Some 2.0.0 Summary", now); var changeVersion1Pt5 = new DefaultChange("1.5.0", excludedTag, "Some 1.5.0 Summary", now.AddDays(-1)); var changeVersion1 = new DefaultChange("1.0.0", "Added", "Some 1.0.0 Summary", now.AddDays(-2)); var changes = new List <IChange> { changeVersion2, changeVersion1Pt5, changeVersion1 }; var expectedChanges = new List <IChange> { changeVersion2, changeVersion1 }; var filteredChanges = new FilteredChanges <IChange>(changes, null, new List <string> { excludedTag }); Assert.That(filteredChanges, Is.EquivalentTo(expectedChanges)); }
public Dictionary <string, string> Generate(ChangeVersion minVersion = null, IEnumerable <string> changeTypesToExclude = null) { var projectToCache = new Dictionary <string, IChangeCache>(); var projectToOutput = new Dictionary <string, string>(); var toExclude = changeTypesToExclude?.ToList() ?? new List <string>(); foreach (var reader in _readers) { var values = reader.Values(); if (minVersion != null || toExclude.Any()) { values = new FilteredChanges <ProjectChange>(values, minVersion, toExclude); } foreach (var lookup in values.ToLookup(change => change.Project)) { if (projectToCache.TryGetValue(lookup.Key, out var cache)) { cache.Add(lookup.ToList()); } else { cache = new ChangeCache(); cache.Add(lookup.ToList()); projectToCache.Add(lookup.Key, cache); } } } foreach (var(project, cache) in projectToCache) { var output = _renderer.Render(_template, cache.GetAsValueDictionary()); projectToOutput.Add(project, output); } return(projectToOutput); }