Пример #1
0
        public async Task Test_DeleteFilesAsync()
        {
            string workingDir = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());

            Directory.CreateDirectory(workingDir);

            EnvironmentSettings settings = TestEnvironmentHelper.GetTestSettings(
                workingDir,
                Path.Combine(workingDir, "cache"));

            IHostInteractionInternal hostInteraction = new HostInteraction(settings);

            Directory.CreateDirectory(Path.Combine(workingDir, "jquery"));
            string jqueryFilePath = Path.Combine("jquery", "jquery.min.js");

            File.WriteAllText(Path.Combine(workingDir, jqueryFilePath), "");

            await hostInteraction.DeleteFilesAsync(new[] { jqueryFilePath }, CancellationToken.None);

            Assert.IsFalse(File.Exists(Path.Combine(workingDir, jqueryFilePath)));
            Assert.IsFalse(Directory.Exists(Path.Combine(workingDir, "jquery")));
        }
Пример #2
0
        public async Task UninstallAsync_Success()
        {
            var manifest            = new Manifest(_dependencies);
            CancellationToken token = CancellationToken.None;

            IProvider provider     = _dependencies.GetProvider("cdnjs");
            var       desiredState = new LibraryInstallationState
            {
                LibraryId       = "[email protected]",
                ProviderId      = "cdnjs",
                DestinationPath = "lib",
                Files           = new[] { "jquery.js", "jquery.min.js" }
            };

            manifest.AddVersion("1.0");
            manifest.AddLibrary(desiredState);
            IEnumerable <ILibraryOperationResult> results = await manifest.RestoreAsync(token);

            string file1 = Path.Combine(_projectFolder, "lib", "jquery.js");
            string file2 = Path.Combine(_projectFolder, "lib", "jquery.min.js");

            Assert.IsTrue(File.Exists(file1));
            Assert.IsTrue(File.Exists(file2));
            Assert.IsTrue(results.Count() == 1);
            Assert.IsTrue(results.First().Success);

            ILibraryOperationResult uninstallResult = await manifest.UninstallAsync(desiredState.LibraryId, (file) => _hostInteraction.DeleteFilesAsync(file, token), token);

            Assert.IsFalse(File.Exists(file1));
            Assert.IsFalse(File.Exists(file2));
            Assert.IsTrue(results.Count() == 1);
            Assert.IsTrue(results.First().Success);
        }