Skip to content

Commit e921588

Browse files
authored
Add net80 as target framework (#7)
* Add net80 as target framework * Update nuget packages to latests * Update unit test to use the constraint model * Bump version to v2.1.0
1 parent b3c6397 commit e921588

10 files changed

+102
-101
lines changed

.github/workflows/build_test.yml

+7-7
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,19 @@ jobs:
1616
name: Build
1717
runs-on: ${{ matrix.os }}
1818
env:
19-
version: '2.0.1'
20-
versionFile: '2.0.1'
21-
packDotNetVersion: '6'
19+
version: '2.1.0'
20+
versionFile: '2.1.0'
21+
packDotNetVersion: '8'
2222
strategy:
2323
matrix:
2424
os: [ ubuntu-latest ]
25-
dotnet-version: [ '3.x', '6.x' ]
25+
dotnet-version: [ '3.x', '6.x', '8.0' ]
2626

2727
steps:
2828
- name: Checkout
29-
uses: actions/checkout@v3
29+
uses: actions/checkout@v4
3030
- name: Setup .NET
31-
uses: actions/setup-dotnet@v3
31+
uses: actions/setup-dotnet@v4
3232
with:
3333
dotnet-version: ${{ matrix.dotnet-version }}
3434
- name: Restore dependencies
@@ -44,7 +44,7 @@ jobs:
4444
dotnet build ./Src/TextTemplating.sln /verbosity:minimal --configuration release /p:IncludeSymbols=true /p:SymbolPackageFormat=snupkg /p:ContinuousIntegrationBuild=true /p:PackageOutputPath=${{ github.workspace }}/artifacts/ /p:Version=${{ env.version }} /p:FileVersion=${{ env.versionFile }}
4545
dotnet pack ./Src/TextTemplating.sln /verbosity:minimal --configuration release
4646
- name: Upload Artifacts
47-
uses: actions/upload-artifact@v3
47+
uses: actions/upload-artifact@v4
4848
if: startsWith(matrix.dotnet-version, env.packDotNetVersion)
4949
with:
5050
name: Packages_${{ env.version }}

Src/Axuno.TextTemplating.Tests/Axuno.TextTemplating.Tests.csproj

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net6.0</TargetFrameworks>
4+
<TargetFrameworks>net8.0</TargetFrameworks>
55
<SignAssembly>true</SignAssembly>
66
<AssemblyOriginatorKeyFile>..\Axuno.TextTemplating\Axuno.TextTemplating.snk</AssemblyOriginatorKeyFile>
77
<Authors>axuno gGmbH</Authors>
@@ -16,10 +16,14 @@
1616
</PropertyGroup>
1717

1818
<ItemGroup>
19-
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
20-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
21-
<PackageReference Include="NUnit" Version="3.13.3" />
22-
<PackageReference Include="NUnit3TestAdapter" Version="4.3.1" />
19+
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
20+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
21+
<PackageReference Include="NUnit" Version="4.1.0" />
22+
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
23+
<PackageReference Include="NUnit.Analyzers" Version="4.2.0">
24+
<PrivateAssets>all</PrivateAssets>
25+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
26+
</PackageReference>
2327
</ItemGroup>
2428

2529
<ItemGroup>

Src/Axuno.TextTemplating.Tests/TemplateDefinitionTests.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,18 @@ public TemplateDefinitionTests()
1919
public void Should_Retrieve_Template_Definition_By_Name()
2020
{
2121
var welcomeEmailTemplate = _templateDefinitionManager.Get(Templates.WelcomeEmail);
22-
Assert.AreEqual(Templates.WelcomeEmail, welcomeEmailTemplate?.Name);
23-
Assert.IsFalse(welcomeEmailTemplate?.IsInlineLocalized);
22+
Assert.That(welcomeEmailTemplate?.Name, Is.EqualTo(Templates.WelcomeEmail));
23+
Assert.That(welcomeEmailTemplate?.IsInlineLocalized, Is.False);
2424

2525
var sayHelloTemplate = _templateDefinitionManager.Get(Templates.SayHelloEmail);
26-
Assert.AreEqual(Templates.SayHelloEmail, sayHelloTemplate?.Name);
27-
Assert.IsTrue(sayHelloTemplate?.IsInlineLocalized);
26+
Assert.That(sayHelloTemplate?.Name, Is.EqualTo(Templates.SayHelloEmail));
27+
Assert.That(sayHelloTemplate?.IsInlineLocalized, Is.True);
2828
}
2929

3030
[Test]
3131
public void Should_Get_Null_If_Template_Not_Found()
3232
{
33-
Assert.IsNull(_templateDefinitionManager.Get("undefined-template"));
33+
Assert.That(_templateDefinitionManager.Get("undefined-template"), Is.Null);
3434
}
3535

3636
[Test]
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
1+
using System.Collections.Generic;
32
using System.Threading.Tasks;
43
using Microsoft.Extensions.DependencyInjection;
54
using NUnit.Framework;
@@ -9,7 +8,7 @@ namespace Axuno.TextTemplating.Tests;
98
[TestFixture]
109
public class TemplateRendererTests
1110
{
12-
private readonly IServiceProvider _services;
11+
private readonly ServiceProvider _services;
1312
private readonly ITemplateRenderer _renderer;
1413

1514
public TemplateRendererTests()
@@ -18,108 +17,114 @@ public TemplateRendererTests()
1817
_renderer = _services.GetRequiredService<ITemplateRenderer>();
1918
}
2019

20+
[OneTimeTearDown]
21+
public void CleanUp()
22+
{
23+
_services.Dispose();
24+
}
25+
2126
[Test]
2227
public async Task Should_Get_Rendered_With_CultureSpecific_Template()
2328
{
24-
Assert.AreEqual("Welcome John to Axuno.TextTemplating!", await _renderer.RenderAsync(
29+
Assert.That(await _renderer.RenderAsync(
2530
Templates.WelcomeEmail,
2631
model: new
2732
{
2833
name = "John"
2934
},
3035
cultureName: "en"
31-
));
36+
), Is.EqualTo("Welcome John to Axuno.TextTemplating!"));
3237

33-
Assert.AreEqual("Willkommen, John, bei Axuno.TextTemplating!", await _renderer.RenderAsync(
38+
Assert.That(await _renderer.RenderAsync(
3439
Templates.WelcomeEmail,
3540
model: new
3641
{
3742
name = "John"
3843
},
3944
cultureName: "de"
40-
));
45+
), Is.EqualTo("Willkommen, John, bei Axuno.TextTemplating!"));
4146
}
4247

4348
[Test]
4449
public async Task Should_Use_Fallback_Culture_CultureSpecific_Template()
4550
{
4651
//"en-US" falls back to "en" since "en-US" doesn't exists and "en" is the fallback culture
47-
Assert.AreEqual("Welcome John to Axuno.TextTemplating!", await _renderer.RenderAsync(
52+
Assert.That(await _renderer.RenderAsync(
4853
Templates.WelcomeEmail,
4954
model: new
5055
{
5156
name = "John"
5257
},
5358
cultureName: "en_US"
54-
));
55-
59+
), Is.EqualTo("Welcome John to Axuno.TextTemplating!"));
60+
5661
//"es" falls back to "en" since "es" doesn't exists and "en" is the fallback culture
57-
Assert.AreEqual("Welcome John to Axuno.TextTemplating!", await _renderer.RenderAsync(
62+
Assert.That(await _renderer.RenderAsync(
5863
Templates.WelcomeEmail,
5964
model: new
6065
{
6166
name = "John"
6267
},
6368
cultureName: "es"
64-
));
69+
), Is.EqualTo("Welcome John to Axuno.TextTemplating!"));
6570
}
6671

6772
[Test]
6873
public async Task Should_Get_Rendered_Localized_Template_Content_With_Strongly_Typed_Model()
6974
{
70-
Assert.AreEqual("Welcome John to Axuno.TextTemplating!", await _renderer.RenderAsync(
75+
Assert.That(await _renderer.RenderAsync(
7176
Templates.WelcomeEmail,
7277
model: new WelcomeEmailModel("John"),
7378
cultureName: "en"
74-
));
79+
), Is.EqualTo("Welcome John to Axuno.TextTemplating!"));
7580
}
7681

7782
[Test]
7883
public async Task Should_Get_Rendered_Localized_Template_Content_With_Dictionary_Model()
7984
{
80-
Assert.AreEqual("Welcome John to Axuno.TextTemplating!", await _renderer.RenderAsync(
85+
Assert.That(await _renderer.RenderAsync(
8186
Templates.WelcomeEmail,
8287
model: new Dictionary<string, object> { { "name", "John" } },
8388
cultureName: "en"
84-
));
89+
), Is.EqualTo("Welcome John to Axuno.TextTemplating!"));
8590
}
8691

8792
[Test]
8893
public async Task Should_Get_Rendered_Inline_Localized_Template()
8994
{
90-
Assert.AreEqual("*BEGIN*Hello John, how are you?*END*", await _renderer.RenderAsync(
95+
Assert.That(await _renderer.RenderAsync(
9196
Templates.SayHelloEmail,
9297
new SayHelloEmailModel("John"),
9398
cultureName: "en"
94-
));
99+
), Is.EqualTo("*BEGIN*Hello John, how are you?*END*"));
95100

96-
Assert.AreEqual("*BEGIN*Bonjour John, comment ça va?*END*", await _renderer.RenderAsync(
101+
Assert.That(await _renderer.RenderAsync(
97102
Templates.SayHelloEmail,
98103
new SayHelloEmailModel("John"),
99104
cultureName: "fr"
100-
));
101-
102-
Assert.AreEqual("*BEGIN*Hallo John, wie geht es Dir?*END*", await _renderer.RenderAsync(
105+
), Is.EqualTo("*BEGIN*Bonjour John, comment ça va?*END*"));
106+
107+
Assert.That(await _renderer.RenderAsync(
103108
Templates.SayHelloEmail,
104109
new SayHelloEmailModel("John"),
105110
cultureName: "de"
106-
));
111+
), Is.EqualTo("*BEGIN*Hallo John, wie geht es Dir?*END*"));
107112
}
108113

109114
[Test]
110115
public async Task Should_Get_Localized_Numbers()
111116
{
112-
Assert.AreEqual("*BEGIN*123.45*END*", await _renderer.RenderAsync(
117+
Assert.That(await _renderer.RenderAsync(
113118
Templates.ShowDecimalNumber,
114119
new Dictionary<string, decimal>(new List<KeyValuePair<string, decimal>> {new KeyValuePair<string, decimal>("amount", 123.45M)}),
115120
cultureName: "en"
116-
));
117-
118-
Assert.AreEqual("*BEGIN*123,45*END*", await _renderer.RenderAsync(
121+
), Is.EqualTo("*BEGIN*123.45*END*"));
122+
123+
Assert.That(await _renderer.RenderAsync(
119124
Templates.ShowDecimalNumber,
120125
new Dictionary<string, decimal>(new List<KeyValuePair<string, decimal>> {new KeyValuePair<string, decimal>("amount", 123.45M)}),
121126
cultureName: "de"
122-
));
127+
), Is.EqualTo("*BEGIN*123,45*END*"));
123128
}
124129

125130
private class WelcomeEmailModel
@@ -141,4 +146,4 @@ public SayHelloEmailModel(string name)
141146
Name = name;
142147
}
143148
}
144-
}
149+
}

