Ejemplo n.º 1
0
        public virtual void DeserializeUtf8BytesToJson_Should_ReturnJsonStringByGenericTypeAndUtf8BytesPassedIn()
        {
            // Arrange
            var utf8JsonBytes  = Encoding.UTF8.GetBytes("{\"RedPanda\":\"Hello World!\",\"Happy\":true,\"Year\":2020,\"Enum\":0,\"BDto\":{\"Service\":\"RedPanda\"}}");
            var expectedResult = JsonSerializer.Serialize(new ADto
            {
                RedPanda = "Hello World!",
                Happy    = true,
                Year     = 2020,
                Enum     = TestEnum.RedPanda,
                BDto     = new BDto
                {
                    Service = "RedPanda"
                }
            }, new JsonSerializerOptions {
                IgnoreNullValues = true
            });

            // Assert
            var actualResult = jsonProvider.DeserializeUtf8BytesToJson <ADto>(utf8JsonBytes);

            // Act
            actualResult.Should().BeEquivalentTo(expectedResult);
        }