diff --git a/Examples/ApiExamples/ApiExamples/ExDocSaveOptions.cs b/Examples/ApiExamples/ApiExamples/ExDocSaveOptions.cs index 91f3d29a..a5650fbb 100644 --- a/Examples/ApiExamples/ApiExamples/ExDocSaveOptions.cs +++ b/Examples/ApiExamples/ApiExamples/ExDocSaveOptions.cs @@ -110,7 +110,9 @@ public void UpdateLastPrintedProperty(bool isUpdateLastPrintedProperty) //ExFor:SaveOptions.UpdateLastPrintedProperty //ExSummary:Shows how to update a document's "Last printed" property when saving. Document doc = new Document(); - doc.BuiltInDocumentProperties.LastPrinted = new DateTime(2019, 12, 20); + + DateTime lastPrinted = new DateTime(2019, 12, 20); + doc.BuiltInDocumentProperties.LastPrinted = lastPrinted; // This flag determines whether the last printed date, which is a built-in property, is updated. // If so, then the date of the document's most recent save operation @@ -125,7 +127,10 @@ public void UpdateLastPrintedProperty(bool isUpdateLastPrintedProperty) // Open the saved document, then verify the value of the property. doc = new Document(ArtifactsDir + "DocSaveOptions.UpdateLastPrintedProperty.doc"); - Assert.AreNotEqual(isUpdateLastPrintedProperty, new DateTime(2019, 12, 20) == doc.BuiltInDocumentProperties.LastPrinted); + if (isUpdateLastPrintedProperty) + Assert.AreNotEqual(lastPrinted, doc.BuiltInDocumentProperties.LastPrinted); + else + Assert.AreEqual(lastPrinted, doc.BuiltInDocumentProperties.LastPrinted); //ExEnd } @@ -137,7 +142,9 @@ public void UpdateCreatedTimeProperty(bool isUpdateCreatedTimeProperty) //ExFor:SaveOptions.UpdateCreatedTimeProperty //ExSummary:Shows how to update a document's "CreatedTime" property when saving. Document doc = new Document(); - doc.BuiltInDocumentProperties.CreatedTime = new DateTime(2019, 12, 20); + + DateTime createdTime = new DateTime(2019, 12, 20); + doc.BuiltInDocumentProperties.CreatedTime = createdTime; // This flag determines whether the created time, which is a built-in property, is updated. // If so, then the date of the document's most recent save operation @@ -150,7 +157,11 @@ public void UpdateCreatedTimeProperty(bool isUpdateCreatedTimeProperty) // Open the saved document, then verify the value of the property. doc = new Document(ArtifactsDir + "DocSaveOptions.UpdateCreatedTimeProperty.docx"); - Assert.AreNotEqual(isUpdateCreatedTimeProperty, new DateTime(2019, 12, 20) == doc.BuiltInDocumentProperties.CreatedTime); + if (isUpdateCreatedTimeProperty) + Assert.AreNotEqual(createdTime, doc.BuiltInDocumentProperties.CreatedTime); + else + Assert.AreEqual(createdTime, doc.BuiltInDocumentProperties.CreatedTime); + //ExEnd } diff --git a/Examples/ApiExamples/ApiExamples/ExDocumentProperties.cs b/Examples/ApiExamples/ApiExamples/ExDocumentProperties.cs index d4159a2a..65b8b0ca 100644 --- a/Examples/ApiExamples/ApiExamples/ExDocumentProperties.cs +++ b/Examples/ApiExamples/ApiExamples/ExDocumentProperties.cs @@ -529,8 +529,8 @@ public void CustomNamedAccess() Document doc = new Document(); doc.CustomDocumentProperties.Add("AuthorizationDate", DateTime.Now); - - Console.WriteLine($"Document authorized on {doc.CustomDocumentProperties["AuthorizationDate"].ToDateTime()}"); + DateTime authorizationDate = doc.CustomDocumentProperties["AuthorizationDate"].ToDateTime(); + Console.WriteLine($"Document authorized on {authorizationDate}"); //ExEnd TestUtil.VerifyDate(DateTime.Now, diff --git a/Examples/ApiExamples/ApiExamples/ExInlineStory.cs b/Examples/ApiExamples/ApiExamples/ExInlineStory.cs index e53d9081..8e77a758 100644 --- a/Examples/ApiExamples/ApiExamples/ExInlineStory.cs +++ b/Examples/ApiExamples/ApiExamples/ExInlineStory.cs @@ -562,7 +562,7 @@ public void InsertInlineStoryNodes() Assert.AreEqual(StoryType.Footnotes, footnote.StoryType); // A comment is another type of inline story. - Comment comment = builder.CurrentParagraph.AppendChild(new Comment(doc, "John Doe", "J. D.", DateTime.Now)); + Comment comment = (Comment)builder.CurrentParagraph.AppendChild(new Comment(doc, "John Doe", "J. D.", DateTime.Now)); // The parent paragraph of an inline story node will be the one from the main document body. Assert.AreEqual(doc.FirstSection.Body.FirstParagraph, comment.ParentParagraph); diff --git a/Examples/ApiExamples/ApiExamples/ExMarkdownSaveOptions.cs b/Examples/ApiExamples/ApiExamples/ExMarkdownSaveOptions.cs index 960fdd41..d74471c5 100644 --- a/Examples/ApiExamples/ApiExamples/ExMarkdownSaveOptions.cs +++ b/Examples/ApiExamples/ApiExamples/ExMarkdownSaveOptions.cs @@ -1,4 +1,5 @@ // Copyright (c) 2001-2024 Aspose Pty Ltd. All Rights Reserved. +using System; using System.Drawing; using System.IO; using System.Linq; @@ -271,10 +272,11 @@ public void ExportTableAsHtml() saveOptions.ExportAsHtml = MarkdownExportAsHtml.Tables; doc.Save(ArtifactsDir + "MarkdownSaveOptions.ExportTableAsHtml.md", saveOptions); - //ExEnd:ExportTableAsHtml - + //ExEnd:ExportTableAsHtml + + string newLine = Environment.NewLine; string outDocContents = File.ReadAllText(ArtifactsDir + "MarkdownSaveOptions.ExportTableAsHtml.md"); - Assert.AreEqual("Sample table:\r\n" + + Assert.AreEqual($"Sample table:{newLine}
" + "
" + "

