コード例 #1
0
        public void TestInstallerCreationShouldNotCreateBinDirectory()
        {
            Directory.Delete(binDir);

            _ = new InstallerLibrary(io, bucket);
            Assert.IsFalse(Directory.Exists(binDir));
        }
コード例 #2
0
        public void TestIsSupports()
        {
            var installer = new InstallerLibrary(io, bucket);

            Assert.IsTrue(installer.IsSupports("library"));
            Assert.IsFalse(installer.IsSupports(null));
            Assert.IsFalse(installer.IsSupports("foo"));
        }
コード例 #3
0
        public void TestUninstallNotInstalledPackage()
        {
            var installer   = new InstallerLibrary(io, bucket);
            var packageMock = new Mock <IPackage>();

            repository.Setup((o) => o.HasPackage(packageMock.Object)).Returns(false);

            installer.Uninstall(repository.Object, packageMock.Object);
        }
コード例 #4
0
        public void TestGetInstallPath()
        {
            var installer   = new InstallerLibrary(io, bucket);
            var packageMock = new Mock <IPackage>();

            packageMock.Setup((o) => o.GetNamePretty()).Returns("foo");

            Assert.AreEqual(
                vendorDir + "/" + packageMock.Object.GetNamePretty(),
                installer.GetInstallPath(packageMock.Object));
        }
コード例 #5
0
        public void TestUpdatePackageNotInstalled()
        {
            var installer = new InstallerLibrary(io, bucket);

            repository.Setup((o) => o.HasPackage(It.IsAny <IPackage>())).Returns(false);

            var initial = new Mock <IPackage>();
            var target  = new Mock <IPackage>();

            installer.Update(repository.Object, initial.Object, target.Object);
        }
コード例 #6
0
        public void TestEnsureBinariesInstalled()
        {
            var binaryInstallerMock = new Mock <InstallerBinary>(IONull.That, "vendor/bin", "auto", null);
            var installer           = new InstallerLibrary(io, bucket, installerBinary: binaryInstallerMock.Object);
            var packageMock         = new Mock <IPackage>();

            installer.EnsureBinariesPresence(packageMock.Object);

            binaryInstallerMock.Verify((o) => o.Remove(It.IsAny <IPackage>()), Times.Never);
            binaryInstallerMock.Verify((o) =>
                                       o.Install(packageMock.Object, installer.GetInstallPath(packageMock.Object), false));
        }
コード例 #7
0
        public void TestIsInstalled()
        {
            var installer   = new InstallerLibrary(io, bucket);
            var packageMock = new Mock <IPackage>();

            repository.SetupSequence((o) => o.HasPackage(packageMock.Object))
            .Returns(true)
            .Returns(false);

            Assert.IsTrue(installer.IsInstalled(repository.Object, packageMock.Object));
            Assert.IsFalse(installer.IsInstalled(repository.Object, packageMock.Object));
        }
コード例 #8
0
        public void TestInstall()
        {
            var installer   = new InstallerLibrary(io, bucket);
            var packageMock = new Mock <IPackage>();

            packageMock.Setup((o) => o.GetNamePretty()).Returns("foo/bar");
            packageMock.Setup((o) => o.Clone()).Returns(packageMock.Object);

            installer.Install(repository.Object, packageMock.Object);

            downloadManager.Verify((o) => o.Install(packageMock.Object, vendorDir + "/foo/bar"));
            repository.Verify((o) => o.AddPackage(packageMock.Object));
        }
コード例 #9
0
        public void TestUninstall()
        {
            var installer   = new InstallerLibrary(io, bucket);
            var packageMock = new Mock <IPackage>();

            packageMock.Setup((o) => o.GetName()).Returns("foo");
            packageMock.Setup((o) => o.GetNamePretty()).Returns("foo");
            repository.SetupSequence((o) => o.HasPackage(packageMock.Object))
            .Returns(true).Returns(false);

            installer.Uninstall(repository.Object, packageMock.Object);

            downloadManager.Verify((o) => o.Remove(packageMock.Object, vendorDir + "/foo"));
            repository.Verify((o) => o.RemovePackage(packageMock.Object));
        }
コード例 #10
0
        public void TestUninstallDeleteVendorDirIfDirIsEmpty()
        {
            var fileSystemMock = new Mock <IFileSystem>();
            var installer      = new InstallerLibrary(io, bucket, fileSystem: fileSystemMock.Object);
            var packageMock    = new Mock <IPackage>();

            repository.Setup((o) => o.HasPackage(packageMock.Object)).Returns(true);
            packageMock.Setup((o) => o.GetName()).Returns("foo/bar");

            var fullVendorDir = Path.GetDirectoryName(installer.GetInstallPath(packageMock.Object));

            fileSystemMock.Setup((o) => o.Exists(fullVendorDir, FileSystemOptions.Directory)).Returns(true);

            installer.Uninstall(repository.Object, packageMock.Object);

            fileSystemMock.Verify((o) => o.Delete(fullVendorDir));
        }
コード例 #11
0
        public void TestUpdate()
        {
            var fileSystemMock = new Mock <IFileSystem>();
            var installer      = new InstallerLibrary(io, bucket, fileSystem: fileSystemMock.Object);
            var initial        = new Mock <IPackage>();
            var target         = new Mock <IPackage>();

            initial.Setup((o) => o.GetNamePretty()).Returns("foo/old");
            target.Setup((o) => o.GetNamePretty()).Returns("foo/new");
            target.Setup((o) => o.Clone()).Returns(target.Object);

            repository.SetupSequence((o) => o.HasPackage(It.IsAny <IPackage>()))
            .Returns(true).Returns(false);

            installer.Update(repository.Object, initial.Object, target.Object);

            downloadManager.Verify((o) => o.Update(initial.Object, target.Object, vendorDir + "/foo/new"));
            fileSystemMock.Verify((o) => o.Move(vendorDir + "/foo/old", vendorDir + "/foo/new"));
            repository.Verify((o) => o.RemovePackage(initial.Object));
            repository.Verify((o) => o.AddPackage(target.Object));
        }