private IEnumerable <IToolPackage> GetPackages() { return(_toolPackageStore.EnumeratePackages() .Where(PackageHasCommands) .OrderBy(p => p.Id) .ToArray()); }
private IEnumerable <string> EnumerateExpectedTableLines(IToolPackageStore store) { string GetCommandsString(IToolPackage package) { return(string.Join(ListToolCommand.CommandDelimiter, package.Commands.Select(c => c.Name))); } var packages = store.EnumeratePackages().Where(PackageHasCommands).OrderBy(package => package.Id); var columnDelimiter = PrintableTable <IToolPackageStore> .ColumnDelimiter; int packageIdColumnWidth = LocalizableStrings.PackageIdColumn.Length; int versionColumnWidth = LocalizableStrings.VersionColumn.Length; int commandsColumnWidth = LocalizableStrings.CommandsColumn.Length; foreach (var package in packages) { packageIdColumnWidth = Math.Max(packageIdColumnWidth, package.Id.ToString().Length); versionColumnWidth = Math.Max(versionColumnWidth, package.Version.ToNormalizedString().Length); commandsColumnWidth = Math.Max(commandsColumnWidth, GetCommandsString(package).Length); } yield return(string.Format( "{0}{1}{2}{3}{4}", LocalizableStrings.PackageIdColumn.PadRight(packageIdColumnWidth), columnDelimiter, LocalizableStrings.VersionColumn.PadRight(versionColumnWidth), columnDelimiter, LocalizableStrings.CommandsColumn.PadRight(commandsColumnWidth))); yield return(new string( '-', packageIdColumnWidth + versionColumnWidth + commandsColumnWidth + (columnDelimiter.Length * 2))); foreach (var package in packages) { yield return(string.Format( "{0}{1}{2}{3}{4}", package.Id.ToString().PadRight(packageIdColumnWidth), columnDelimiter, package.Version.ToNormalizedString().PadRight(versionColumnWidth), columnDelimiter, GetCommandsString(package).PadRight(commandsColumnWidth))); } }