public void CanSerializeAndDeserializeMarkdown() { var sut = new NodeToFolderSerializer(new SystemIoFileSystem()); string rootPath = Path.GetFullPath("temp2"); var node = new TestNodeWithMarkdown{ Name = "Root", Uri = new Uri("http://root/barn"), HeadLine = "Mjallo", BirthDay = DateTime.Today, Content = new Markdown { Source = "Mjallo"} }; sut.Serialize(rootPath, node, recursive: false); string nodePath = Path.Combine(rootPath, "Root"); File.Exists(Path.Combine(nodePath, "Content.markdown")).Should().BeTrue(); var reloaded = (TestNodeWithMarkdown)sut.Deserialize(nodePath); reloaded.Content.Source.Should().Be("Mjallo"); }
public void CanDeserializeSimpleNode() { // Arrange var sut = new NodeToFolderSerializer(new SystemIoFileSystem()); string rootPath = Path.GetFullPath("temp2"); var node = new TestNodeWithHtml { Name = "Root", Uri = new Uri("http://root/barn"), HeadLine = "Mjallo", BirthDay = DateTime.Today, Content = XDocument.Parse("<html><body>Hejsa</body></html>") }; sut.Serialize(rootPath, node, recursive: false); // Act var newNode = (TestNodeWithHtml)sut.Deserialize(Path.Combine(rootPath, "Root")); // Assert newNode.Uri.ToString().Should().BeEquivalentTo("http://root/barn"); newNode.HeadLine.Should().BeEquivalentTo("Mjallo"); newNode.Content.Should().HaveRoot("html"); newNode.Content.Should().HaveElement("body"); newNode.BirthDay.Should().Be(DateTime.Today); }
public void CanSerializeAndDeserializeMarkdown() { var sut = new NodeToFolderSerializer(new SystemIoFileSystem()); string rootPath = Path.GetFullPath("temp2"); var node = new TestNodeWithMarkdown { Name = "Root", Uri = new Uri("http://root/barn"), HeadLine = "Mjallo", BirthDay = DateTime.Today, Content = new Markdown { Source = "Mjallo" } }; sut.Serialize(rootPath, node, recursive: false); string nodePath = Path.Combine(rootPath, "Root"); File.Exists(Path.Combine(nodePath, "Content.markdown")).Should().BeTrue(); var reloaded = (TestNodeWithMarkdown)sut.Deserialize(nodePath); reloaded.Content.Source.Should().Be("Mjallo"); }