public void TestRemoteSource_Acquire() { RemoteTemplatesSource rts = new RemoteTemplatesSource(); rts.LoadConfig(); var package = rts.Config.Latest; rts.Acquire(ref package); string acquiredContentFolder = package.LocalPath; Assert.NotNull(acquiredContentFolder); // Ensure package is not downloaded again if already downloaded rts.Acquire(ref package); Assert.True(acquiredContentFolder == package.LocalPath); // Reset localPath and ensure it is acquired again if (Directory.Exists(Path.GetDirectoryName(package.LocalPath))) { Directory.Delete(Path.GetDirectoryName(package.LocalPath), true); } rts.Acquire(ref package); Assert.True(package.LocalPath != acquiredContentFolder); if (Directory.Exists(Path.GetDirectoryName(package.LocalPath))) { Directory.Delete(Path.GetDirectoryName(package.LocalPath), true); } }
public void TestRemoteSource_GetContent() { string drive = Path.GetPathRoot(new Uri(typeof(TemplatePackageTests).Assembly.CodeBase).LocalPath); string testDir = Path.Combine(drive, $@"Temp\TestRts{Process.GetCurrentProcess().Id}_{Thread.CurrentThread.ManagedThreadId}"); try { RemoteTemplatesSource rts = new RemoteTemplatesSource(); rts.LoadConfig(); var package = rts.Config.Latest; rts.Acquire(ref package); var contentInfo = rts.GetContent(package, testDir); Assert.True(Directory.Exists(contentInfo.Path)); } finally { if (Directory.Exists(testDir)) { Directory.Delete(testDir, true); } } }