public async Task SitemapGeneratedWithSitemapItemAsString(string hostname, string formatterString, string expected) { // Given TestExecutionContext context = new TestExecutionContext(); context.Settings[Keys.LinkHideExtensions] = "true"; if (!string.IsNullOrWhiteSpace(hostname)) { context.Settings[Keys.Host] = hostname; } TestDocument doc = new TestDocument(new FilePath("sub/testfile.html"), "Test"); IDocument[] inputs = { doc }; SetMetadata m = new SetMetadata( Keys.SitemapItem, Config.FromDocument(d => d.Destination.FullPath)); Func <string, string> formatter = null; if (!string.IsNullOrWhiteSpace(formatterString)) { formatter = f => string.Format(formatterString, f); } GenerateSitemap sitemap = new GenerateSitemap(formatter); // When TestDocument result = await ExecuteAsync(doc, context, m, sitemap).SingleAsync(); // Then result.Content.ShouldContain($"<loc>{expected}</loc>"); }
public async Task MetadataKeys() { // Given TestDocument a = new TestDocument { { "Name", "A" }, { "A", "a" }, { "B", "b" } }; TestDocument b = new TestDocument { { "Name", "B" }, { "A", "a" } }; SetMetadata set = new SetMetadata("C", "c"); // When ImmutableArray <TestDocument> results = await ExecuteAsync(new TestDocument[] { a, b }, new ExecuteIf(new[] { "A", "B" }, set)); // Then TestDocument resultA = results.Single(x => x.GetString("Name") == "A"); TestDocument resultB = results.Single(x => x.GetString("Name") == "B"); resultA["A"].ShouldBe("a"); resultA["B"].ShouldBe("b"); resultA["C"].ShouldBe("c"); resultB["A"].ShouldBe("a"); resultB.Keys.ShouldNotContain("B"); resultB.Keys.ShouldNotContain("C"); }
public async Task IgnoresNull() { // Given TestDocument input = new TestDocument(); SetMetadata module = new SetMetadata("Foo", (string)null).IgnoreNull(); // When IReadOnlyList <TestDocument> results = await ExecuteAsync(input, module); // Then results.Single().Keys.ShouldNotContain("Foo"); }
public async Task AddsNull() { // Given TestDocument input = new TestDocument(); SetMetadata module = new SetMetadata("Foo", (string)null); // When IReadOnlyList <TestDocument> results = await ExecuteAsync(input, module); // Then results.Single()["Foo"].ShouldBe((string)null); }
public async Task OnlyIfNonExisting() { // Given TestDocument input = new TestDocument { { "Foo", "Baz" } }; SetMetadata module = new SetMetadata("Foo", "Bar").OnlyIfNonExisting(); // When IReadOnlyList <TestDocument> results = await ExecuteAsync(input, module); // Then results.Single()["Foo"].ShouldBe("Baz"); }
public static void Main(string[] args) { //// *********************************************************** //// GroupDocs.Comparison Cloud API Examples //// *********************************************************** //TODO: Get your Client Id and Client secret at https://dashboard.groupdocs.cloud (free registration is required). Constants.MyClientId = "XXXX-XXXX-XXXX-XXXX"; Constants.MyClientSecret = "XXXXXXXXXXXXXXXX"; Constants.MyStorage = "First Storage"; // Uploading sample test files from local disk to cloud storage Constants.UploadSampleTestFiles(); #region Basic usage GetSupportedFormats.Run(); GetDocumentInformation.Run(); CompareDocuments.Run(); ComparePdfDocuments.Run(); #endregion #region Advanced usage CompareProtectedDocuments.Run(); AcceptOrRejectChanges.Run(); CompareMultipleDocumentsOptions.Run(); CompareMultipleProtectedDocuments.Run(); CompareSensitivity.Run(); CustomizeChangesStyles.Run(); GetListOfChanges.Run(); GetChangesCoordinates.Run(); SetPassword.Run(); SetMetadata.Run(); GetListOfRevisions.Run(); ApplyRevisions.Run(); AcceptAllRevisions.Run(); RejectAllRevisions.Run(); #endregion Console.WriteLine("Completed!"); Console.ReadKey(); }
public async Task GroupByMetadataKey() { // Given List <int> groupKey = new List <int>(); CountModule count = new CountModule("A") { AdditionalOutputs = 7, EnsureInputDocument = true }; SetMetadata meta = new SetMetadata("GroupMetadata", Config.FromDocument(d => new object[] { d.GetInt("A") % 3, 3 })); GroupDocuments groupByMany = new GroupDocuments("GroupMetadata"); ForEachDocument gatherData = new ExecuteConfig( Config.FromDocument(d => { groupKey.Add(d.GetInt(Keys.GroupKey)); return((object)null); })).ForEachDocument(); // When IReadOnlyList <IDocument> results = await ExecuteAsync(count, meta, groupByMany, gatherData); // Then CollectionAssert.AreEquivalent(new[] { 0, 1, 2, 3 }, groupKey); }
private void OnOverride(object sender, RoutedEventArgs e) { Box.Text = SetMetadata.GetString(Box.Text); }