public void CanSerializeHtmlFields()
        {
            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);

            string nodePath = Path.Combine(rootPath, "Root");
            File.Exists(Path.Combine(nodePath, "Properties.txt")).Should().BeTrue();
            Directory.EnumerateFiles(nodePath).Count().Should().Be(4);
            Directory.EnumerateDirectories(nodePath).Count().Should().Be(0);
            XDocument.Load(Path.Combine(nodePath, "Content.xml"));
        }
Ejemplo n.º 2
0
        public void CanSerializeHtmlFields()
        {
            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);

            string nodePath = Path.Combine(rootPath, "Root");

            File.Exists(Path.Combine(nodePath, "Properties.txt")).Should().BeTrue();
            Directory.EnumerateFiles(nodePath).Count().Should().Be(4);
            Directory.EnumerateDirectories(nodePath).Count().Should().Be(0);
            XDocument.Load(Path.Combine(nodePath, "Content.xml"));
        }
        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);
        }
Ejemplo n.º 4
0
        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);
        }