コード例 #1
0
        private void FillNetVersionSupport(FeatureTable table, ILibrary library, IEnumerable<IGrouping<string, FrameworkName>> allVersionsGrouped)
        {
            if (library.PackageId == null) {
                // this is always intentional
                foreach (var versionGroup in allVersionsGrouped) {
                    var cell = table[library, versionGroup];
                    cell.State = FeatureState.Skipped;
                    cell.DisplayValue = "n/a";
                }

                return;
            }

            var package = this.packageCache.GetPackage(library.PackageId);
            var supported = package.GetSupportedFrameworks().ToArray();

            foreach (var versionGroup in allVersionsGrouped) {
                var cell = table[library, versionGroup];
                if (versionGroup.Any(v => VersionUtility.IsCompatible(v, supported))) {
                    cell.State = FeatureState.Success;
                    cell.DisplayValue = "yes";
                }
                else {
                    cell.State = FeatureState.Concern;
                    cell.DisplayValue = "no";
                }
            }
        }
コード例 #2
0
        public IEnumerable<FeatureTable> GetTables(Assembly featureTestAssembly) {
            var testRuns = this.runner.RunAllTests(featureTestAssembly).ToDictionary(r => new { Test = r.Method, LibraryType = r.AdapterType });
            var testGroups = testRuns.Keys
                                     .Select(k => k.Test)
                                     .Distinct()
                                     .GroupBy(m => m.DeclaringType)
                                     .OrderBy(g => FeatureTestAttributeHelper.GetDisplayOrder(g.Key))
                                     .ToArray();

            var libraries = LibraryProvider.GetAdapters(featureTestAssembly).ToArray();
            foreach (var group in testGroups) {
                var features = group.ToDictionary(m => m, this.ConvertToFeature);
                var table = new FeatureTable(FeatureTestAttributeHelper.GetDisplayName(group.Key), libraries, features.Values) {
                    Description = this.GetDescription(@group.Key),
                    Scoring = FeatureTestAttributeHelper.GetScoring(@group.Key)
                };

                var resultApplyTasks = new List<Task>();
                foreach (var test in group.OrderBy(FeatureTestAttributeHelper.GetDisplayOrder)) {
                    foreach (var library in libraries) {
                        var cell = table[library, test];
                        var run = testRuns[new { Test = test, LibraryType = library.GetType() }];

                        resultApplyTasks.Add(this.ApplyRunResultToCell(cell, run.Task));
                    }
                }

                Task.WaitAll(resultApplyTasks.ToArray());
                yield return table;
            }
        }
コード例 #3
0
 private string[] GetNetFxVersions(ILibrary library, FeatureTable table)
 {
     return table.Features.Where(f => table[library, f].State == FeatureState.Success)
                          .Select(f => (IGrouping<string, FrameworkName>)f.Key)
                          .Select(g => VersionUtility.GetShortFrameworkName(g.First()))
                          .ToArray();
 }
コード例 #4
0
        private FeatureTable GetTable(Assembly featureTestAssembly)
        {
            var libraries = LibraryProvider.GetAdapters(featureTestAssembly).ToArray();
            var allVersionsGrouped = libraries.Where(l => l.PackageId != null)
                                              .Select(l => this.packageCache.GetPackage(l.PackageId))
                                              .SelectMany(p => p.GetSupportedFrameworks())
                                              .Where(NetFxVersionHelper.ShouldDisplay)
                                              .GroupBy(NetFxVersionHelper.GetDisplayName)
                                              .OrderBy(g => NetFxVersionHelper.GetDisplayOrder(g.First()))
                                              .ToList();

            var versionFeatures = allVersionsGrouped.Select(g => new Feature(g, g.Key));
            var table = new FeatureTable(MetadataKeys.NetFxSupportTable, "Supported .NET versions", libraries, versionFeatures) {
                Description = "This information is based on versions included in NuGet package.",
                Scoring = FeatureScoring.NotScored
            };

            foreach (var library in libraries) {
                this.FillNetVersionSupport(table, library, allVersionsGrouped);
            }

            return table;
        }
コード例 #5
0
        private static void CalculateTotal(FeatureTable general, IReadOnlyCollection<FeatureTable> all)
        {
            // special case
            var totals = general.Libraries.ToDictionary(
                library => library,
                library => all.Sum(t => t.GetScore(library))
            );

            var max = all.Sum(t => t.MaxScore);
            foreach (var total in totals) {
                var cell = general[total.Key, MetadataKeys.TotalFeature];
                var percent = 100 * ((double)total.Value / max);
                cell.DisplayValue = string.Format("{0:F0}%", percent);
                if (percent > 70) {
                    cell.State = FeatureState.Success;
                }
                else if (percent > 40) {
                    cell.State = FeatureState.Concern;
                }
                else {
                    cell.State = FeatureState.Failure;
                }
            }
        }