diff --git a/Examples/ApiExamples/ApiExamples/ExBookmarks.cs b/Examples/ApiExamples/ApiExamples/ExBookmarks.cs index 367d5a80..7cf9e432 100644 --- a/Examples/ApiExamples/ApiExamples/ExBookmarks.cs +++ b/Examples/ApiExamples/ApiExamples/ExBookmarks.cs @@ -251,7 +251,7 @@ public void Remove() bookmarks.Clear(); // The text that was inside the bookmarks is still present in the document. - Assert.That(bookmarks, Is.Empty); + Assert.AreEqual(0, bookmarks.Count); Assert.AreEqual("Text inside MyBookmark_1.\r" + "Text inside MyBookmark_2.\r" + "Text inside MyBookmark_3.\r" + diff --git a/Examples/ApiExamples/ApiExamples/ExDigitalSignatureUtil.cs b/Examples/ApiExamples/ApiExamples/ExDigitalSignatureUtil.cs index ebf01c04..3a522abc 100644 --- a/Examples/ApiExamples/ApiExamples/ExDigitalSignatureUtil.cs +++ b/Examples/ApiExamples/ApiExamples/ExDigitalSignatureUtil.cs @@ -67,8 +67,8 @@ public void Remove() } // Verify that both our output documents have no digital signatures. - Assert.That(DigitalSignatureUtil.LoadSignatures(ArtifactsDir + "DigitalSignatureUtil.LoadAndRemove.FromString.docx"), Is.Empty); - Assert.That(DigitalSignatureUtil.LoadSignatures(ArtifactsDir + "DigitalSignatureUtil.LoadAndRemove.FromStream.docx"), Is.Empty); + Assert.AreEqual(0, DigitalSignatureUtil.LoadSignatures(ArtifactsDir + "DigitalSignatureUtil.LoadAndRemove.FromString.docx").Count); + Assert.AreEqual(0, DigitalSignatureUtil.LoadSignatures(ArtifactsDir + "DigitalSignatureUtil.LoadAndRemove.FromStream.docx").Count); //ExEnd } @@ -78,7 +78,7 @@ public void RemoveSignatures() DigitalSignatureUtil.RemoveAllSignatures(MyDir + "Digitally signed.odt", ArtifactsDir + "DigitalSignatureUtil.RemoveSignatures.odt"); - Assert.That(DigitalSignatureUtil.LoadSignatures(ArtifactsDir + "DigitalSignatureUtil.RemoveSignatures.odt"), Is.Empty); + Assert.AreEqual(0, DigitalSignatureUtil.LoadSignatures(ArtifactsDir + "DigitalSignatureUtil.RemoveSignatures.odt").Count); } [Test] @@ -196,9 +196,9 @@ public void IncorrectDecryptionPassword() DecryptionPassword = "docPassword1" }; - Assert.That( + Assert.Throws( () => DigitalSignatureUtil.Sign(doc.OriginalFileName, outputFileName, certificateHolder, signOptions), - Throws.TypeOf(), "The document password is incorrect."); + "The document password is incorrect."); } [Test] @@ -211,8 +211,8 @@ public void NoArgumentsForSing() DecryptionPassword = string.Empty }; - Assert.That(() => DigitalSignatureUtil.Sign(string.Empty, string.Empty, null, signOptions), - Throws.TypeOf()); + Assert.Throws( + () => DigitalSignatureUtil.Sign(string.Empty, string.Empty, null, signOptions)); } [Test] @@ -228,8 +228,8 @@ public void NoCertificateForSign() DecryptionPassword = "docPassword" }; - Assert.That(() => DigitalSignatureUtil.Sign(doc.OriginalFileName, outputFileName, null, signOptions), - Throws.TypeOf()); + Assert.Throws( + () => DigitalSignatureUtil.Sign(doc.OriginalFileName, outputFileName, null, signOptions)); } } } \ No newline at end of file diff --git a/Examples/ApiExamples/ApiExamples/ExDocSaveOptions.cs b/Examples/ApiExamples/ApiExamples/ExDocSaveOptions.cs index b41ee622..413a26d8 100644 --- a/Examples/ApiExamples/ApiExamples/ExDocSaveOptions.cs +++ b/Examples/ApiExamples/ApiExamples/ExDocSaveOptions.cs @@ -74,7 +74,7 @@ public void TempFolder() doc.Save(ArtifactsDir + "DocSaveOptions.TempFolder.doc", options); // The folder will persist with no residual contents from the load operation. - Assert.That(Directory.GetFiles(options.TempFolder), Is.Empty); + Assert.AreEqual(0, Directory.GetFiles(options.TempFolder).Length); //ExEnd } @@ -175,9 +175,9 @@ public void AlwaysCompressMetafiles(bool compressAllMetafiles) var testedFileLength = new FileInfo(ArtifactsDir + "DocSaveOptions.AlwaysCompressMetafiles.docx").Length; if (compressAllMetafiles) - Assert.That(testedFileLength, Is.LessThan(14000)); + Assert.IsTrue(testedFileLength < 14000); else - Assert.That(testedFileLength, Is.LessThan(22000)); + Assert.IsTrue(testedFileLength < 22000); } } } \ No newline at end of file diff --git a/Examples/ApiExamples/ApiExamples/ExDocument.cs b/Examples/ApiExamples/ApiExamples/ExDocument.cs index 317076c6..a497fedc 100644 --- a/Examples/ApiExamples/ApiExamples/ExDocument.cs +++ b/Examples/ApiExamples/ApiExamples/ExDocument.cs @@ -783,8 +783,7 @@ public void AppendDocumentFromAutomation() { Document srcDoc = new Document(); - Assert.That(() => srcDoc == new Document("C:\\DetailsList.doc"), - Throws.TypeOf()); + Assert.Throws(() => new Document("C:\\DetailsList.doc")); // Append the source document at the end of the destination document. doc.AppendDocument(srcDoc, ImportFormatMode.UseDestinationStyles); @@ -795,8 +794,7 @@ public void AppendDocumentFromAutomation() // Unlink all headers/footers in this section from the previous section headers/footers // if this is the second document or above being appended. if (i > 1) - Assert.That(() => doc.Sections[i].HeadersFooters.LinkToPrevious(false), - Throws.TypeOf()); + Assert.Throws(() => doc.Sections[i].HeadersFooters.LinkToPrevious(false)); } } @@ -1442,8 +1440,7 @@ public void CompareDocumentWithRevisions() docWithRevision.StartTrackRevisions("John Doe"); builder.Writeln("This is a revision."); - Assert.That(() => docWithRevision.Compare(doc1, "John Doe", DateTime.Now), - Throws.TypeOf()); + Assert.Throws(() => docWithRevision.Compare(doc1, "John Doe", DateTime.Now)); } [Test] @@ -1592,7 +1589,7 @@ public void TrackRevisions() Assert.AreEqual(1, doc.Revisions.Count); Assert.True(doc.FirstSection.Body.Paragraphs[0].Runs[1].IsInsertRevision); Assert.AreEqual("John Doe", doc.Revisions[0].Author); - Assert.That(doc.Revisions[0].DateTime, Is.EqualTo(DateTime.Now).Within(10).Milliseconds); + Assert.IsTrue((DateTime.Now - doc.Revisions[0].DateTime).Milliseconds <= 10); // Stop tracking revisions to not count any future edits as revisions. doc.StopTrackRevisions(); @@ -1759,9 +1756,8 @@ public void HyphenationOptionsDefaultValues() public void HyphenationZoneException() { Document doc = new Document(); - - Assert.That(() => doc.HyphenationOptions.HyphenationZone = 0, - Throws.TypeOf()); + + Assert.Throws(() => doc.HyphenationOptions.HyphenationZone = 0); } [Test] diff --git a/Examples/ApiExamples/ApiExamples/ExDocumentBuilder.cs b/Examples/ApiExamples/ApiExamples/ExDocumentBuilder.cs index fa7c4b09..a663df36 100644 --- a/Examples/ApiExamples/ApiExamples/ExDocumentBuilder.cs +++ b/Examples/ApiExamples/ApiExamples/ExDocumentBuilder.cs @@ -204,13 +204,13 @@ public void HorizontalRuleFormatExceptions() HorizontalRuleFormat horizontalRuleFormat = shape.HorizontalRuleFormat; horizontalRuleFormat.WidthPercent = 1; horizontalRuleFormat.WidthPercent = 100; - Assert.That(() => horizontalRuleFormat.WidthPercent = 0, Throws.TypeOf()); - Assert.That(() => horizontalRuleFormat.WidthPercent = 101, Throws.TypeOf()); + Assert.Throws(() => horizontalRuleFormat.WidthPercent = 0); + Assert.Throws(() => horizontalRuleFormat.WidthPercent = 101); horizontalRuleFormat.Height = 0; horizontalRuleFormat.Height = 1584; - Assert.That(() => horizontalRuleFormat.Height = -1, Throws.TypeOf()); - Assert.That(() => horizontalRuleFormat.Height = 1585, Throws.TypeOf()); + Assert.Throws(() => horizontalRuleFormat.Height = -1); + Assert.Throws(() => horizontalRuleFormat.Height = 1585); } [Test] @@ -2480,8 +2480,7 @@ public void InsertOleObjectException() Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); - Assert.That(() => builder.InsertOleObject("", "checkbox", false, true, null), - Throws.TypeOf()); + Assert.Throws(() => builder.InsertOleObject("", "checkbox", false, true, null)); } [Test] @@ -2559,7 +2558,7 @@ public void InsertField() Assert.AreEqual("DATE \\@ \"dddd, MMMM dd, yyyy\"", field.GetFieldCode()); // This overload of the InsertField method automatically updates inserted fields. - Assert.That(DateTime.Parse(field.Result), Is.EqualTo(DateTime.Today).Within(1).Days); + Assert.True((DateTime.Today - DateTime.Parse(field.Result)).Days <= 1); //ExEnd } diff --git a/Examples/ApiExamples/ApiExamples/ExEditableRange.cs b/Examples/ApiExamples/ApiExamples/ExEditableRange.cs index d32bd7aa..21e1a969 100644 --- a/Examples/ApiExamples/ApiExamples/ExEditableRange.cs +++ b/Examples/ApiExamples/ApiExamples/ExEditableRange.cs @@ -270,7 +270,7 @@ public void IncorrectStructureException() DocumentBuilder builder = new DocumentBuilder(doc); // Assert that isn't valid structure for the current document. - Assert.That(() => builder.EndEditableRange(), Throws.TypeOf()); + Assert.Throws(() => builder.EndEditableRange()); builder.StartEditableRange(); } diff --git a/Examples/ApiExamples/ApiExamples/ExField.cs b/Examples/ApiExamples/ApiExamples/ExField.cs index c675658d..1cc63805 100644 --- a/Examples/ApiExamples/ApiExamples/ExField.cs +++ b/Examples/ApiExamples/ApiExamples/ExField.cs @@ -406,9 +406,9 @@ public void InsertFieldWithFieldBuilderException() FieldBuilder fieldBuilder = new FieldBuilder(FieldType.FieldIncludeText); - Assert.That( + Assert.Throws( () => fieldBuilder.AddArgument(argumentBuilder).AddArgument("=").AddArgument("BestField") - .AddArgument(10).AddArgument(20.0).BuildAndInsert(run), Throws.TypeOf()); + .AddArgument(10).AddArgument(20.0).BuildAndInsert(run)); } [Test] @@ -1533,7 +1533,7 @@ public void FieldAutoText() doc = new Document(ArtifactsDir + "Field.AUTOTEXT.GLOSSARY.dotx"); - Assert.That(doc.FieldOptions.BuiltInTemplatesPaths, Is.Empty); + Assert.AreEqual(0, doc.FieldOptions.BuiltInTemplatesPaths.Length); fieldAutoText = (FieldAutoText)doc.Range.Fields[0]; @@ -1678,7 +1678,7 @@ public void FieldGreetingLine() doc.MailMerge.Execute(table); - Assert.That(doc.Range.Fields, Is.Empty); + Assert.AreEqual(0, doc.Range.Fields.Count); Assert.AreEqual("Dear Mr. Doe,\r\r\tThis is your custom greeting, created programmatically using Aspose Words!\r" + "\fDear Mrs. Cardholder,\r\r\tThis is your custom greeting, created programmatically using Aspose Words!\r" + "\fDear Sir or Madam,\r\r\tThis is your custom greeting, created programmatically using Aspose Words!", @@ -1844,7 +1844,7 @@ public void MergeField() Assert.AreEqual("Dear Mr. Doe:\u000cDear Mrs. Cardholder:", doc.GetText().Trim()); //ExEnd - Assert.That(doc.Range.Fields, Is.Empty); + Assert.AreEqual(0, doc.Range.Fields.Count); } //ExStart @@ -5105,7 +5105,7 @@ public void FieldDocVariable() // 2 - Display a custom document variable: // Define a custom variable, then reference that variable with a DOCPROPERTY field. - Assert.That(doc.Variables, Is.Empty); + Assert.AreEqual(0, doc.Variables.Count); doc.Variables.Add("My variable", "My variable's value"); FieldDocVariable fieldDocVariable = (FieldDocVariable)builder.InsertField(FieldType.FieldDocVariable, true); diff --git a/Examples/ApiExamples/ApiExamples/ExFont.cs b/Examples/ApiExamples/ApiExamples/ExFont.cs index ce87e0e4..14a74aa4 100644 --- a/Examples/ApiExamples/ApiExamples/ExFont.cs +++ b/Examples/ApiExamples/ApiExamples/ExFont.cs @@ -161,9 +161,9 @@ public void FontInfoCollection(bool embedAllFonts) var testedFileLength = new FileInfo(ArtifactsDir + "Font.FontInfoCollection.docx").Length; if (embedAllFonts) - Assert.That(testedFileLength, Is.LessThan(28000)); + Assert.IsTrue(testedFileLength < 28000); else - Assert.That(testedFileLength, Is.LessThan(13000)); + Assert.IsTrue(testedFileLength < 13000); } [TestCase(true, false, false, Description = diff --git a/Examples/ApiExamples/ApiExamples/ExFontSettings.cs b/Examples/ApiExamples/ApiExamples/ExFontSettings.cs index 4fc275fe..c671d3f5 100644 --- a/Examples/ApiExamples/ApiExamples/ExFontSettings.cs +++ b/Examples/ApiExamples/ApiExamples/ExFontSettings.cs @@ -108,7 +108,7 @@ public void UpdatePageLayoutWarnings() // Even though the document was rendered previously, any save warnings are notified to the user during document save doc.Save(ArtifactsDir + "FontSettings.UpdatePageLayoutWarnings.pdf"); - Assert.That(callback.FontWarnings.Count, Is.GreaterThan(0)); + Assert.True(callback.FontWarnings.Count > 0); Assert.True(callback.FontWarnings[0].WarningType == WarningType.FontSubstitution); Assert.True(callback.FontWarnings[0].Description.Contains("has not been found")); @@ -273,7 +273,7 @@ public void EnableFontSubstitution() substitutionWarningHandler.FontWarnings.Clear(); - Assert.That(substitutionWarningHandler.FontWarnings, Is.Empty); + Assert.AreEqual(0, substitutionWarningHandler.FontWarnings.Count); } public class HandleDocumentSubstitutionWarnings : IWarningCallback diff --git a/Examples/ApiExamples/ApiExamples/ExHtmlFixedSaveOptions.cs b/Examples/ApiExamples/ApiExamples/ExHtmlFixedSaveOptions.cs index e15a7424..bc65c6a9 100644 --- a/Examples/ApiExamples/ApiExamples/ExHtmlFixedSaveOptions.cs +++ b/Examples/ApiExamples/ApiExamples/ExHtmlFixedSaveOptions.cs @@ -353,7 +353,7 @@ public void PageMargins() public void PageMarginsException() { HtmlFixedSaveOptions saveOptions = new HtmlFixedSaveOptions(); - Assert.That(() => saveOptions.PageMargins = -1, Throws.TypeOf()); + Assert.Throws(() => saveOptions.PageMargins = -1); } [TestCase(false)] diff --git a/Examples/ApiExamples/ApiExamples/ExHtmlSaveOptions.cs b/Examples/ApiExamples/ApiExamples/ExHtmlSaveOptions.cs index 31d3d184..39571742 100644 --- a/Examples/ApiExamples/ApiExamples/ExHtmlSaveOptions.cs +++ b/Examples/ApiExamples/ApiExamples/ExHtmlSaveOptions.cs @@ -94,35 +94,35 @@ public void ExportTextBoxAsSvgEpub(SaveFormat saveFormat, bool isTextBoxAsSvg) dirFiles = Directory.GetFiles(ArtifactsDir, "HtmlSaveOptions.ExportTextBoxAsSvgEpub.001.png", SearchOption.AllDirectories); - Assert.That(dirFiles, Is.Empty); + Assert.AreEqual(0, dirFiles.Length); return; case SaveFormat.Epub: dirFiles = Directory.GetFiles(ArtifactsDir, "HtmlSaveOptions.ExportTextBoxAsSvgEpub.001.png", SearchOption.AllDirectories); - Assert.That(dirFiles, Is.Empty); + Assert.AreEqual(0, dirFiles.Length); return; case SaveFormat.Mhtml: dirFiles = Directory.GetFiles(ArtifactsDir, "HtmlSaveOptions.ExportTextBoxAsSvgEpub.001.png", SearchOption.AllDirectories); - Assert.That(dirFiles, Is.Empty); + Assert.AreEqual(0, dirFiles.Length); return; case SaveFormat.Azw3: dirFiles = Directory.GetFiles(ArtifactsDir, "HtmlSaveOptions.ExportTextBoxAsSvgEpub.001.png", SearchOption.AllDirectories); - Assert.That(dirFiles, Is.Empty); + Assert.AreEqual(0, dirFiles.Length); return; case SaveFormat.Mobi: dirFiles = Directory.GetFiles(ArtifactsDir, "HtmlSaveOptions.ExportTextBoxAsSvgEpub.001.png", SearchOption.AllDirectories); - Assert.That(dirFiles, Is.Empty); + Assert.AreEqual(0, dirFiles.Length); return; } } @@ -1745,12 +1745,12 @@ public void ScaleImageToShapeSize(bool scaleImageToShapeSize) if (scaleImageToShapeSize) #if NET461_OR_GREATER || JAVA - Assert.That(testedImageLength, Is.LessThan(3000)); + Assert.IsTrue(testedImageLength < 3000); #elif NET5_0_OR_GREATER - Assert.That(testedImageLength, Is.LessThan(6000)); + Assert.IsTrue(testedImageLength < 6000); #endif else - Assert.That(testedImageLength, Is.LessThan(16000)); + Assert.IsTrue(testedImageLength < 16000); } diff --git a/Examples/ApiExamples/ApiExamples/ExImageSaveOptions.cs b/Examples/ApiExamples/ApiExamples/ExImageSaveOptions.cs index 434e7fc8..d3ed7618 100644 --- a/Examples/ApiExamples/ApiExamples/ExImageSaveOptions.cs +++ b/Examples/ApiExamples/ApiExamples/ExImageSaveOptions.cs @@ -287,26 +287,26 @@ public void ColorMode(ImageColorMode imageColorMode) switch (imageColorMode) { case ImageColorMode.None: - Assert.That(testedImageLength, Is.LessThan(175000)); + Assert.IsTrue(testedImageLength < 175000); break; case ImageColorMode.Grayscale: - Assert.That(testedImageLength, Is.LessThan(90000)); + Assert.IsTrue(testedImageLength < 90000); break; case ImageColorMode.BlackAndWhite: - Assert.That(testedImageLength, Is.LessThan(15000)); + Assert.IsTrue(testedImageLength < 15000); break; } #elif NET5_0_OR_GREATER switch (imageColorMode) { case ImageColorMode.None: - Assert.That(testedImageLength, Is.LessThan(132000)); + Assert.IsTrue(testedImageLength < 132000); break; case ImageColorMode.Grayscale: - Assert.That(testedImageLength, Is.LessThan(90000)); + Assert.IsTrue(testedImageLength < 90000); break; case ImageColorMode.BlackAndWhite: - Assert.That(testedImageLength, Is.LessThan(11000)); + Assert.IsTrue(testedImageLength < 11000); break; } #endif @@ -391,37 +391,37 @@ public void PixelFormat(ImagePixelFormat imagePixelFormat) switch (imagePixelFormat) { case ImagePixelFormat.Format1bppIndexed: - Assert.That(testedImageLength, Is.LessThan(2500)); - break; + Assert.IsTrue(testedImageLength < 2500); + break; case ImagePixelFormat.Format16BppRgb565: - Assert.That(testedImageLength, Is.LessThan(104000)); + Assert.IsTrue(testedImageLength < 104000); break; case ImagePixelFormat.Format16BppRgb555: - Assert.That(testedImageLength, Is.LessThan(88000)); + Assert.IsTrue(testedImageLength < 88000); break; case ImagePixelFormat.Format24BppRgb: - Assert.That(testedImageLength, Is.LessThan(160000)); + Assert.IsTrue(testedImageLength < 160000); break; case ImagePixelFormat.Format32BppRgb: case ImagePixelFormat.Format32BppArgb: - Assert.That(testedImageLength, Is.LessThan(175000)); + Assert.IsTrue(testedImageLength < 175000); break; case ImagePixelFormat.Format48BppRgb: - Assert.That(testedImageLength, Is.LessThan(212000)); + Assert.IsTrue(testedImageLength < 212000); break; case ImagePixelFormat.Format64BppArgb: case ImagePixelFormat.Format64BppPArgb: - Assert.That(testedImageLength, Is.LessThan(239000)); + Assert.IsTrue(testedImageLength < 239000); break; } #elif NET5_0_OR_GREATER switch (imagePixelFormat) { case ImagePixelFormat.Format1bppIndexed: - Assert.That(testedImageLength, Is.LessThan(7500)); + Assert.IsTrue(testedImageLength < 7500); break; case ImagePixelFormat.Format24BppRgb: - Assert.That(testedImageLength, Is.LessThan(77000)); + Assert.IsTrue(testedImageLength < 77000); break; case ImagePixelFormat.Format16BppRgb565: case ImagePixelFormat.Format16BppRgb555: @@ -430,7 +430,7 @@ public void PixelFormat(ImagePixelFormat imagePixelFormat) case ImagePixelFormat.Format48BppRgb: case ImagePixelFormat.Format64BppArgb: case ImagePixelFormat.Format64BppPArgb: - Assert.That(testedImageLength, Is.LessThan(132000)); + Assert.IsTrue(testedImageLength < 132000); break; } #endif @@ -533,7 +533,7 @@ public void JpegQuality() // Set the "JpegQuality" property to "10" to use stronger compression when rendering the document. // This will reduce the file size of the document, but the image will display more prominent compression artifacts. imageOptions.JpegQuality = 10; - doc.Save(ArtifactsDir + "ImageSaveOptions.JpegQuality.HighCompression.jpg", imageOptions); + doc.Save(ArtifactsDir + "ImageSaveOptions.JpegQuality.HighCompression.jpg", imageOptions); // Set the "JpegQuality" property to "100" to use weaker compression when rending the document. // This will improve the quality of the image at the cost of an increased file size. @@ -541,8 +541,8 @@ public void JpegQuality() doc.Save(ArtifactsDir + "ImageSaveOptions.JpegQuality.HighQuality.jpg", imageOptions); //ExEnd - Assert.That(new FileInfo(ArtifactsDir + "ImageSaveOptions.JpegQuality.HighCompression.jpg").Length, Is.LessThan(18000)); - Assert.That(new FileInfo(ArtifactsDir + "ImageSaveOptions.JpegQuality.HighQuality.jpg").Length, Is.LessThan(75000)); + Assert.IsTrue(new FileInfo(ArtifactsDir + "ImageSaveOptions.JpegQuality.HighCompression.jpg").Length < 18000); + Assert.IsTrue(new FileInfo(ArtifactsDir + "ImageSaveOptions.JpegQuality.HighQuality.jpg").Length < 75000); } [TestCase(TiffCompression.None), Category("SkipMono")] @@ -580,27 +580,27 @@ public void TiffImageCompression(TiffCompression tiffCompression) switch (tiffCompression) { case TiffCompression.None: - Assert.That(testedImageLength, Is.LessThan(3450000)); + Assert.IsTrue(testedImageLength < 3450000); break; case TiffCompression.Rle: #if NET5_0_OR_GREATER - Assert.That(testedImageLength, Is.LessThan(7500)); + Assert.IsTrue(testedImageLength < 7500); #else - Assert.That(testedImageLength, Is.LessThan(687000)); + Assert.IsTrue(testedImageLength < 687000); #endif break; case TiffCompression.Lzw: - Assert.That(testedImageLength, Is.LessThan(250000)); + Assert.IsTrue(testedImageLength < 250000); break; case TiffCompression.Ccitt3: #if NET5_0_OR_GREATER - Assert.That(testedImageLength, Is.LessThan(6100)); + Assert.IsTrue(testedImageLength < 6100); #else - Assert.That(testedImageLength, Is.LessThan(8300)); + Assert.IsTrue(testedImageLength < 8300); #endif break; case TiffCompression.Ccitt4: - Assert.That(testedImageLength, Is.LessThan(1700)); + Assert.IsTrue(testedImageLength < 1700); break; } } diff --git a/Examples/ApiExamples/ApiExamples/ExInlineStory.cs b/Examples/ApiExamples/ApiExamples/ExInlineStory.cs index fdfd6beb..2c1009ee 100644 --- a/Examples/ApiExamples/ApiExamples/ExInlineStory.cs +++ b/Examples/ApiExamples/ApiExamples/ExInlineStory.cs @@ -542,7 +542,7 @@ public void InsertInlineStoryNodes() table.EnsureMinimum(); // We can place a table inside a footnote, which will make it appear at the referencing page's footer. - Assert.That(footnote.Tables, Is.Empty); + Assert.AreEqual(0, footnote.Tables.Count); footnote.AppendChild(table); Assert.AreEqual(1, footnote.Tables.Count); Assert.AreEqual(NodeType.Table, footnote.LastChild.NodeType); diff --git a/Examples/ApiExamples/ApiExamples/ExLists.cs b/Examples/ApiExamples/ApiExamples/ExLists.cs index 95ea833e..d0f0dac7 100644 --- a/Examples/ApiExamples/ApiExamples/ExLists.cs +++ b/Examples/ApiExamples/ApiExamples/ExLists.cs @@ -988,12 +988,10 @@ public void CustomNumberStyleFormat() Assert.AreEqual("005", ListLevel.GetEffectiveValue(5, NumberStyle.Custom, customNumberStyleFormat)); //ExEnd - Assert.That(() => ListLevel.GetEffectiveValue(5, NumberStyle.LowercaseRoman, customNumberStyleFormat), - Throws.TypeOf()); - Assert.That(() => ListLevel.GetEffectiveValue(5, NumberStyle.Custom, null), - Throws.TypeOf()); - Assert.That(() => ListLevel.GetEffectiveValue(5, NumberStyle.Custom, "...."), - Throws.TypeOf()); + Assert.Throws( + () => ListLevel.GetEffectiveValue(5, NumberStyle.LowercaseRoman, customNumberStyleFormat)); + Assert.Throws(() => ListLevel.GetEffectiveValue(5, NumberStyle.Custom, null)); + Assert.Throws(() => ListLevel.GetEffectiveValue(5, NumberStyle.Custom, "....")); } [Test] diff --git a/Examples/ApiExamples/ApiExamples/ExLoadOptions.cs b/Examples/ApiExamples/ApiExamples/ExLoadOptions.cs index 8e11b44f..24775a7a 100644 --- a/Examples/ApiExamples/ApiExamples/ExLoadOptions.cs +++ b/Examples/ApiExamples/ApiExamples/ExLoadOptions.cs @@ -232,7 +232,7 @@ public void TempFolder() Document doc = new Document(MyDir + "Document.docx", options); // The folder will persist with no residual contents from the load operation. - Assert.That(Directory.GetFiles(options.TempFolder), Is.Empty); + Assert.AreEqual(0, Directory.GetFiles(options.TempFolder).Length); //ExEnd } diff --git a/Examples/ApiExamples/ApiExamples/ExMailMerge.cs b/Examples/ApiExamples/ApiExamples/ExMailMerge.cs index c551b6a3..b9f2246c 100644 --- a/Examples/ApiExamples/ApiExamples/ExMailMerge.cs +++ b/Examples/ApiExamples/ApiExamples/ExMailMerge.cs @@ -51,11 +51,11 @@ public void ExecuteArray() new object[] { "James Bond", "MI5 Headquarters", "Milbank", "London" }); // Send the document to the client browser. - Assert.That(() => doc.Save(response, "Artifacts/MailMerge.ExecuteArray.docx", ContentDisposition.Inline, null), - Throws.TypeOf()); //Thrown because HttpResponse is null in the test. + //Thrown because HttpResponse is null in the test. + Assert.Throws(() => doc.Save(response, "Artifacts/MailMerge.ExecuteArray.docx", ContentDisposition.Inline, null)); // We will need to close this response manually to ensure that we do not add any superfluous content to the document after saving. - Assert.That(() => response.End(), Throws.TypeOf()); + Assert.Throws(() => response.End()); //ExEnd doc = DocumentHelper.SaveOpen(doc); @@ -1562,7 +1562,7 @@ public void OdsoEmail() //ExEnd doc = new Document(ArtifactsDir + "MailMerge.OdsoEmail.docx"); - Assert.That(doc.MailMergeSettings.ConnectString, Is.Empty); + Assert.AreEqual(string.Empty, doc.MailMergeSettings.ConnectString); } private void TestOdsoEmail(Document doc) diff --git a/Examples/ApiExamples/ApiExamples/ExMarkdownLoadOptions.cs b/Examples/ApiExamples/ApiExamples/ExMarkdownLoadOptions.cs index 97acae7a..4b9ef254 100644 --- a/Examples/ApiExamples/ApiExamples/ExMarkdownLoadOptions.cs +++ b/Examples/ApiExamples/ApiExamples/ExMarkdownLoadOptions.cs @@ -1,13 +1,14 @@ using System; using System.IO; using System.Text; -using ApiExamples; +using Aspose.Words; using Aspose.Words.Loading; using NUnit.Framework; -namespace Aspose.Words.ApiExamples +namespace ApiExamples { - class ExMarkdownLoadOptions : ApiExampleBase + [TestFixture] + public class ExMarkdownLoadOptions : ApiExampleBase { [Test] public void PreserveEmptyLines() diff --git a/Examples/ApiExamples/ApiExamples/ExOoxmlSaveOptions.cs b/Examples/ApiExamples/ApiExamples/ExOoxmlSaveOptions.cs index f12e4c38..1091361d 100644 --- a/Examples/ApiExamples/ApiExamples/ExOoxmlSaveOptions.cs +++ b/Examples/ApiExamples/ApiExamples/ExOoxmlSaveOptions.cs @@ -157,7 +157,7 @@ public void LastSavedTime(bool updateLastSavedTimeProperty) DateTime lastSavedTimeNew = doc.BuiltInDocumentProperties.LastSavedTime; if (updateLastSavedTimeProperty) - Assert.That(DateTime.Now, Is.EqualTo(lastSavedTimeNew).Within(1).Days); + Assert.IsTrue((DateTime.Now - lastSavedTimeNew).Days < 1); else Assert.AreEqual(new DateTime(2021, 5, 11, 6, 32, 0), lastSavedTimeNew); @@ -231,16 +231,16 @@ public void DocumentCompression(CompressionLevel compressionLevel) switch (compressionLevel) { case CompressionLevel.Maximum: - Assert.That(testedFileLength, Is.LessThan(1269000)); + Assert.IsTrue(testedFileLength < 1269000); break; case CompressionLevel.Normal: - Assert.That(testedFileLength, Is.LessThan(1271000)); + Assert.IsTrue(testedFileLength < 1271000); break; case CompressionLevel.Fast: - Assert.That(testedFileLength, Is.LessThan(1280000)); + Assert.IsTrue(testedFileLength < 1280000); break; case CompressionLevel.SuperFast: - Assert.That(testedFileLength, Is.LessThan(1276000)); + Assert.IsTrue(testedFileLength < 1276000); break; } } @@ -285,7 +285,7 @@ public void CheckFileSignatures() using (FileStream outputFileStream = File.Open(ArtifactsDir + "OoxmlSaveOptions.CheckFileSignatures.docx", FileMode.Open)) { long fileSize = outputFileStream.Length; - Assert.That(prevFileSize < fileSize); + Assert.IsTrue(prevFileSize < fileSize); TestUtil.CopyStream(outputFileStream, stream); Assert.AreEqual(fileSignatures[i], TestUtil.DumpArray(stream.ToArray(), 0, 10)); diff --git a/Examples/ApiExamples/ApiExamples/ExParagraph.cs b/Examples/ApiExamples/ApiExamples/ExParagraph.cs index ce91635d..c981ffb8 100644 --- a/Examples/ApiExamples/ApiExamples/ExParagraph.cs +++ b/Examples/ApiExamples/ApiExamples/ExParagraph.cs @@ -520,7 +520,7 @@ public void IsRevision() doc.AcceptAllRevisions(); Assert.AreEqual(3, paragraphs.Count); - Assert.That(para, Is.Empty); + Assert.AreEqual(0, para.Count); Assert.AreEqual( "Paragraph 1. \r" + "Paragraph 2. \r" + diff --git a/Examples/ApiExamples/ApiExamples/ExPdfSaveOptions.cs b/Examples/ApiExamples/ApiExamples/ExPdfSaveOptions.cs index 7e3489b7..03a2682f 100644 --- a/Examples/ApiExamples/ApiExamples/ExPdfSaveOptions.cs +++ b/Examples/ApiExamples/ApiExamples/ExPdfSaveOptions.cs @@ -581,11 +581,11 @@ public void TextCompression(PdfTextCompression pdfTextCompression) switch (pdfTextCompression) { case PdfTextCompression.None: - Assert.That(testedFileLength, Is.LessThan(69000)); + Assert.IsTrue(testedFileLength < 69000); TestUtil.FileContainsString("<>stream", filePath); break; case PdfTextCompression.Flate: - Assert.That(testedFileLength, Is.LessThan(27000)); + Assert.IsTrue(testedFileLength < 27000); TestUtil.FileContainsString("<>stream", filePath); break; } @@ -649,11 +649,11 @@ public void UsePdfDocumentForImageCompression(PdfImageCompression pdfImageCompre switch (pdfImageCompression) { case PdfImageCompression.Auto: - Assert.That(testedFileLength, Is.LessThan(54000)); + Assert.IsTrue(testedFileLength < 54000); TestUtil.VerifyImage(400, 400, imagePath); break; case PdfImageCompression.Jpeg: - Assert.That(testedFileLength, Is.LessThan(40000)); + Assert.IsTrue(testedFileLength < 40000); TestUtil.VerifyImage(400, 400, imagePath); break; } @@ -705,10 +705,10 @@ public void UsePdfDocumentForImageColorSpaceExportMode(PdfImageColorSpaceExportM switch (pdfImageColorSpaceExportMode) { case PdfImageColorSpaceExportMode.Auto: - Assert.That(testedImageLength, Is.LessThan(20500)); + Assert.IsTrue(testedImageLength < 20500); break; case PdfImageColorSpaceExportMode.SimpleCmyk: - Assert.That(testedImageLength, Is.LessThan(140000)); + Assert.IsTrue(testedImageLength < 140000); break; } @@ -722,10 +722,10 @@ public void UsePdfDocumentForImageColorSpaceExportMode(PdfImageColorSpaceExportM switch (pdfImageColorSpaceExportMode) { case PdfImageColorSpaceExportMode.Auto: - Assert.That(testedImageLength, Is.LessThan(20500)); + Assert.IsTrue(testedImageLength < 20500); break; case PdfImageColorSpaceExportMode.SimpleCmyk: - Assert.That(testedImageLength, Is.LessThan(21500)); + Assert.IsTrue(testedImageLength < 21500); break; } @@ -777,7 +777,7 @@ public void UsePdfDocumentForDownsampleOptions() Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(ArtifactsDir + "PdfSaveOptions.DownsampleOptions.Default.pdf"); XImage pdfDocImage = pdfDocument.Pages[1].Resources.Images[1]; - Assert.That(pdfDocImage.ToStream().Length, Is.LessThan(400000)); + Assert.IsTrue(pdfDocImage.ToStream().Length < 400000); Assert.AreEqual(ColorType.Rgb, pdfDocImage.GetColorType()); } @@ -816,11 +816,11 @@ public void UsePdfDocumentForColorRendering(ColorMode colorMode) switch (colorMode) { case ColorMode.Normal: - Assert.That(testedImageLength, Is.LessThan(400000)); + Assert.IsTrue(testedImageLength < 400000); Assert.AreEqual(ColorType.Rgb, pdfDocImage.GetColorType()); break; case ColorMode.Grayscale: - Assert.That(testedImageLength, Is.LessThan(1450000)); + Assert.IsTrue(testedImageLength < 1450000); Assert.AreEqual(ColorType.Grayscale, pdfDocImage.GetColorType()); break; } @@ -1133,8 +1133,8 @@ public void UnsupportedImageFormatWarning() doc.Save(ArtifactsDir + "PdfSaveOption.UnsupportedImageFormatWarning.pdf", SaveFormat.Pdf); - Assert.That(saveWarningCallback.SaveWarnings[0].Description, - Is.EqualTo("Image can not be processed. Possibly unsupported image format.")); + Assert.AreEqual("Image can not be processed. Possibly unsupported image format.", + saveWarningCallback.SaveWarnings[0].Description); } public class SaveWarningCallback : IWarningCallback @@ -1238,9 +1238,9 @@ public void EmbedFullFonts(bool embedFullFonts) var testedFileLength = new FileInfo(ArtifactsDir + "PdfSaveOptions.EmbedFullFonts.pdf").Length; if (embedFullFonts) - Assert.That(testedFileLength, Is.LessThan(571000)); + Assert.IsTrue(testedFileLength < 571000); else - Assert.That(testedFileLength, Is.LessThan(24000)); + Assert.IsTrue(testedFileLength < 24000); } [TestCase(false)] @@ -1294,16 +1294,15 @@ public void EmbedWindowsFonts(PdfFontEmbeddingMode pdfFontEmbeddingMode) switch (pdfFontEmbeddingMode) { case PdfFontEmbeddingMode.EmbedAll: - Assert.That(testedFileLength, Is.LessThan(1040000)); + Assert.IsTrue(testedFileLength < 1040000); break; case PdfFontEmbeddingMode.EmbedNonstandard: - Assert.That(testedFileLength, Is.LessThan(492000)); + Assert.IsTrue(testedFileLength < 492000); break; case PdfFontEmbeddingMode.EmbedNone: - Assert.That(testedFileLength, Is.LessThan(4300)); + Assert.IsTrue(testedFileLength < 4300); break; } - } [TestCase(PdfFontEmbeddingMode.EmbedAll)] @@ -1353,9 +1352,9 @@ public void EmbedCoreFonts(bool useCoreFonts) var testedFileLength = new FileInfo(ArtifactsDir + "PdfSaveOptions.EmbedCoreFonts.pdf").Length; if (useCoreFonts) - Assert.That(testedFileLength, Is.LessThan(2000)); + Assert.IsTrue(testedFileLength < 2000); else - Assert.That(testedFileLength, Is.LessThan(33500)); + Assert.IsTrue(testedFileLength < 33500); } [TestCase(false)] @@ -1424,14 +1423,14 @@ public void UsePdfDocumentForAdditionalTextPositioning(bool applyAdditionalTextP var testedFileLength = new FileInfo(ArtifactsDir + "PdfSaveOptions.AdditionalTextPositioning.pdf").Length; if (applyAdditionalTextPositioning) { - Assert.That(testedFileLength, Is.LessThan(102000)); + Assert.IsTrue(testedFileLength < 102000); Assert.AreEqual( "[0 (S) 0 (a) 0 (m) 0 (s) 0 (t) 0 (a) -1 (g) 1 (,) 0 ( ) 0 (1) 0 (0) 0 (.) 0 ( ) 0 (N) 0 (o) 0 (v) 0 (e) 0 (m) 0 (b) 0 (e) 0 (r) -1 ( ) 1 (2) -1 (0) 0 (1) 0 (8)] TJ", tjOperator.ToString()); } else { - Assert.That(testedFileLength, Is.LessThan(99500)); + Assert.IsTrue(testedFileLength < 99500); Assert.AreEqual("[(Samsta) -1 (g) 1 (, 10. November) -1 ( ) 1 (2) -1 (018)] TJ", tjOperator.ToString()); } } @@ -2032,7 +2031,7 @@ public void PreblendImages(bool preblendImages) } else { - Assert.That(stream.Length, Is.LessThan(19500)); + Assert.IsTrue(stream.Length < 19500); } } } diff --git a/Examples/ApiExamples/ApiExamples/ExReportingEngine.cs b/Examples/ApiExamples/ApiExamples/ExReportingEngine.cs index 6a9371cb..51a7960e 100644 --- a/Examples/ApiExamples/ApiExamples/ExReportingEngine.cs +++ b/Examples/ApiExamples/ApiExamples/ExReportingEngine.cs @@ -593,7 +593,7 @@ public void WithoutKnownType() builder.Writeln("<<[new DateTime()]:”dd.MM.yyyy”>>"); ReportingEngine engine = new ReportingEngine(); - Assert.That(() => engine.BuildReport(doc, ""), Throws.TypeOf()); + Assert.Throws(() => engine.BuildReport(doc, "")); } [Test] @@ -808,8 +808,8 @@ public void WithoutMissingMembers() new[] { "<<[missingObject.First().id]>>", "<><<[id]>><>" }); // Assert that build report failed without "ReportBuildOptions.AllowMissingMembers". - Assert.That(() => BuildReport(builder.Document, new DataSet(), "", ReportBuildOptions.None), - Throws.TypeOf()); + Assert.Throws( + () => BuildReport(builder.Document, new DataSet(), "", ReportBuildOptions.None)); } [Test] @@ -840,7 +840,7 @@ public void InlineErrorMessages(string templateText, string result) BuildReport(builder.Document, new DataSet(), "", ReportBuildOptions.InlineErrorMessages); - Assert.That(builder.Document.FirstSection.Body.Paragraphs[0].GetText().TrimEnd(), Is.EqualTo(result)); + Assert.AreEqual(result, builder.Document.FirstSection.Body.Paragraphs[0].GetText().TrimEnd()); } [Test] diff --git a/Examples/ApiExamples/ApiExamples/ExShape.cs b/Examples/ApiExamples/ApiExamples/ExShape.cs index ccd9035f..a2165782 100644 --- a/Examples/ApiExamples/ApiExamples/ExShape.cs +++ b/Examples/ApiExamples/ApiExamples/ExShape.cs @@ -1293,8 +1293,8 @@ public void OleControl() oleFormat.Save(ArtifactsDir + "OLE spreadsheet saved directly" + oleFormat.SuggestedExtension); //ExEnd - Assert.That(new FileInfo(ArtifactsDir + "OLE spreadsheet extracted via stream.xlsx").Length, Is.LessThan(8400)); - Assert.That(new FileInfo(ArtifactsDir + "OLE spreadsheet saved directly.xlsx").Length, Is.LessThan(8400)); + Assert.IsTrue(new FileInfo(ArtifactsDir + "OLE spreadsheet extracted via stream.xlsx").Length < 8400); + Assert.IsTrue(new FileInfo(ArtifactsDir + "OLE spreadsheet saved directly.xlsx").Length < 8400); } [Test] @@ -1414,7 +1414,7 @@ public void ObjectDidNotHaveSuggestedFileName() Document doc = new Document(MyDir + "ActiveX controls.docx"); Shape shape = (Shape)doc.GetChild(NodeType.Shape, 0, true); - Assert.That(shape.OleFormat.SuggestedFileName, Is.Empty); + Assert.AreEqual(string.Empty, shape.OleFormat.SuggestedFileName); } [Test] @@ -1453,8 +1453,7 @@ public void OfficeMathDisplayException() OfficeMath officeMath = (OfficeMath)doc.GetChild(NodeType.OfficeMath, 0, true); officeMath.DisplayType = OfficeMathDisplayType.Display; - Assert.That(() => officeMath.Justification = OfficeMathJustification.Inline, - Throws.TypeOf()); + Assert.Throws(() => officeMath.Justification = OfficeMathJustification.Inline); } [Test] diff --git a/Examples/ApiExamples/ApiExamples/ExStructuredDocumentTag.cs b/Examples/ApiExamples/ApiExamples/ExStructuredDocumentTag.cs index e5e7c6a6..0a9f27c2 100644 --- a/Examples/ApiExamples/ApiExamples/ExStructuredDocumentTag.cs +++ b/Examples/ApiExamples/ApiExamples/ExStructuredDocumentTag.cs @@ -132,7 +132,7 @@ public void CheckBox() .OfType().ToArray(); Assert.AreEqual(true, tags[0].Checked); - Assert.That(tags[0].XmlMapping.StoreItemId, Is.Empty); + Assert.AreEqual(string.Empty, tags[0].XmlMapping.StoreItemId); } [Test, Category("SkipMono")] @@ -204,7 +204,7 @@ public void PlainText() tag.Tag = "MyPlainTextSDT"; // Every structured document tag has a random unique ID. - Assert.That(tag.Id, Is.Positive); + Assert.IsTrue(tag.Id > 0); // Set the font for the text inside the structured document tag. tag.ContentsFont.Name = "Arial"; @@ -245,7 +245,7 @@ public void PlainText() Assert.AreEqual("My plain text", tag.Title); Assert.AreEqual(Color.Magenta.ToArgb(), tag.Color.ToArgb()); Assert.AreEqual("MyPlainTextSDT", tag.Tag); - Assert.That(tag.Id, Is.Positive); + Assert.IsTrue(tag.Id > 0); Assert.AreEqual("Arial", tag.ContentsFont.Name); Assert.AreEqual("Arial Black", tag.EndCharacterFont.Name); Assert.True(tag.Multiline); @@ -835,7 +835,7 @@ public void AccessToBuildingBlockPropertiesFromPlainTextSdt() (StructuredDocumentTag)doc.GetChild(NodeType.StructuredDocumentTag, 1, true); Assert.AreEqual(SdtType.PlainText, plainTextSdt.SdtType); - Assert.That(() => plainTextSdt.BuildingBlockGallery, Throws.TypeOf(), + Assert.Throws(() => { var _ =plainTextSdt.BuildingBlockGallery; }, "BuildingBlockType is only accessible for BuildingBlockGallery SDT type."); } diff --git a/Examples/ApiExamples/ApiExamples/ExVariableCollection.cs b/Examples/ApiExamples/ApiExamples/ExVariableCollection.cs index 2f4885da..7423d5a1 100644 --- a/Examples/ApiExamples/ApiExamples/ExVariableCollection.cs +++ b/Examples/ApiExamples/ApiExamples/ExVariableCollection.cs @@ -88,7 +88,7 @@ public void Primer() // 3 - Clear the whole collection at once: variables.Clear(); - Assert.That(variables, Is.Empty); + Assert.AreEqual(0, variables.Count); //ExEnd } } diff --git a/Examples/ApiExamples/ApiExamples/ExXpsSaveOptions.cs b/Examples/ApiExamples/ApiExamples/ExXpsSaveOptions.cs index 5268455e..c0b895d7 100644 --- a/Examples/ApiExamples/ApiExamples/ExXpsSaveOptions.cs +++ b/Examples/ApiExamples/ApiExamples/ExXpsSaveOptions.cs @@ -117,9 +117,9 @@ public void OptimizeOutput(bool optimizeOutput) var testedFileLength = new FileInfo(ArtifactsDir + "XpsSaveOptions.OptimizeOutput.xps").Length; if (optimizeOutput) - Assert.That(testedFileLength, Is.LessThan(43000)); + Assert.IsTrue(testedFileLength < 43000); else - Assert.That(testedFileLength, Is.LessThan(64000)); + Assert.IsTrue(testedFileLength < 64000); TestUtil.DocPackageFileContainsString( optimizeOutput