Esempio n. 1
0
        public void CanOrderOrderedDocuments()
        {
            var path = Path.GetFullPath(@"data\ordered-documents\");

            var command = new LoadDocumentsCommand();
            command.Author = new Author();
            command.DocumentsPath = path;
            command.OutputRootPath = Path.GetFullPath("output");
            command.RenderedExtensions = new[] { "md" };
            command.RootUrl = "http://www.example.com/";
            command.ApplicationUrl = "/foo";
            command.Execute();

            var order = new OrderCommand();
            order.Documents = command.Documents;
            order.Execute();

            Assert.Equal(1, order.Books.Count());

            var documents = command.Documents.OrderBy(d => d.Order).ToList();

            Assert.Equal(0, documents[0].Order);
            Assert.Equal("parent.txt", documents[0].OutputRelativePath);
            Assert.Equal(String.Empty, documents[0].ParentId);
            Assert.Null(documents[0].ParentDocument);

            Assert.Equal(1, documents[1].Order);
            Assert.Equal("parent\\first-ordered-document.txt", documents[1].OutputRelativePath);
            Assert.Equal("parent", documents[1].ParentId);
            Assert.Equal(documents[0], documents[1].ParentDocument);

            Assert.Equal(1, documents[2].Order);
            Assert.Equal("parent\\second-document\\sub-second-document.txt", documents[2].OutputRelativePath);
            Assert.Equal("parent\\second-document", documents[2].ParentId);
            Assert.Equal(documents[3], documents[2].ParentDocument);

            Assert.Equal(2, documents[3].Order);
            Assert.Equal("parent\\second-document.txt", documents[3].OutputRelativePath);
            Assert.Equal("parent", documents[3].ParentId);
            Assert.Equal(documents[0], documents[3].ParentDocument);

            Assert.Equal(2, documents[4].Order);
            Assert.Equal("parent\\second-document\\another-sub-second-document.txt", documents[4].OutputRelativePath);
            Assert.Equal("parent\\second-document", documents[4].ParentId);
            Assert.Equal(documents[3], documents[4].ParentDocument);

            Assert.Equal(3, documents[5].Order);
            Assert.Equal("parent\\third-document-from-metadata.txt", documents[5].OutputRelativePath);
            Assert.Equal("parent", documents[5].ParentId);
            Assert.Equal(documents[0], documents[5].ParentDocument);
        }
        public void CanOrderUnorderedDocuments()
        {
            var path = Path.GetFullPath(@"data\dated-documents\");

            var command = new LoadDocumentsCommand();
            command.Author = new Author();
            command.DocumentsPath = path;
            command.OutputRootPath = Path.GetFullPath("output");
            command.RenderedExtensions = new[] { "md" };
            command.RootUrl = "http://www.example.com/";
            command.ApplicationUrl = "/foo";
            command.ExecuteAsync().Wait();

            var order = new OrderCommand();
            order.Documents = command.Documents;
            order.Execute();

            Assert.Equal(0, order.Books.Count());
        }
Esempio n. 3
0
        private void Order(Site site)
        {
            using (var capture = Statistics.Current.Start(StatisticTiming.Ordering))
            {
                var order = new OrderCommand();
                order.Documents = site.Documents;
                order.Execute();

                site.Books = order.Books;
            }
        }