Src/Axuno.TextTemplating.Tests/TextTemplatingOptionsTests.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ public TextTemplatingOptionsTests()
2020
[Test]
2121
public void Should_Auto_Add_TemplateDefinitionProviders_To_Options()
2222
{
23-
Assert.Contains(typeof(TestTemplateDefinitionProvider), _options.DefinitionProviders.ToList());
23+
Assert.That(_options.DefinitionProviders.ToList(), Does.Contain(typeof(TestTemplateDefinitionProvider)));
2424
}
25-
}
25+
}

Src/Axuno.TextTemplating.Tests/VirtualFiles/LocalizedTemplateContentReaderFactoryTests.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ public async Task Create_Should_Work_With_PhysicalFileProvider()
3030

3131
var reader = await localizedTemplateContentReaderFactory.CreateAsync(_templateDefinitionManager.Get(Templates.WelcomeEmail)!);
3232

33-
Assert.AreEqual(reader.GetContent("en"), "Welcome {{model.name}} to Axuno.TextTemplating!");
34-
Assert.AreEqual(reader.GetContent("de"), "Willkommen, {{model.name}}, bei Axuno.TextTemplating!");
33+
Assert.That(reader.GetContent("en"), Is.EqualTo("Welcome {{model.name}} to Axuno.TextTemplating!"));
34+
Assert.That(reader.GetContent("de"), Is.EqualTo("Willkommen, {{model.name}}, bei Axuno.TextTemplating!"));
3535
}
3636

