Esempio n. 1
0
        /// <summary> Verifies that the given block serializes and then deserializes properly. </summary>
        /// <param name="originalBlock"> The original block to test the serialization process for. </param>
        /// <param name="descriptorsLookup"> The descriptors that should be used when deserializing. </param>
        public static void VerifyDeserialization(Block originalBlock, DescriptorsLookup descriptorsLookup)
        {
            var node    = originalBlock.Serialize();
            var context = new SerializationContext(descriptorsLookup);

            var deserializedBlock = context.Deserialize(node);

            deserializedBlock.As <object>()
            .Should()
            .BeEquivalentTo(originalBlock, c => c.IgnoringCyclicReferences());
        }
Esempio n. 2
0
        public void Verify_Serialization()
        {
            var paragraph = new HeadingBlock();
            var caret     = (TextCaret)paragraph.GetCaretAtStart();

            caret.InsertText("This is some of the text")
            .InsertText("Some additional text");

            var descriptorsLookup = new DescriptorsLookup((BlockDescriptor)HeadingBlock.Descriptor);

            // Act
            SerializationHelpers.VerifyDeserialization(paragraph, descriptorsLookup);
        }
        public void Verify_Serialization()
        {
            var collection = new RootBlockCollection();

            collection.Append(CreateBlock());
            collection.Append(CreateBlock());
            collection.Append(CreateBlock());

            var descriptorsLookup = new DescriptorsLookup(RootBlockCollection.Descriptor,
                                                          ParagraphBlock.Descriptor);

            // Act
            SerializationHelpers.VerifyDeserialization(collection, descriptorsLookup);
        }
        public void Verify_Serialization()
        {
            var paragraph = new ParagraphBlock();
            var cursor    = (TextCaret)paragraph.GetCaretAtStart();
            var next      = cursor.InsertText("This is some of the text");

            next.InsertText("Some additional text");

            next.Content.GetText()
            .Should()
            .BeEquivalentTo("This is some of the textSome additional text");

            var descriptorsLookup = new DescriptorsLookup(ParagraphBlock.Descriptor);

            // Act
            SerializationHelpers.VerifyDeserialization(paragraph, descriptorsLookup);
        }