public void TestCacheClean_ThrowsIfUnknownProvider() { var cleanCommand = new CacheCleanCommand(HostEnvironment); cleanCommand.Configure(); var exception = Assert.ThrowsException <AggregateException>(() => cleanCommand.Execute("foo")); Assert.IsInstanceOfType(exception.InnerExceptions.First(), typeof(InvalidOperationException)); }
public void TestCacheClean_ForProvider() { string contents = @"{ ""version"": ""1.0"", ""defaultProvider"": ""cdnjs"", ""defaultDestination"": ""wwwroot"", ""libraries"": [ { ""library"": ""[email protected]"", ""files"": [ ""jquery.min.js"", ""core.js"" ] } ] }"; File.WriteAllText(Path.Combine(WorkingDir, "libman.json"), contents); Directory.CreateDirectory(Path.Combine(CacheDir, "filesystem")); File.WriteAllText(Path.Combine(CacheDir, "filesystem", "abc.js"), ""); var restoreCommand = new RestoreCommand(HostEnvironment); restoreCommand.Configure(null).Execute(); Assert.IsTrue(File.Exists(Path.Combine(WorkingDir, "wwwroot", "jquery.min.js"))); Assert.IsTrue(File.Exists(Path.Combine(WorkingDir, "wwwroot", "core.js"))); Assert.IsTrue(File.Exists(Path.Combine(CacheDir, "cdnjs", "jquery", "3.2.1", "jquery.min.js"))); Assert.IsTrue(File.Exists(Path.Combine(CacheDir, "cdnjs", "jquery", "3.2.1", "core.js"))); var cleanCommand = new CacheCleanCommand(HostEnvironment); cleanCommand.Configure(); cleanCommand.Execute("cdnjs"); // Should not delete files in the project. Assert.IsTrue(File.Exists(Path.Combine(WorkingDir, "wwwroot", "jquery.min.js"))); Assert.IsTrue(File.Exists(Path.Combine(WorkingDir, "wwwroot", "core.js"))); // Should delete files in the cache. Assert.IsFalse(File.Exists(Path.Combine(CacheDir, "cdnjs", "jquery", "3.2.1", "jquery.min.js"))); Assert.IsFalse(File.Exists(Path.Combine(CacheDir, "cdnjs", "jquery", "3.2.1", "core.js"))); Assert.IsTrue(File.Exists(Path.Combine(CacheDir, "fileSystem", "abc.js"))); }