3737
private class TestPhysicalVirtualFileProvider : IFileProvider
@@ -58,4 +58,4 @@ public IChangeToken Watch(string filter)
5858
return _physicalFileProvider.Watch(filter);
5959
}
6060
}
61-
}
61+
}

Src/Axuno.TextTemplating.Tests/VirtualFiles/VirtualFileTemplateContributorTests.cs

+15-12
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace Axuno.TextTemplating.Tests.VirtualFiles;
99
[TestFixture]
1010
public class VirtualFileTemplateContributorTests
1111
{
12-
private readonly IServiceProvider _services;
12+
private readonly ServiceProvider _services;
1313
private readonly ITemplateDefinitionManager _templateDefinitionManager;
1414
private readonly VirtualFileTemplateContentContributor _virtualFileTemplateContentContributor;
1515

@@ -20,29 +20,32 @@ public VirtualFileTemplateContributorTests()
2020
_virtualFileTemplateContentContributor = _services.GetRequiredService<VirtualFileTemplateContentContributor>();
2121
}
2222

23+
[OneTimeTearDown]
24+
public void CleanUp()
25+
{
26+
_services.Dispose();
27+
}
28+
2329
[Test]
2430
public async Task Should_Get_Localized_Content_By_Culture()
2531
{
26-
Assert.AreEqual("Welcome {{model.name}} to Axuno.TextTemplating!",
27-
await _virtualFileTemplateContentContributor.GetAsync(
32+
Assert.That(await _virtualFileTemplateContentContributor.GetAsync(
2833
new TemplateContentContributorContext(_templateDefinitionManager.Get(Templates.WelcomeEmail)!,
2934
_services,
30-
"en")));
31-
32-
Assert.AreEqual("Willkommen, {{model.name}}, bei Axuno.TextTemplating!",
33-
await _virtualFileTemplateContentContributor.GetAsync(
35+
"en")), Is.EqualTo("Welcome {{model.name}} to Axuno.TextTemplating!"));
36+
37+
Assert.That(await _virtualFileTemplateContentContributor.GetAsync(
3438
new TemplateContentContributorContext(_templateDefinitionManager.Get(Templates.WelcomeEmail)!,
3539
_services,
36-
"de")));
40+
"de")), Is.EqualTo("Willkommen, {{model.name}}, bei Axuno.TextTemplating!"));
3741
}
3842

3943
[Test]
4044
public async Task Should_Get_Non_Localized_Template_Content()
4145
{
42-
Assert.AreEqual("{{ L \"HelloText\" model.name}}, {{ L \"HowAreYou\" }}",
43-
await _virtualFileTemplateContentContributor.GetAsync(
46+
Assert.That(await _virtualFileTemplateContentContributor.GetAsync(
4447
new TemplateContentContributorContext(_templateDefinitionManager.Get(Templates.SayHelloEmail)!,
4548
_services,
46-
null)));
49+
null)), Is.EqualTo("{{ L \"HelloText\" model.name}}, {{ L \"HowAreYou\" }}"));
4750
}
48-
}
51+
}

0 commit comments

Comments
 (0)