Esempio n. 1
0
        public void Should_not_serialize_attachments()
        {
            //arrange
            var serializer = new MicrosoftJsonSerializer();
            var message    = new AttachmentCommand
            {
                Message    = "Hello",
                Attachment = new MessageAttachment("filename.txt", "text/plain", new MemoryStream())
            };
            //act
            var serialized   = serializer.Serialize(message);
            var deserialized = serializer.Deserialize <AttachmentCommand>(serialized.AsSpan());

            //assert
            deserialized.Attachment.Should().BeNull();
            deserialized.Message.Should().Be("Hello");
        }
Esempio n. 2
0
        public void Should_serialize_deserialize_message()
        {
            //arrange
            var serializer = new MicrosoftJsonSerializer();
            var original   = new TestSerializationCommand
            {
                Age    = 1,
                Height = 5.7f,
                Name   = "Aurora"
            };
            var serialized = serializer.Serialize(original);
            //act
            var deserialized = serializer.Deserialize <TestSerializationCommand>(serialized.AsSpan());

            //assert
            deserialized.Age.Should().Be(original.Age);
            deserialized.Name.Should().Be(original.Name);
            deserialized.Height.Should().Be(original.Height);
        }