-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
5157a05
commit dce2cd9
Showing
6 changed files
with
106 additions
and
0 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
31 changes: 31 additions & 0 deletions
31
tests/Doki.Output.Json.Tests/Doki.Output.Json.Tests.csproj
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,31 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
|
||
<IsPackable>false</IsPackable> | ||
<IsTestProject>true</IsTestProject> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.0"/> | ||
<PackageReference Include="xunit" Version="2.4.2"/> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
<PackageReference Include="coverlet.collector" Version="6.0.0"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\Doki.Output.Json\Doki.Output.Json.csproj" /> | ||
<ProjectReference Include="..\..\src\Doki\Doki.csproj" /> | ||
<ProjectReference Include="..\assemblies\Doki.TestAssembly.InheritanceChain.Abstractions\Doki.TestAssembly.InheritanceChain.Abstractions.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
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 @@ | ||
global using Xunit; |
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,57 @@ | ||
using System.Text.Json; | ||
using System.Xml.XPath; | ||
using Doki.TestAssembly.InheritanceChain.Abstractions; | ||
using Microsoft.Extensions.Logging.Abstractions; | ||
|
||
namespace Doki.Output.Json.Tests; | ||
|
||
public class JsonOutputTests | ||
{ | ||
[Fact] | ||
public async Task Test_Deserialization() | ||
{ | ||
var outputDirectory = new DirectoryInfo(Path.Combine(Path.GetTempPath(), "doki")); | ||
|
||
var emptyDocumentation = new XPathDocument(new StringReader(""" | ||
<?xml version="1.0"?> | ||
<doc> | ||
<assembly> | ||
<name>Doki.TestAssembly.InheritanceChain.Abstractions</name> | ||
</assembly> | ||
<members> | ||
<member name="T:Doki.TestAssembly.InheritanceChain.Abstractions.AbstractClass"> | ||
<summary> | ||
This is an abstract class. See <see cref="T:Doki.TestAssembly.InheritanceChain.Abstractions.AbstractClass"/> for more information. | ||
</summary> | ||
<example> | ||
This is an example of how to use the <see cref="T:Doki.TestAssembly.InheritanceChain.Abstractions.AbstractClass"/> class. | ||
<code> | ||
public class ExampleClass : AbstractClass {} | ||
</code> | ||
</example> | ||
</member> | ||
</members> | ||
</doc> | ||
""")); | ||
|
||
var generator = new DocumentationGenerator(); | ||
|
||
generator.AddAssembly(typeof(AbstractClass).Assembly, emptyDocumentation); | ||
|
||
generator.AddOutput(new JsonOutput(new OutputOptions<JsonOutput> | ||
{ | ||
OutputDirectory = outputDirectory | ||
})); | ||
|
||
await generator.GenerateAsync(NullLogger.Instance); | ||
|
||
var jsonFile = outputDirectory.GetFiles().Single(); | ||
|
||
var json = await File.ReadAllTextAsync(jsonFile.FullName); | ||
|
||
var documentation = JsonSerializer.Deserialize<AssemblyDocumentation>(json); | ||
Assert.NotNull(documentation); | ||
|
||
|
||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
tests/assemblies/Doki.TestAssembly.InheritanceChain.Abstractions/AbstractClass.cs
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 |
---|---|---|
@@ -1,5 +1,14 @@ | ||
namespace Doki.TestAssembly.InheritanceChain.Abstractions; | ||
|
||
/// <summary> | ||
/// This is an abstract class. See <see cref="AbstractClass"/> for more information. | ||
/// </summary> | ||
/// <example> | ||
/// This is an example of how to use the <see cref="AbstractClass"/> class. | ||
/// <code> | ||
/// public class ExampleClass : AbstractClass {} | ||
/// </code> | ||
/// </example> | ||
public abstract class AbstractClass | ||
{ | ||
} |
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