コード例 #1
0
        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");
        }
コード例 #2
0
        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\"");
        }