Cell1

" + "
" + diff --git a/Examples/ApiExamples/ApiExamples/ExStyles.cs b/Examples/ApiExamples/ApiExamples/ExStyles.cs index 76920b91..a64fb67f 100644 --- a/Examples/ApiExamples/ApiExamples/ExStyles.cs +++ b/Examples/ApiExamples/ApiExamples/ExStyles.cs @@ -341,16 +341,16 @@ public void LatentStyles() doc.Save(ArtifactsDir + "Styles.LatentStyles.docx"); TestUtil.DocPackageFileContainsString( - @"", + "", ArtifactsDir + "Styles.LatentStyles.docx", "styles.xml"); TestUtil.DocPackageFileContainsString( - @"", + "", ArtifactsDir + "Styles.LatentStyles.docx", "styles.xml"); TestUtil.DocPackageFileContainsString( - @"", + "", ArtifactsDir + "Styles.LatentStyles.docx", "styles.xml"); TestUtil.DocPackageFileContainsString( - @"", + "", ArtifactsDir + "Styles.LatentStyles.docx", "styles.xml"); } diff --git a/Examples/ApiExamples/ApiExamples/ExTxtSaveOptions.cs b/Examples/ApiExamples/ApiExamples/ExTxtSaveOptions.cs index 24b84a1d..3c3b26b0 100644 --- a/Examples/ApiExamples/ApiExamples/ExTxtSaveOptions.cs +++ b/Examples/ApiExamples/ApiExamples/ExTxtSaveOptions.cs @@ -5,6 +5,7 @@ // "as is", without warranty of any kind, either expressed or implied. ////////////////////////////////////////////////////////////////////////// +using System; using System.IO; using Aspose.Words; using Aspose.Words.Saving; @@ -205,10 +206,11 @@ public void TxtListIndentation() doc.Save(ArtifactsDir + "TxtSaveOptions.TxtListIndentation.txt", txtSaveOptions); string docText = File.ReadAllText(ArtifactsDir + "TxtSaveOptions.TxtListIndentation.txt"); + string newLine= Environment.NewLine; - Assert.AreEqual("1. Item 1\r\n" + - " a. Item 2\r\n" + - " i. Item 3\r\n", docText); + Assert.AreEqual($"1. Item 1{newLine}" + + $" a. Item 2{newLine}" + + $" i. Item 3{newLine}", docText); //ExEnd }