private void RewriteTaxmlAndAssertOutput(string inputResourceName, string outputResourceName, [CallerMemberName] string testGroupName = "") { string inputTaxmlString = this.GetTestResource(inputResourceName, testGroupName); LocalTermStore termStore = TaxmlLoader.LoadFromString(inputTaxmlString); string outputTaxmlString = TaxmlSaver.SaveToString(termStore); this.AssertXmlMatchesResource(outputTaxmlString, outputResourceName, testGroupName); }
public void LoadFile(string filenameToLoad) { TaxmlLoader loader = new TaxmlLoader(); LocalTermStore termStore = loader.LoadFromFile(filenameToLoad); this.ctlListView.TermStore = termStore; this.Filename = filenameToLoad; this.Modified = false; this.UpdateUI(); }
public void UploadBatchingTest() { Debug.WriteLine("START UploadBatchingTest()"); // Clean up any previous data SampleData.DeleteTestGroups(); string initialInputTaxml = this.GetTestResource("Input"); LocalTermStore initialTermStore = TaxmlLoader.LoadFromString(initialInputTaxml); this.connector.Upload(initialTermStore, SampleData.TermStoreId); string initialOutputTaxml = FunctionalTests.DownloadTestDataAsTaxml(this.connector); this.AssertXmlMatchesResource(initialOutputTaxml, "Output"); Debug.WriteLine("END UploadBatchingTest()"); }
public void UploadWithTermLinkSourcePath_NotFoundError() { Debug.WriteLine("START UploadWithTermLinkSourcePath_NotFoundError()"); // Clean up any previous data SampleData.DeleteTestGroups(); SampleData.CreateMinimal(); try { string initialInputTaxml = this.GetTestResource("Input"); LocalTermStore initialTermStore = TaxmlLoader.LoadFromString(initialInputTaxml); this.connector.Upload(initialTermStore, SampleData.TermStoreId); Assert.Fail("The expected exception was not thrown"); } catch (InvalidOperationException ex) { Assert.IsTrue(ex.Message.StartsWith("Unable to find term specified by the TermLinkSourcePath:")); } Debug.WriteLine("END UploadWithTermLinkSourcePath_NotFoundError()"); }
protected override void BeginProcessing() { base.BeginProcessing(); ExportImportHelpers.WriteStartupBanner(this.AppLog); string inputFilename = ExportImportHelpers.GetAbsolutePath(this.Path, this.SessionState); // Validate parameters if (!File.Exists(inputFilename)) { // If the "taxml" extension was omitted, try adding it if (string.IsNullOrEmpty(System.IO.Path.GetExtension(inputFilename)) && !inputFilename.EndsWith(".")) { inputFilename += ".taxml"; } if (!File.Exists(inputFilename)) { throw new FileNotFoundException("The TAXML input file does not exist: " + inputFilename); } } ExportImportHelpers.ValidateSiteUrl(this.SiteUrl); this.AppLog.WriteInfo("Reading TAXML input from " + inputFilename); TaxmlLoader loader = new TaxmlLoader(); LocalTermStore loadedTermStore = loader.LoadFromFile(inputFilename); this.AppLog.WriteInfo("Connecting to SharePoint site: " + this.SiteUrl); Client15Connector clientConnector = ExportImportHelpers.CreateClientConnector( this.SiteUrl, this.Credential, this.CloudCredential, this.AppLog); clientConnector.UploadingItem += this.clientConnector_UploadingItem; List <LocalTermStore> fetchedTermStores = clientConnector.FetchTermStores(); Guid?optionalTermStoreId = null; if (this.MyInvocation.BoundParameters.ContainsKey(ImportTaxmlCommand.PropertyName_TermStoreId)) { optionalTermStoreId = this.TermStoreId; } LocalTermStore fetchedTermStore = ExportImportHelpers.SelectTermStore(fetchedTermStores, optionalTermStoreId); this.AppLog.WriteLine(); this.AppLog.WriteInfo("Starting operation..."); this.AppLog.WriteLine(); var options = new ClientConnectorUploadOptions(); if (this.MyInvocation.BoundParameters.ContainsKey(ImportTaxmlCommand.PropertyName_MaximumBatchSize)) { options.MaximumBatchSize = this.MaximumBatchSize; } clientConnector.Upload(loadedTermStore, fetchedTermStore.Id, options); var progressRecord = new ProgressRecord(0, ImportTaxmlCommand.ProgressRecordTitle, "Finished."); progressRecord.RecordType = ProgressRecordType.Completed; this.WriteProgress(progressRecord); this.AppLog.WriteLine(); this.AppLog.WriteInfo("The operation completed successfully."); this.AppLog.WriteLine(); }
private void DoCreateUpdateModify(string testGroupName) { // Clean up any previous data SampleData.DeleteTestGroups(); var options = new ClientConnectorUploadOptions(); // options.MaximumBatchSize = 1; //--------------------------------------------------------------- // Initial creation of the objects Debug.WriteLine("Part 1: Upload that initially creates objects"); string initialInputTaxml = this.GetTestResource("InitialInput", testGroupName); LocalTermStore initialTermStore = TaxmlLoader.LoadFromString(initialInputTaxml); initialTermStore.SyncAction = new SyncAction() { IfMissing = SyncActionIfMissing.Create, IfPresent = SyncActionIfPresent.Error, IfElsewhere = SyncActionIfElsewhere.Error }; this.connector.Upload(initialTermStore, SampleData.TermStoreId, options); string initialOutputTaxml = FunctionalTests.DownloadTestDataAsTaxml(this.connector); this.AssertXmlMatchesResource(initialOutputTaxml, "InitialOutput", testGroupName); //--------------------------------------------------------------- // Perform a second upload of the exact same content, to verify that // no changes were committed to the term store Debug.WriteLine("Part 2: Duplicate upload that doesn't change anything"); initialTermStore.SyncAction = new SyncAction() { IfMissing = SyncActionIfMissing.Error, IfPresent = SyncActionIfPresent.Update, IfElsewhere = SyncActionIfElsewhere.Error }; DateTime changeTimeBefore = this.GetChangeTimeForTermStore(); this.connector.Upload(initialTermStore, SampleData.TermStoreId, options); DateTime changeTimeAfter = this.GetChangeTimeForTermStore(); Assert.AreEqual(changeTimeAfter, changeTimeBefore); //--------------------------------------------------------------- // Upload a modified input that changes every property Debug.WriteLine("Part 3: Upload that makes modifications"); string modifiedInputTaxml = this.GetTestResource("ModifiedInput", testGroupName); LocalTermStore modifiedTermStore = TaxmlLoader.LoadFromString(modifiedInputTaxml); modifiedTermStore.SyncAction = new SyncAction() { IfMissing = SyncActionIfMissing.Error, IfPresent = SyncActionIfPresent.Update, IfElsewhere = SyncActionIfElsewhere.Error }; this.connector.Upload(modifiedTermStore, SampleData.TermStoreId, options); string modifiedOutputTaxml = FunctionalTests.DownloadTestDataAsTaxml(this.connector); this.AssertXmlMatchesResource(modifiedOutputTaxml, "ModifiedOutput", testGroupName); }