-
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.
test: new tests to assert Program (#17)
- Loading branch information
Showing
13 changed files
with
167 additions
and
6 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
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,16 @@ | ||
[ | ||
{ | ||
"name": { | ||
"first": "Albert", | ||
"last": "Einstein" | ||
}, | ||
"age": 30 | ||
}, | ||
{ | ||
"name": { | ||
"first": "Nikola", | ||
"last": "Tesla" | ||
}, | ||
"age": 50 | ||
} | ||
] |
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,16 @@ | ||
<root> | ||
<employee> | ||
<name> | ||
<first>Albert</first> | ||
<last>Einstein</last> | ||
</name> | ||
<age>30</age> | ||
</employee> | ||
<employee> | ||
<name> | ||
<first>Nikola</first> | ||
<last>Tesla</last> | ||
</name> | ||
<age>50</age> | ||
</employee> | ||
</root> |
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,8 @@ | ||
- name: | ||
first: Albert | ||
last: Einstein | ||
age: 30 | ||
- name: | ||
first: Nikola | ||
last: Tesla | ||
age: 50 |
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,58 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<ItemGroup> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" /> | ||
<PackageReference Include="Moq" Version="4.20.72" /> | ||
<PackageReference Include="NUnit" Version="4.2.2" /> | ||
<PackageReference Include="NUnit.Analyzers" Version="4.3.0"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" /> | ||
<PackageReference Include="Appveyor.TestLogger" Version="2.0.0" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<PackageReference Include="coverlet.msbuild" Version="6.0.2"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
<PackageReference Include="coverlet.collector" Version="6.0.2"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<PackageReference Update="DotNet.ReproducibleBuilds" Version="1.2.25"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\Didot.Cli\Didot.Cli.csproj" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Update="Data\data-01.xml"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
<None Update="Data\data-01.json"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
<None Update="Data\data-01.yaml"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
<None Update="Expectation\expectation-01.txt"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
<None Update="Template\template-01.smart"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
<None Update="Template\template-01.hbs"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
<None Update="Template\template-01.liquid"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
<None Update="Template\template-01.scriban"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
</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,2 @@ | ||
Albert Einstein is a 30 years old. | ||
Nikola Tesla is a 50 years old. |
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 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using NUnit.Framework; | ||
|
||
namespace Didot.Cli.Testing; | ||
|
||
public class ProgramTests | ||
{ | ||
private static string[] Templates = { "scriban", "liquid", "hbs", "smart" }; | ||
public static string[] DataSets = { "yaml", "json", "xml" }; | ||
|
||
[Test, Combinatorial] | ||
public void Main_WithNoArguments_ShouldPrintHelp( | ||
[ValueSource(nameof(Templates))] string engine, | ||
[ValueSource(nameof(DataSets))] string data) | ||
{ | ||
var args = new string[] | ||
{ | ||
$"-ttemplate/template-01.{engine}", | ||
$"-sdata/data-01.{data}", | ||
$"-ooutput-01-{engine}-{data}.txt" | ||
}; | ||
Program.Main(args); | ||
|
||
var output = File.ReadAllText($"output-01-{engine}-{data}.txt").Uniform(); | ||
var expected = File.ReadAllText($"Expectation/expectation-01.txt").Uniform(); | ||
Assert.That(output, Is.EqualTo(expected)); | ||
} | ||
} | ||
|
||
public static class StringExtensions | ||
{ | ||
public static string Uniform(this string value) | ||
{ | ||
var result = value.Trim().Replace("\r\n", "\n").Trim(); | ||
return result; | ||
} | ||
} |
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,3 @@ | ||
{{#each model}} | ||
{{this.name.first}} {{this.name.last}} is a {{this.age}} years old. | ||
{{/each}} |
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,3 @@ | ||
{% for employee in model -%} | ||
{{ employee.name.first }} {{ employee.name.last }} is a {{ employee.age }} years old. | ||
{%- endfor %} |
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,3 @@ | ||
{{~ for employee in model ~}} | ||
{{employee.name.first}} {{employee.name.last}} is a {{employee.age}} years old. | ||
{{~ end ~}} |
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,2 @@ | ||
{model:{name.first} {name.last} is a {age} years old.| | ||
} |