-
-
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
6 changed files
with
174 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,50 @@ | ||
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 BasicDocument : 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); | ||
} | ||
} |
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/BasicDocument.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/BasicDocument.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> | ||
<!-----------------------------------------------------------------------------------> |