Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Bentley committed Apr 11, 2019
1 parent 8763b86 commit 37890f9
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 0 deletions.
20 changes: 20 additions & 0 deletions OpenXmlFactory.Tests/OpenXmlElementReconstructorTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
namespace OpenXmlFactory.Tests
{
using Shouldly;
using Xunit;

public class OpenXmlElementReconstructorTests
{
[Fact]
public void Reconstruct()
{
var constructor = new OpenXmlElementReconstructor();
var outerXml = "<w:p w:rsidRPr=\"00974A4B\" w:rsidR=\"00D3074F\" w:rsidP=\"00D3074F\" w:rsidRDefault=\"00974A4B\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\"><w:pPr><w:pStyle w:val=\"Title\" /><w:pBdr><w:top w:val=\"single\" w:color=\"C0504D\" w:sz=\"48\" w:space=\"0\" /><w:bottom w:val=\"single\" w:color=\"C0504D\" w:sz=\"48\" w:space=\"0\" /></w:pBdr><w:shd w:val=\"clear\" w:color=\"auto\" w:fill=\"C0504D\" /><w:rPr><w:rFonts w:ascii=\"Calibri\" w:hAnsi=\"Calibri\" /><w:b /><w:iCs w:val=\"0\" /><w:color w:val=\"FFFFFF\" /><w:sz w:val=\"36\" /><w:szCs w:val=\"36\" /><w:lang w:val=\"nl-NL\" /></w:rPr></w:pPr><w:proofErr w:type=\"spellStart\" /><w:r w:rsidRPr=\"00974A4B\"><w:rPr><w:rFonts w:ascii=\"Calibri\" w:hAnsi=\"Calibri\" /><w:b /><w:iCs w:val=\"0\" /><w:smallCaps /><w:color w:val=\"FFFFFF\" /><w:sz w:val=\"36\" /><w:szCs w:val=\"36\" /><w:lang w:val=\"nl-NL\" /></w:rPr><w:t>Projectspecifieke</w:t></w:r><w:proofErr w:type=\"spellEnd\" /><w:r w:rsidRPr=\"00974A4B\"><w:rPr><w:rFonts w:ascii=\"Calibri\" w:hAnsi=\"Calibri\" /><w:b /><w:iCs w:val=\"0\" /><w:smallCaps /><w:color w:val=\"FFFFFF\" /><w:sz w:val=\"36\" /><w:szCs w:val=\"36\" /><w:lang w:val=\"nl-NL\" /></w:rPr><w:t xml:space=\"preserve\"> Voorwaarden</w:t></w:r></w:p>";

var element = constructor.Reconstruct(outerXml);

element.GetType().ShouldBe(typeof(DocumentFormat.OpenXml.Wordprocessing.Paragraph));
element.LocalName.ShouldBe("p");
}
}
}
22 changes: 22 additions & 0 deletions OpenXmlFactory.Tests/OpenXmlFactory.Tests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.0.1" />
<PackageReference Include="Shouldly" Version="3.0.2" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\OpenXmlFactory\OpenXmlFactory.csproj" />
</ItemGroup>

</Project>
18 changes: 18 additions & 0 deletions OpenXmlFactory.Tests/OpenXmlTagExtractorTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
namespace OpenXmlFactory.Tests
{
using Shouldly;
using Xunit;

public class OpenXmlTagExtractorTests
{
[Fact]
public void GetTagNamesByType()
{
var extractor = new OpenXmlTagExtractor();
var tags = extractor.GetTagNamesByType();

tags.Count.ShouldBe(3440);
tags.ShouldContain(e => e.Name == "p" && e.Namespace == "w");
}
}
}
22 changes: 22 additions & 0 deletions OpenXmlFactory.Tests/TagConverterTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
namespace OpenXmlFactory.Tests
{
using Shouldly;
using Xunit;

public class TagConverterTests
{
[Fact]
public void ConvertToTag()
{
ITagConverter converter = new TagConverter();

var type = typeof(DocumentFormat.OpenXml.Wordprocessing.Paragraph);
var tag = converter.ConvertToTag(type);

tag.Name.ShouldBe("p");
tag.Namespace.ShouldBe("w");
tag.Type.ShouldBe(type);
tag.TypeName.ShouldBe("DocumentFormat.OpenXml.Wordprocessing.Paragraph");
}
}
}
14 changes: 14 additions & 0 deletions OpenXmlFactory.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenXmlFactory", "OpenXmlFa
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsoleApplication1", "ConsoleApplication1\ConsoleApplication1.csproj", "{20AB08CA-CE60-405E-904B-83A997E7E523}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenXmlFactory.Tests", "OpenXmlFactory.Tests\OpenXmlFactory.Tests.csproj", "{D9CF3FAE-69B4-475C-86B0-8CC8863BB25D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -39,6 +41,18 @@ Global
{20AB08CA-CE60-405E-904B-83A997E7E523}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{20AB08CA-CE60-405E-904B-83A997E7E523}.Release|x86.ActiveCfg = Release|Any CPU
{20AB08CA-CE60-405E-904B-83A997E7E523}.Release|x86.Build.0 = Release|Any CPU
{D9CF3FAE-69B4-475C-86B0-8CC8863BB25D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D9CF3FAE-69B4-475C-86B0-8CC8863BB25D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D9CF3FAE-69B4-475C-86B0-8CC8863BB25D}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{D9CF3FAE-69B4-475C-86B0-8CC8863BB25D}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{D9CF3FAE-69B4-475C-86B0-8CC8863BB25D}.Debug|x86.ActiveCfg = Debug|Any CPU
{D9CF3FAE-69B4-475C-86B0-8CC8863BB25D}.Debug|x86.Build.0 = Debug|Any CPU
{D9CF3FAE-69B4-475C-86B0-8CC8863BB25D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D9CF3FAE-69B4-475C-86B0-8CC8863BB25D}.Release|Any CPU.Build.0 = Release|Any CPU
{D9CF3FAE-69B4-475C-86B0-8CC8863BB25D}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{D9CF3FAE-69B4-475C-86B0-8CC8863BB25D}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{D9CF3FAE-69B4-475C-86B0-8CC8863BB25D}.Release|x86.ActiveCfg = Release|Any CPU
{D9CF3FAE-69B4-475C-86B0-8CC8863BB25D}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down

0 comments on commit 37890f9

Please sign in to comment.