public void SerializeToString() { var content = new TestPageContent { Title = "page", Header = new PageHeaderContent { Title = "header" }, Headers = new List<PageHeaderContent> { new PageHeaderContent { Title = "header" } } }; var contentMetadata = metadataManager.GetMetadata(content.GetType()); var contentData = contentMetadata.ConvertContentModelToDictionary(content); var json = JsonContentDataSerializer.SerializeToString(contentData); Assert.NotNull(json); }
public void ConvertDictionaryToContentModel() { var contentMetadata = metadataManager.GetMetadata <TestPageContent>(); var sourceModel = new TestPageContent { Title = "test" }; var data = contentMetadata.ConvertContentModelToDictionary(sourceModel); var model = contentMetadata.ConvertDictionaryToContentModel(data) as TestPageContent; Assert.NotNull(model); Assert.Equal(model.GetType(), sourceModel.GetType()); Assert.Equal(model.Title, sourceModel.Title); }
public void DeserializeFromString() { var content = new TestPageContent { Title = "page", Header = new PageHeaderContent { Title = "header" }, Headers = new List<PageHeaderContent> { new PageHeaderContent { Title = "header" } } }; var contentMetadata = metadataManager.GetMetadata(content.GetType()); var contentData = contentMetadata.ConvertContentModelToDictionary(content); var json = JsonContentDataSerializer.SerializeToString(contentData); var deserializedContentData = JsonContentDataSerializer.DeserializeFromString(json); var deserializedContent = (TestPageContent)contentMetadata.ConvertDictionaryToContentModel(deserializedContentData); Assert.NotNull(deserializedContent); Assert.Equal(deserializedContent.Title, content.Title); Assert.Equal(deserializedContent.Header.Title, content.Header.Title); Assert.Equal(deserializedContent.Headers[0].Title, content.Headers[0].Title); }