private IToolPackage GetOldPackage(IToolPackageStoreQuery toolPackageStoreQuery) { IToolPackage oldPackageNullable; try { oldPackageNullable = toolPackageStoreQuery.EnumeratePackageVersions(_packageId).SingleOrDefault(); } catch (InvalidOperationException) { throw new GracefulException( messages: new[] { string.Format( LocalizableStrings.ToolHasMultipleVersionsInstalled, _packageId), }, isUserError: false); } return(oldPackageNullable); }
private static void AssertPackageInstall( BufferedReporter reporter, IFileSystem fileSystem, IToolPackage package, IToolPackageStore store, IToolPackageStoreQuery storeQuery) { reporter.Lines.Should().BeEmpty(); package.Id.Should().Be(TestPackageId); package.Version.ToNormalizedString().Should().Be(TestPackageVersion); package.PackageDirectory.Value.Should().Contain(store.Root.Value); storeQuery.EnumeratePackageVersions(TestPackageId) .Select(p => p.Version.ToNormalizedString()) .Should() .Equal(TestPackageVersion); package.Commands.Count.Should().Be(1); fileSystem.File.Exists(package.Commands[0].Executable.Value).Should() .BeTrue($"{package.Commands[0].Executable.Value} should exist"); package.Commands[0].Executable.Value.Should().Contain(store.Root.Value); }