Inheritance: IPackageInstaller
Ejemplo n.º 1
0
            public void ShouldInstallAllPassedPackages()
            {
                var provider = new Mock<IInstallationProvider>();
                provider.Setup(
                    i => i.InstallPackage(It.IsAny<IPackageReference>(), It.IsAny<bool>(), It.IsAny<Action<string>>()))
                        .Returns(true);

                var references = new List<IPackageReference> {
                    new PackageReference("testId", VersionUtility.ParseFrameworkName("net40"), new Version("3.0")),
                    new PackageReference("testId2", VersionUtility.ParseFrameworkName("net40"), new Version("4.0")),
                    new PackageReference("testId3", VersionUtility.ParseFrameworkName("net40"), new Version("5.0"))
                };

                var installer = new PackageInstaller(provider.Object);
                installer.InstallPackages(references);

                provider.Verify(i => i.InstallPackage(It.IsAny<IPackageReference>(), It.IsAny<bool>(), It.IsAny<Action<string>>()), Times.Exactly(3));
            }
Ejemplo n.º 2
0
            public void ShouldNotInstallExistingPackages()
            {
                var callbacks = new List<string>();
                var provider = new Mock<IInstallationProvider>();
                provider.Setup(
                    i => i.IsInstalled(It.Is<IPackageReference>(x => x.PackageId == "testId"), It.IsAny<bool>()))
                        .Returns(true);

                var references = new List<IPackageReference> {
                    new PackageReference("testId", VersionUtility.ParseFrameworkName("net40"), new Version("3.0")),
                    new PackageReference("testId2", VersionUtility.ParseFrameworkName("net40"), new Version("4.0")),
                    new PackageReference("testId3", VersionUtility.ParseFrameworkName("net40"), new Version("5.0"))
                };

                var installer = new PackageInstaller(provider.Object);
                installer.InstallPackages(references);

                provider.Verify(i => i.InstallPackage(It.Is<IPackageReference>(x => x.PackageId == "testId"), It.IsAny<bool>(), It.IsAny<Action<string>>()), Times.Never());
            }
Ejemplo n.º 3
0
            public void ShouldShowErrorIfOneOfPackagesFail()
            {
                var callbacks = new List<string>();
                var provider = new Mock<IInstallationProvider>();
                provider.Setup(
                    i => i.InstallPackage(It.IsAny<IPackageReference>(), It.IsAny<bool>(), It.IsAny<Action<string>>()))
                        .Returns(true);
                provider.Setup(
                    i => i.InstallPackage(It.Is<IPackageReference>(x => x.PackageId == "testId"), It.IsAny<bool>(), It.IsAny<Action<string>>()))
                        .Returns(false);

                var references = new List<IPackageReference> {
                    new PackageReference("testId", VersionUtility.ParseFrameworkName("net40"), new Version("3.0")),
                    new PackageReference("testId2", VersionUtility.ParseFrameworkName("net40"), new Version("4.0")),
                    new PackageReference("testId3", VersionUtility.ParseFrameworkName("net40"), new Version("5.0"))
                };

                var installer = new PackageInstaller(provider.Object);
                installer.InstallPackages(references, true, msg => callbacks.Add(msg));

                provider.Verify(i => i.InstallPackage(It.IsAny<IPackageReference>(), It.IsAny<bool>(), It.IsAny<Action<string>>()), Times.Exactly(3));
                callbacks.Count.ShouldEqual(1);
                callbacks.Count(x => x.EndsWith("unsuccessful.")).ShouldEqual(1);
            }
Ejemplo n.º 4
0
            public void ShouldThrowArgumentNullExWhenNoPackageIdsPassed()
            {
                var installer = new PackageInstaller(new Mock<IInstallationProvider>().Object);

                Assert.Throws<ArgumentNullException>(() => installer.InstallPackages(null));
            }