diff --git a/Doki.sln b/Doki.sln index de132d2..f9f62a9 100644 --- a/Doki.sln +++ b/Doki.sln @@ -28,6 +28,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Doki.Output.Extensions", "s EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Doki.Output.Json", "src\Doki.Output.Json\Doki.Output.Json.csproj", "{00BCCBC0-A719-489C-A746-559B4D055B56}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Doki.Output.Json.Tests", "tests\Doki.Output.Json.Tests\Doki.Output.Json.Tests.csproj", "{6CCD9EE6-B3FC-485F-9155-553165141B20}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -43,6 +45,7 @@ Global {33DFFEBE-DB9E-4960-BB4E-3B58399E132C} = {568576F3-3D48-459E-B4D2-1790DAE80E7A} {A89D22B2-2427-4863-A2D9-9E1BEFF37C61} = {568576F3-3D48-459E-B4D2-1790DAE80E7A} {00BCCBC0-A719-489C-A746-559B4D055B56} = {568576F3-3D48-459E-B4D2-1790DAE80E7A} + {6CCD9EE6-B3FC-485F-9155-553165141B20} = {8C7B5305-B599-4F08-B28B-DD9F1715DD51} EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {6F31B87A-2BD3-4FB4-8C08-7E059A338D4A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU @@ -89,5 +92,9 @@ Global {00BCCBC0-A719-489C-A746-559B4D055B56}.Debug|Any CPU.Build.0 = Debug|Any CPU {00BCCBC0-A719-489C-A746-559B4D055B56}.Release|Any CPU.ActiveCfg = Release|Any CPU {00BCCBC0-A719-489C-A746-559B4D055B56}.Release|Any CPU.Build.0 = Release|Any CPU + {6CCD9EE6-B3FC-485F-9155-553165141B20}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6CCD9EE6-B3FC-485F-9155-553165141B20}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6CCD9EE6-B3FC-485F-9155-553165141B20}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6CCD9EE6-B3FC-485F-9155-553165141B20}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal diff --git a/tests/Doki.Output.Json.Tests/Doki.Output.Json.Tests.csproj b/tests/Doki.Output.Json.Tests/Doki.Output.Json.Tests.csproj new file mode 100644 index 0000000..4418524 --- /dev/null +++ b/tests/Doki.Output.Json.Tests/Doki.Output.Json.Tests.csproj @@ -0,0 +1,31 @@ + + + + net8.0 + enable + enable + + false + true + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + + + + diff --git a/tests/Doki.Output.Json.Tests/GlobalUsings.cs b/tests/Doki.Output.Json.Tests/GlobalUsings.cs new file mode 100644 index 0000000..8c927eb --- /dev/null +++ b/tests/Doki.Output.Json.Tests/GlobalUsings.cs @@ -0,0 +1 @@ +global using Xunit; \ No newline at end of file diff --git a/tests/Doki.Output.Json.Tests/JsonOutputTests.cs b/tests/Doki.Output.Json.Tests/JsonOutputTests.cs new file mode 100644 index 0000000..05f42a1 --- /dev/null +++ b/tests/Doki.Output.Json.Tests/JsonOutputTests.cs @@ -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(""" + + + + Doki.TestAssembly.InheritanceChain.Abstractions + + + + + This is an abstract class. See for more information. + + + This is an example of how to use the class. + + public class ExampleClass : AbstractClass {} + + + + + + """)); + + var generator = new DocumentationGenerator(); + + generator.AddAssembly(typeof(AbstractClass).Assembly, emptyDocumentation); + + generator.AddOutput(new JsonOutput(new OutputOptions + { + OutputDirectory = outputDirectory + })); + + await generator.GenerateAsync(NullLogger.Instance); + + var jsonFile = outputDirectory.GetFiles().Single(); + + var json = await File.ReadAllTextAsync(jsonFile.FullName); + + var documentation = JsonSerializer.Deserialize(json); + Assert.NotNull(documentation); + + + } +} \ No newline at end of file diff --git a/tests/assemblies/Doki.TestAssembly.InheritanceChain.Abstractions/AbstractClass.cs b/tests/assemblies/Doki.TestAssembly.InheritanceChain.Abstractions/AbstractClass.cs index 6b60390..0809341 100644 --- a/tests/assemblies/Doki.TestAssembly.InheritanceChain.Abstractions/AbstractClass.cs +++ b/tests/assemblies/Doki.TestAssembly.InheritanceChain.Abstractions/AbstractClass.cs @@ -1,5 +1,14 @@ namespace Doki.TestAssembly.InheritanceChain.Abstractions; +/// +/// This is an abstract class. See for more information. +/// +/// +/// This is an example of how to use the class. +/// +/// public class ExampleClass : AbstractClass {} +/// +/// public abstract class AbstractClass { } \ No newline at end of file diff --git a/tests/assemblies/Doki.TestAssembly.InheritanceChain.Abstractions/Doki.TestAssembly.InheritanceChain.Abstractions.csproj b/tests/assemblies/Doki.TestAssembly.InheritanceChain.Abstractions/Doki.TestAssembly.InheritanceChain.Abstractions.csproj index eb2460e..e0cdc1a 100644 --- a/tests/assemblies/Doki.TestAssembly.InheritanceChain.Abstractions/Doki.TestAssembly.InheritanceChain.Abstractions.csproj +++ b/tests/assemblies/Doki.TestAssembly.InheritanceChain.Abstractions/Doki.TestAssembly.InheritanceChain.Abstractions.csproj @@ -4,6 +4,7 @@ net6.0 enable enable + true