forked from dotnet/Docker.DotNet
-
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.
fix: Support empty string serialization / deserialization
- Loading branch information
1 parent
e036666
commit 52399a3
Showing
8 changed files
with
136 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
using System.Runtime.CompilerServices; | ||
|
||
[assembly: InternalsVisibleTo("Docker.DotNet.JsonSerializer8.Tests" + StrongNamePublicKeys.DockerDotNetPublicKey)] | ||
[assembly: InternalsVisibleTo("Docker.DotNet.JsonSerializer9.Tests" + StrongNamePublicKeys.DockerDotNetPublicKey)] | ||
[assembly: InternalsVisibleTo("Docker.DotNet.Tests" + StrongNamePublicKeys.DockerDotNetPublicKey)] |
15 changes: 15 additions & 0 deletions
15
test/Docker.DotNet.JsonSerializer8.Tests/Docker.DotNet.JsonSerializer8.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,15 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<IsPackable>false</IsPackable> | ||
<IsPublishable>false</IsPublishable> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" /> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2" /> | ||
<PackageReference Include="xunit" Version="2.9.2" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\Docker.DotNet\Docker.DotNet.csproj" /> | ||
</ItemGroup> | ||
</Project> |
40 changes: 40 additions & 0 deletions
40
test/Docker.DotNet.JsonSerializer8.Tests/JsonEnumMemberConverterTest.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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
namespace Docker.DotNet.JsonSerializer8.Tests; | ||
|
||
public sealed class JsonEnumMemberConverterTests | ||
{ | ||
[Theory] | ||
[ClassData(typeof(RestartPolicyKindTestData))] | ||
public void JsonSerialization_ShouldSerializeAndDeserializeCorrectly(RestartPolicyKind restartPolicyKind) | ||
{ | ||
// Given | ||
var parameters = new CreateContainerParameters | ||
{ | ||
HostConfig = new HostConfig | ||
{ | ||
RestartPolicy = new RestartPolicy | ||
{ | ||
Name = restartPolicyKind | ||
} | ||
} | ||
}; | ||
|
||
// When | ||
var jsonString = JsonSerializer.Instance.Serialize(parameters); | ||
var deserializedParameters = JsonSerializer.Instance.Deserialize<CreateContainerParameters>(Encoding.UTF8.GetBytes(jsonString)); | ||
|
||
// Then | ||
Assert.Equal(restartPolicyKind, deserializedParameters.HostConfig.RestartPolicy.Name); | ||
} | ||
|
||
private sealed class RestartPolicyKindTestData : TheoryData<RestartPolicyKind> | ||
{ | ||
public RestartPolicyKindTestData() | ||
{ | ||
Add(RestartPolicyKind.Undefined); | ||
Add(RestartPolicyKind.No); | ||
Add(RestartPolicyKind.Always); | ||
Add(RestartPolicyKind.OnFailure); | ||
Add(RestartPolicyKind.UnlessStopped); | ||
} | ||
} | ||
} |
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 @@ | ||
global using System.Text; | ||
global using Docker.DotNet.Models; | ||
global using Xunit; |
21 changes: 21 additions & 0 deletions
21
test/Docker.DotNet.JsonSerializer9.Tests/Docker.DotNet.JsonSerializer9.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,21 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<IsPackable>false</IsPackable> | ||
<IsPublishable>false</IsPublishable> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" /> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2" /> | ||
<PackageReference Include="xunit" Version="2.9.2" /> | ||
<PackageReference Include="System.IO.Pipelines" Version="9.0.0" /> | ||
<PackageReference Include="System.Net.Http.Json" Version="9.0.0" /> | ||
<PackageReference Include="System.Text.Json" Version="9.0.0" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\Docker.DotNet\Docker.DotNet.csproj" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="..\Docker.DotNet.JsonSerializer8.Tests\*.cs"/> | ||
</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