Skip to content

Commit 1c07aaf

Browse files
v1.3.0 (#18)
* Upgrade the NuGet packages for the unit tests to the last version. * Remove the shortcut of .editorconfig in Directory.Build.props. * Migrates the Azure Pipelines to GitHub actions (#17). * Add new overrides BeJsonDeserializableInto() to test the string collections, string and numeric values (#16).
1 parent a66f8b2 commit 1c07aaf

File tree

10 files changed

+264
-96
lines changed

10 files changed

+264
-96
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Continuous Integration
2+
3+
on:
4+
pull_request:
5+
branches: [ "main" ]
6+
push:
7+
branches: [ "releases/**" ]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v3
14+
15+
- name: Setup .NET 8.x
16+
uses: actions/setup-dotnet@v3
17+
with:
18+
dotnet-version: '8.x'
19+
20+
- name: Build
21+
run: dotnet build --property:Configuration=Debug "PosInformatique.FluentAssertions.Json.sln"
22+
23+
- name: Test with the dotnet CLI
24+
run: dotnet test --property:Configuration=Debug "PosInformatique.FluentAssertions.Json.sln"
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
VersionPrefix:
7+
type: string
8+
description: The version of the library
9+
required: true
10+
default: 1.3.0
11+
VersionSuffix:
12+
type: string
13+
description: The version suffix of the library (for example rc.1)
14+
15+
run-name: ${{ inputs.VersionPrefix }}-${{ inputs.VersionSuffix }}
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v3
22+
23+
- name: Setup .NET 8.x
24+
uses: actions/setup-dotnet@v3
25+
with:
26+
dotnet-version: '8.x'
27+
28+
- name: Build
29+
run: dotnet pack
30+
--property:Configuration=Release
31+
--property:VersionPrefix=${{ github.event.inputs.VersionPrefix }}
32+
--property:VersionSuffix=${{ github.event.inputs.VersionSuffix }}
33+
"src/FluentAssertions.Json/FluentAssertions.Json.csproj"
34+
35+
- name: Publish the package to nuget.org
36+
run: dotnet nuget push "src/FluentAssertions.Json/bin/Release/*.nupkg" --api-key "${{ secrets.NUGET_APIKEY }}" --source https://api.nuget.org/v3/index.json

Directory.Build.props

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@
3131
<Link>stylecop.json</Link>
3232
</AdditionalFiles>
3333
</ItemGroup>
34-
35-
<ItemGroup>
36-
<None Include="..\..\.editorconfig" Link=".editorconfig" />
37-
</ItemGroup>
3834

3935
<!-- Common NuGet packages -->
4036
<ItemGroup>

PosInformatique.FluentAssertions.Json.sln

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{7928175B
2222
tests\.editorconfig = tests\.editorconfig
2323
EndProjectSection
2424
EndProject
25-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{E7CF7FC5-E257-4A28-8641-F41032340CA9}"
26-
ProjectSection(SolutionItems) = preProject
27-
build\azure-pipelines-ci.yaml = build\azure-pipelines-ci.yaml
28-
build\azure-pipelines-release.yaml = build\azure-pipelines-release.yaml
29-
EndProjectSection
30-
EndProject
3125
Global
3226
GlobalSection(SolutionConfigurationPlatforms) = preSolution
3327
Debug|Any CPU = Debug|Any CPU
@@ -48,7 +42,6 @@ Global
4842
EndGlobalSection
4943
GlobalSection(NestedProjects) = preSolution
5044
{7928175B-C3B3-4F81-B956-BF4E4F816436} = {882949E5-7DCE-4EB6-8E9A-CB88FD0ED1F9}
51-
{E7CF7FC5-E257-4A28-8641-F41032340CA9} = {882949E5-7DCE-4EB6-8E9A-CB88FD0ED1F9}
5245
EndGlobalSection
5346
GlobalSection(ExtensibilityGlobals) = postSolution
5447
SolutionGuid = {0582B8EB-4FA4-488E-9953-9B7CEEE4E94F}

build/azure-pipelines-ci.yaml

Lines changed: 0 additions & 24 deletions
This file was deleted.

build/azure-pipelines-release.yaml

Lines changed: 0 additions & 54 deletions
This file was deleted.

src/FluentAssertions.Json/FluentAssertions.Json.csproj

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,12 @@
1111
<PackageProjectUrl>https://github.com/PosInformatique/PosInformatique.FluentAssertions.Json</PackageProjectUrl>
1212
<PackageReadmeFile>README.md</PackageReadmeFile>
1313
<PackageReleaseNotes>
14+
1.3.0
15+
- Add new overload BeJsonDeserializableInto() method to test the string collections.
16+
- Add new overload BeJsonDeserializableInto() method to test the string and numeric values.
17+
1418
1.2.0
15-
- Add new override BeJsonSerializableInto() method to test polymorphism serialization with discriminator JSON property.
19+
- Add new overload BeJsonSerializableInto() method to test polymorphism serialization with discriminator JSON property.
1620
- Add the support to assert the deserialization of root JSON array.
1721

1822
1.1.0

src/FluentAssertions.Json/JsonFluentAssertionsExtensions.cs

Lines changed: 97 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ namespace FluentAssertions
1212
using FluentAssertions.Collections;
1313
using FluentAssertions.Common;
1414
using FluentAssertions.Equivalency;
15+
using FluentAssertions.Numeric;
1516
using FluentAssertions.Primitives;
1617
using PosInformatique.FluentAssertions.Json;
1718

@@ -105,7 +106,7 @@ public static void BeJsonDeserializableInto<T>(this ObjectAssertions assertions,
105106
/// </summary>
106107
/// <typeparam name="TElement">Type of the element of the collection to check the JSON deserialization.</typeparam>
107108
/// <typeparam name="T">Type of the object to deserialize from JSON.</typeparam>
108-
/// <param name="assertions"><see cref="ObjectAssertions"/> which contains the JSON collection subject to deserialize.</param>
109+
/// <param name="assertions"><see cref="GenericCollectionAssertions{T}"/> which contains the JSON collection subject to deserialize.</param>
109110
/// <param name="expectedObject">Expected collection deserialized expected.</param>
110111
/// <param name="options"><see cref="JsonSerializerOptions"/> to use to assert the deserialization. If not specified
111112
/// the default <see cref="IFluentAssertionsJsonConfiguration.JsonSerializerOptions"/> of the <see cref="FluentAssertionsJson.Configuration"/>
@@ -115,6 +116,49 @@ public static void BeJsonDeserializableInto<TElement, T>(this GenericCollectionA
115116
BeJsonDeserializableIntoCore(assertions.Subject, expectedObject, GetSerializerOptions(options));
116117
}
117118

119+
/// <summary>
120+
/// Check if the JSON subject string collection is deserializable into the specified <paramref name="expectedObject"/> argument.
121+
/// </summary>
122+
/// <typeparam name="T">Type of the object to deserialize from JSON.</typeparam>
123+
/// <param name="assertions"><see cref="StringCollectionAssertions"/> which contains the JSON string collection subject to deserialize.</param>
124+
/// <param name="expectedObject">Expected string collection deserialized expected.</param>
125+
/// <param name="options"><see cref="JsonSerializerOptions"/> to use to assert the deserialization. If not specified
126+
/// the default <see cref="IFluentAssertionsJsonConfiguration.JsonSerializerOptions"/> of the <see cref="FluentAssertionsJson.Configuration"/>
127+
/// will be used.</param>
128+
public static void BeJsonDeserializableInto<T>(this StringCollectionAssertions assertions, T expectedObject, JsonSerializerOptions? options = null)
129+
{
130+
BeJsonDeserializableIntoCore(assertions.Subject, expectedObject, GetSerializerOptions(options));
131+
}
132+
133+
/// <summary>
134+
/// Check if the JSON subject numeric is deserializable into the specified <paramref name="expectedObject"/> argument.
135+
/// </summary>
136+
/// <typeparam name="T">Type of the object to deserialize from JSON.</typeparam>
137+
/// <param name="assertions"><see cref="NumericAssertions{T}"/> which contains the JSON numeric subject to deserialize.</param>
138+
/// <param name="expectedObject">Expected numeric value deserialized expected.</param>
139+
/// <param name="options"><see cref="JsonSerializerOptions"/> to use to assert the deserialization. If not specified
140+
/// the default <see cref="IFluentAssertionsJsonConfiguration.JsonSerializerOptions"/> of the <see cref="FluentAssertionsJson.Configuration"/>
141+
/// will be used.</param>
142+
public static void BeJsonDeserializableInto<T>(this NumericAssertions<T> assertions, T expectedObject, JsonSerializerOptions? options = null)
143+
where T : struct, IComparable<T>
144+
{
145+
BeJsonDeserializableIntoCore(assertions.Subject, expectedObject, GetSerializerOptions(options));
146+
}
147+
148+
/// <summary>
149+
/// Check if the JSON subject string is deserializable into the specified <paramref name="expectedObject"/> argument.
150+
/// </summary>
151+
/// <typeparam name="T">Type of the object to deserialize from JSON.</typeparam>
152+
/// <param name="assertions"><see cref="StringAssertions"/> which contains the JSON string subject to deserialize.</param>
153+
/// <param name="expectedObject">Expected string value deserialized expected.</param>
154+
/// <param name="options"><see cref="JsonSerializerOptions"/> to use to assert the deserialization. If not specified
155+
/// the default <see cref="IFluentAssertionsJsonConfiguration.JsonSerializerOptions"/> of the <see cref="FluentAssertionsJson.Configuration"/>
156+
/// will be used.</param>
157+
public static void BeJsonDeserializableInto<T>(this StringAssertions assertions, T expectedObject, JsonSerializerOptions? options = null)
158+
{
159+
BeJsonDeserializableIntoCore(assertions.Subject, expectedObject, GetSerializerOptions(options));
160+
}
161+
118162
/// <summary>
119163
/// Check if the JSON subject object is deserializable into the specified <paramref name="expectedObject"/> argument.
120164
/// </summary>
@@ -150,6 +194,58 @@ public static void BeJsonDeserializableInto<TElement, T>(this GenericCollectionA
150194
BeJsonDeserializableIntoCore(assertions.Subject, expectedObject, optionsCopy);
151195
}
152196

197+
/// <summary>
198+
/// Check if the JSON subject string collection is deserializable into the specified <paramref name="expectedObject"/> argument.
199+
/// </summary>
200+
/// <typeparam name="T">Type of the object to deserialize from JSON.</typeparam>
201+
/// <param name="assertions"><see cref="ObjectAssertions"/> which contains the JSON string collection subject to deserialize.</param>
202+
/// <param name="expectedObject">Expected string collection deserialized expected.</param>
203+
/// <param name="configureOptions">Allows to change the default <see cref="IFluentAssertionsJsonConfiguration.JsonSerializerOptions"/>
204+
/// of the <see cref="FluentAssertionsJson.Configuration"/> used to assert the deserialization.</param>
205+
public static void BeJsonDeserializableInto<T>(this StringCollectionAssertions assertions, T expectedObject, Action<JsonSerializerOptions> configureOptions)
206+
{
207+
var optionsCopy = new JsonSerializerOptions(FluentAssertionsJson.Configuration.JsonSerializerOptions);
208+
209+
configureOptions(optionsCopy);
210+
211+
BeJsonDeserializableIntoCore(assertions.Subject, expectedObject, optionsCopy);
212+
}
213+
214+
/// <summary>
215+
/// Check if the JSON subject numeric is deserializable into the specified <paramref name="expectedObject"/> argument.
216+
/// </summary>
217+
/// <typeparam name="T">Type of the numeric value to deserialize from JSON.</typeparam>
218+
/// <param name="assertions"><see cref="ObjectAssertions"/> which contains the JSON numeric subject to deserialize.</param>
219+
/// <param name="expectedObject">Expected numeric value deserialized expected.</param>
220+
/// <param name="configureOptions">Allows to change the default <see cref="IFluentAssertionsJsonConfiguration.JsonSerializerOptions"/>
221+
/// of the <see cref="FluentAssertionsJson.Configuration"/> used to assert the deserialization.</param>
222+
public static void BeJsonDeserializableInto<T>(this NumericAssertions<T> assertions, T expectedObject, Action<JsonSerializerOptions> configureOptions)
223+
where T : struct, IComparable<T>
224+
{
225+
var optionsCopy = new JsonSerializerOptions(FluentAssertionsJson.Configuration.JsonSerializerOptions);
226+
227+
configureOptions(optionsCopy);
228+
229+
BeJsonDeserializableIntoCore(assertions.Subject, expectedObject, optionsCopy);
230+
}
231+
232+
/// <summary>
233+
/// Check if the JSON subject string is deserializable into the specified <paramref name="expectedObject"/> argument.
234+
/// </summary>
235+
/// <typeparam name="T">Type of the string value to deserialize from JSON.</typeparam>
236+
/// <param name="assertions"><see cref="StringAssertions"/> which contains the JSON string subject to deserialize.</param>
237+
/// <param name="expectedObject">Expected string value deserialized expected.</param>
238+
/// <param name="configureOptions">Allows to change the default <see cref="IFluentAssertionsJsonConfiguration.JsonSerializerOptions"/>
239+
/// of the <see cref="FluentAssertionsJson.Configuration"/> used to assert the deserialization.</param>
240+
public static void BeJsonDeserializableInto<T>(this StringAssertions assertions, T expectedObject, Action<JsonSerializerOptions> configureOptions)
241+
{
242+
var optionsCopy = new JsonSerializerOptions(FluentAssertionsJson.Configuration.JsonSerializerOptions);
243+
244+
configureOptions(optionsCopy);
245+
246+
BeJsonDeserializableIntoCore(assertions.Subject, expectedObject, optionsCopy);
247+
}
248+
153249
private static void BeJsonSerializableIntoCore<TBase>(ObjectAssertions assertions, object? expectedJson, JsonSerializerOptions options)
154250
{
155251
if (assertions.Subject is not null && assertions.Subject is not TBase)

tests/FluentAssertions.Json.Tests/FluentAssertions.Json.Tests.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net7.0</TargetFramework>
4+
<TargetFramework>net8.0</TargetFramework>
55
<Nullable>disable</Nullable>
66

77
<!-- Disable the StyleCop 'XML comment analysis is disabled due to project configuration' warning. -->
88
<NoWarn>$(NoWarn);SA0001</NoWarn>
99
</PropertyGroup>
1010

1111
<ItemGroup>
12-
<PackageReference Include="coverlet.collector" Version="6.0.0">
12+
<PackageReference Include="coverlet.collector" Version="6.0.2">
1313
<PrivateAssets>all</PrivateAssets>
1414
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1515
</PackageReference>
16-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
17-
<PackageReference Include="xunit" Version="2.5.1" />
18-
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.1">
16+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
17+
<PackageReference Include="xunit" Version="2.8.1" />
18+
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.1">
1919
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2020
<PrivateAssets>all</PrivateAssets>
2121
</PackageReference>

0 commit comments

Comments
 (0)