public void ShouldDeSerialize() { const string json = @"{""PackageId"": ""bla""}"; var cut = new SystemTextJsonPackageIdentifier.SystemTextJsonNuGetPackageConverter(); var options = new JsonSerializerOptions(); options.Converters.Add(cut); var actualResult = (string)JsonSerializer.Deserialize <NuGetPackage>(json, options).PackageId; actualResult.Should().Be("bla"); }
public void ShouldSerialize() { var nuGetPackage = new NuGetPackage { PackageId = new SystemTextJsonPackageIdentifier("bla") }; var cut = new SystemTextJsonPackageIdentifier.SystemTextJsonNuGetPackageConverter(); var options = new JsonSerializerOptions(); options.Converters.Add(cut); JsonSerializer.Serialize(nuGetPackage, typeof(NuGetPackage), options).Should().Contain("\"bla\""); }