-
-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
327 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
using System.Threading.Tasks; | ||
using DocumentFormat.OpenXml.Packaging; | ||
using DocumentFormat.OpenXml.Wordprocessing; | ||
using OfficeIMO.Word; | ||
using VerifyXunit; | ||
using Xunit; | ||
|
||
using Color = SixLabors.ImageSharp.Color; | ||
|
||
namespace OfficeIMO.VerifyTests.Word; | ||
|
||
public class BasicDocumentTests : VerifyTestBase { | ||
|
||
private static async Task DoTest(WordprocessingDocument document) { | ||
NormalizeWord(document); | ||
var result = ToVerifyResult(document); | ||
await Verifier.Verify(result, GetSettings()); | ||
} | ||
|
||
[Fact] | ||
public async Task BasicEmptyWord() { | ||
using var document = WordDocument.Create(); | ||
document.BuiltinDocumentProperties.Title = "This is my title"; | ||
document.BuiltinDocumentProperties.Creator = "Przemysław Kłys"; | ||
document.BuiltinDocumentProperties.Keywords = "word, docx, test"; | ||
document.Save(); | ||
|
||
await DoTest(document._wordprocessingDocument); | ||
} | ||
|
||
[Fact] | ||
public async Task BasicWord() { | ||
using var document = WordDocument.Create(); | ||
var paragraph = document.AddParagraph("Adding paragraph with some text"); | ||
paragraph.ParagraphAlignment = JustificationValues.Center; | ||
|
||
paragraph.Color = Color.Red; | ||
|
||
paragraph = document.AddParagraph("Adding another paragraph with some more text"); | ||
paragraph.Bold = true; | ||
paragraph = paragraph.AddText(" , but now we also decided to add more text to this paragraph using different style"); | ||
paragraph.Underline = UnderlineValues.DashLong; | ||
paragraph = paragraph.AddText(" , and we still continue adding more text to existing paragraph."); | ||
paragraph.Color = Color.CornflowerBlue; | ||
|
||
document.Save(); | ||
|
||
await DoTest(document._wordprocessingDocument); | ||
} | ||
|
||
[Fact] | ||
public async Task BasicWordWithBreaks() { | ||
using var document = WordDocument.Create(); | ||
_ = document.AddParagraph("Adding paragraph1 with some text and pressing ENTER"); | ||
|
||
var paragraph = document.AddParagraph("Adding paragraph2 with some text and pressing SHIFT+ENTER"); | ||
paragraph.AddBreak(); | ||
paragraph.AddText("Continue1"); | ||
paragraph.AddBreak(); | ||
paragraph.AddText("Continue2"); | ||
paragraph.AddText(" Continue3"); | ||
|
||
document.Breaks[0].Remove(); // removes break before continue1 | ||
|
||
_ = document.AddParagraph("Adding paragraph3 with some text and pressing ENTER"); | ||
_ = document.AddParagraph("Adding paragraph4 with some text and pressing SHIFT+ENTER"); | ||
|
||
document.Save(); | ||
|
||
await DoTest(document._wordprocessingDocument); | ||
} | ||
|
||
[Fact] | ||
public async Task BasicWordWithDefaultStyleChange() { | ||
using var document = WordDocument.Create(); | ||
document.Settings.FontSize = 30; | ||
document.Settings.FontFamily = "Calibri Light"; | ||
document.Settings.Language = "pl-PL"; | ||
document.Settings.Language = "pt-Br"; | ||
_ = document.AddParagraph("To jest po polsku"); | ||
|
||
var paragraph = document.AddParagraph("Adding paragraph1 with some text and pressing ENTER"); | ||
paragraph.FontSize = 15; | ||
paragraph.FontFamily = "Courier New"; | ||
|
||
document.Save(); | ||
|
||
await DoTest(document._wordprocessingDocument); | ||
} | ||
|
||
[Fact] | ||
public async Task BasicWordWithDefaultFontChange() { | ||
using var document = WordDocument.Create(); | ||
document.Settings.FontSize = 30; | ||
document.Settings.FontFamily = "Calibri Light"; | ||
document.Settings.FontFamilyHighAnsi = "Calibri Light"; | ||
document.Settings.Language = "pt-Br"; | ||
document.Settings.ZoomPreset = PresetZoomValues.BestFit; | ||
|
||
document.CompatibilitySettings.CompatibilityMode = CompatibilityMode.Word2013; | ||
document.CompatibilitySettings.CompatibilityMode = CompatibilityMode.None; | ||
|
||
const string title = "INSTRUMENTO PARTICULAR DE CONSTITUIÇÃO DE GARANTIA DE ALIENAÇÃO FIDUCIÁRIA DE IMÓVEL"; | ||
|
||
document.AddParagraph(title).SetBold().ParagraphAlignment = JustificationValues.Center; | ||
|
||
document.Save(); | ||
|
||
await DoTest(document._wordprocessingDocument); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
OfficeIMO.VerifyTests/Word/verified/BasicDocumentTests.BasicEmptyWord.verified.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/word/document.xml | ||
<!---------------------------------------------------------------------------------------------------------------------> | ||
<?xml version="1.0" encoding="utf-16"?> | ||
<w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"> | ||
<w:body> | ||
<w:sectPr /> | ||
</w:body> | ||
</w:document> | ||
<!---------------------------------------------------------------------------------------------------------------------> |
42 changes: 42 additions & 0 deletions
42
OfficeIMO.VerifyTests/Word/verified/BasicDocumentTests.BasicWord.verified.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/word/document.xml | ||
<!---------------------------------------------------------------------------------------------------------------------> | ||
<?xml version="1.0" encoding="utf-16"?> | ||
<w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"> | ||
<w:body> | ||
<w:p> | ||
<w:pPr> | ||
<w:jc w:val="center" /> | ||
</w:pPr> | ||
<w:r> | ||
<w:rPr> | ||
<w:color w:val="FF0000" /> | ||
</w:rPr> | ||
<w:t xml:space="preserve">Adding paragraph with some text</w:t> | ||
</w:r> | ||
</w:p> | ||
<w:p> | ||
<w:pPr /> | ||
<w:r> | ||
<w:rPr> | ||
<w:b /> | ||
<w:bCs /> | ||
</w:rPr> | ||
<w:t xml:space="preserve">Adding another paragraph with some more text</w:t> | ||
</w:r> | ||
<w:r> | ||
<w:rPr> | ||
<w:u w:val="dashLong" /> | ||
</w:rPr> | ||
<w:t xml:space="preserve"> , but now we also decided to add more text to this paragraph using different style</w:t> | ||
</w:r> | ||
<w:r> | ||
<w:rPr> | ||
<w:color w:val="6495ED" /> | ||
</w:rPr> | ||
<w:t xml:space="preserve"> , and we still continue adding more text to existing paragraph.</w:t> | ||
</w:r> | ||
</w:p> | ||
<w:sectPr /> | ||
</w:body> | ||
</w:document> | ||
<!---------------------------------------------------------------------------------------------------------------------> |
45 changes: 45 additions & 0 deletions
45
OfficeIMO.VerifyTests/Word/verified/BasicDocumentTests.BasicWordWithBreaks.verified.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/word/document.xml | ||
<!---------------------------------------------------------------------------------------------------------------------> | ||
<?xml version="1.0" encoding="utf-16"?> | ||
<w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"> | ||
<w:body> | ||
<w:p> | ||
<w:pPr /> | ||
<w:r> | ||
<w:t xml:space="preserve">Adding paragraph1 with some text and pressing ENTER</w:t> | ||
</w:r> | ||
</w:p> | ||
<w:p> | ||
<w:pPr /> | ||
<w:r> | ||
<w:t xml:space="preserve">Adding paragraph2 with some text and pressing SHIFT+ENTER</w:t> | ||
</w:r> | ||
<w:r> | ||
<w:t xml:space="preserve">Continue1</w:t> | ||
</w:r> | ||
<w:r> | ||
<w:br /> | ||
</w:r> | ||
<w:r> | ||
<w:t xml:space="preserve">Continue2</w:t> | ||
</w:r> | ||
<w:r> | ||
<w:t xml:space="preserve"> Continue3</w:t> | ||
</w:r> | ||
</w:p> | ||
<w:p> | ||
<w:pPr /> | ||
<w:r> | ||
<w:t xml:space="preserve">Adding paragraph3 with some text and pressing ENTER</w:t> | ||
</w:r> | ||
</w:p> | ||
<w:p> | ||
<w:pPr /> | ||
<w:r> | ||
<w:t xml:space="preserve">Adding paragraph4 with some text and pressing SHIFT+ENTER</w:t> | ||
</w:r> | ||
</w:p> | ||
<w:sectPr /> | ||
</w:body> | ||
</w:document> | ||
<!---------------------------------------------------------------------------------------------------------------------> |
21 changes: 21 additions & 0 deletions
21
....VerifyTests/Word/verified/BasicDocumentTests.BasicWordWithDefaultFontChange.verified.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/word/document.xml | ||
<!---------------------------------------------------------------------------------------------------------------------> | ||
<?xml version="1.0" encoding="utf-16"?> | ||
<w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"> | ||
<w:body> | ||
<w:p> | ||
<w:pPr> | ||
<w:jc w:val="center" /> | ||
</w:pPr> | ||
<w:r> | ||
<w:rPr> | ||
<w:b /> | ||
<w:bCs /> | ||
</w:rPr> | ||
<w:t xml:space="preserve">INSTRUMENTO PARTICULAR DE CONSTITUIÇÃO DE GARANTIA DE ALIENAÇÃO FIDUCIÁRIA DE IMÓVEL</w:t> | ||
</w:r> | ||
</w:p> | ||
<w:sectPr /> | ||
</w:body> | ||
</w:document> | ||
<!---------------------------------------------------------------------------------------------------------------------> |
Oops, something went wrong.