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));
        }
        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));
        }
        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));
        }