private void TestSkypOpen() { var skyZipPath = TestContext.GetProjectDirectory(@"TestFunctional\LibraryShareTest.zip"); // Reusing ShareDocumentTest test file var skypPath = TestFilesDir.GetTestPath("test.skyp"); var skyp = SkypFile.Create(skypPath, new List <Server>()); Assert.IsNull(skyp.Server); var server = new Server("http://fakepanoramalabkeyserver.org", "user", "password"); skyp = SkypFile.Create(skypPath, new[] { server, new Server("http://anotherserver.org", null, null) }); Assert.AreEqual(skyp.Server, server); var skyZipName = Path.GetFileName(skyZipPath); Assert.AreEqual(TestFilesDir.GetTestPath(skyZipName), skyp.DownloadPath); var downloadClient = new TestDownladClient(skyZipPath, skyp.DownloadPath, true); // This will throw an error var skypSupport = new SkypSupport(SkylineWindow) { DownloadClient = downloadClient }; var errDlg = ShowDialog <MessageDlg>(() => skypSupport.Open(skypPath, null)); Assert.IsTrue(errDlg.Message.Contains(string.Format( Resources .SkypSupport_Download_You_may_have_to_add__0__as_a_Panorama_server_from_the_Tools___Options_menu_in_Skyline_, skyp.SkylineDocUri.Host))); RunUI(() => { errDlg.ClickOk(); }); WaitForClosedForm(errDlg); skypSupport.DownloadClient = new TestDownladClient(skyZipPath, skyp.DownloadPath); RunUI(() => skypSupport.Open(skypPath, null)); WaitForDocumentLoaded(); var skyZipNoExt = Path.GetFileNameWithoutExtension(skyZipPath); var explodedDir = TestFilesDir.GetTestPath(skyZipNoExt); Assert.AreEqual(Path.Combine(explodedDir, skyZipNoExt + SrmDocument.EXT), SkylineWindow.DocumentFilePath); }
private void TestSkypValid() { AssertEx.ThrowsException <InvalidDataException>( () => SkypFile.GetSkyFileUrl(new StringReader(STR_EMPTY_SKYP)), string.Format( Resources.SkypFile_GetSkyFileUrl_File_does_not_contain_the_URL_of_a_shared_Skyline_archive_file___0___on_a_Panorama_server_, SrmDocumentSharing.EXT_SKY_ZIP)); var err = string.Format( Resources .SkypFile_GetSkyFileUrl_Expected_the_URL_of_a_shared_Skyline_document_archive___0___in_the_skyp_file__Found__1__instead_, SrmDocumentSharing.EXT_SKY_ZIP, STR_INVALID_SKYP1); AssertEx.ThrowsException <InvalidDataException>(() => SkypFile.GetSkyFileUrl(new StringReader(STR_INVALID_SKYP1)), err); err = string.Format(Resources.SkypFile_GetSkyFileUrl__0__is_not_a_valid_URL_on_a_Panorama_server_, STR_INVALID_SKYP2); AssertEx.ThrowsException <InvalidDataException>(() => SkypFile.GetSkyFileUrl(new StringReader(STR_INVALID_SKYP2)), err); AssertEx.NoExceptionThrown <Exception>(() => SkypFile.GetSkyFileUrl(new StringReader(STR_VALID_SKYP))); }
private void TestSkypGetNonExistentPath() { const string skyZip = "empty.sky.zip"; var skyZipPath = TestFilesDir.GetTestPath(skyZip); Assert.AreEqual(skyZipPath, SkypFile.GetNonExistentPath(TestFilesDir.FullPath, skyZip)); // Create the file so that GetNonExistentPath appends a (1) suffix to the file name using (File.Create(skyZipPath)) { } Assert.IsTrue(File.Exists(skyZipPath)); skyZipPath = TestFilesDir.GetTestPath("empty(1).sky.zip"); Assert.AreEqual(skyZipPath, SkypFile.GetNonExistentPath(TestFilesDir.FullPath, skyZip)); // Create a empty(1) directory. // Now empty.sky.zip AND empty(1) directory exist in the folder. // empty(1).sky.zip does not exist, but opening a file by this name will extract the zip // in an empty(1)(1) since empty(1) exists. So we append a (2) suffix to fhe filename so // that the zip is extracted in an empty(2) folder. Directory.CreateDirectory(TestFilesDir.GetTestPath("empty(1)")); skyZipPath = TestFilesDir.GetTestPath("empty(2).sky.zip"); Assert.AreEqual(skyZipPath, SkypFile.GetNonExistentPath(TestFilesDir.FullPath, skyZip)); }