Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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()");
        }
Ejemplo n.º 3
0
        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()");
        }
Ejemplo n.º 4
0
        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);
        }