Esempio n. 1
0
        public void Be_Creatable()
        {
            var sut = new NuPlugPackageRegistry();

            var package = "foo".CreatePackage("0.1.0");

            sut.Exists(package.Id).Should().BeFalse();

            sut.Add(package);
            sut.Add(package.Id, package.Version);

            sut.Exists(package.Id).Should().BeTrue();
            sut.Exists(package.Id, package.Version).Should().BeTrue();
            sut.Exists(package.Id, SemanticVersion.Parse("0.2.0")).Should().BeFalse();

            sut.Invoking(x => x.FindPackage(null, null)).ShouldThrow <ArgumentException>();
            sut.Invoking(x => x.FindPackage(package.Id, null)).ShouldThrow <ArgumentException>();
            sut.Invoking(x => x.FindPackage("\t\r\n", package.Version)).ShouldThrow <ArgumentException>();

            sut.FindPackage(package.Id, package.Version).ShouldBeEquivalentTo(package);
            sut.FindPackage(package.Id, SemanticVersion.Parse("0.2.0")).Should().BeNull();

            sut.FindPackagesById(package.Id).ShouldAllBeEquivalentTo(new[] { package });
            sut.FindPackagesById("bar").Should().BeEmpty();
        }
        public void Ignore_AlreadyInstalled_Packages()
        {
            var context = new ContextFor <NuPlugPackageManager>();

            var packageLookup   = Substitute.For <IPackageLookup>();
            var packageRegistry = new NuPlugPackageRegistry();
            var localRepo       = new NuPlugPackageRepository(packageLookup, packageRegistry);

            var sut         = context.BuildSut();
            var foo         = "foo".CreatePackage("0.1.0");
            var bar         = "bar".CreatePackage("2.9.0");
            var versionSpec = new VersionSpec(SemanticVersion.Parse("2.6.0"))
            {
                MaxVersion = null
            };
            var deps = new[]
            { new PackageDependencySet(sut.TargetFramework, new[] { new PackageDependency(bar.Id, versionSpec) }) };

            foo.DependencySets.Returns(deps);

            localRepo.AddPackage(new NullPackage(bar.Id, bar.Version));

            var remotePackages = new[] { foo };

            sut.SourceRepository.GetPackages().Returns(remotePackages.AsQueryable());
            sut.SetLocalRepository(localRepo);

            sut.Logger = new TraceLogger();
            using (var tl = new TestTraceListener())
            {
                sut.InstallPackage(foo, false, true);

                var infos = tl.MessagesFor(TraceLevel.Info);
                infos.Should().BeEquivalentTo(
                    $"Attempting to resolve dependency '{bar.Id} (≥ {versionSpec.MinVersion})'.",
                    //$"{bar.Id} already installed.",
                    $"Installing '{foo.Id} {foo.Version}'.",
                    $"Successfully installed '{foo.Id} {foo.Version}'."
                    );
            }
        }