public void GetBlog_WithBlogHavingCategories_GetsCategoriesFromSource()
        {
            // arrange
            var categories = new List <LinkCategory> {
                new LinkCategory(1, "Any Title")
            };
            var context = new Mock <ISubtextContext>();

            context.Setup(c => c.Blog).Returns(new Blog());
            context.Setup(c => c.Repository.GetCategories(CategoryType.PostCollection, false /*activeOnly*/)).Returns(categories);
            var blogMLCategories = new List <BlogMLCategory> {
                new BlogMLCategory {
                    Title = "The First Category"
                }
            };
            var converter = new Mock <IBlogMLExportMapper>();

            converter.Setup(c => c.ConvertBlog(It.IsAny <Blog>())).Returns(new BlogMLBlog {
                Title = "Whatever"
            });
            converter.Setup(c => c.ConvertCategories(categories)).Returns(blogMLCategories);
            var source = new BlogMLSource(context.Object, converter.Object);

            // act
            var blogMLBlog = source.GetBlog();

            // assert
            Assert.AreEqual("The First Category", blogMLBlog.Categories[0].Title);
        }
        public void GetBlog_WithBlogInSubtextContext_ConvertsBlogToBlogML()
        {
            // arrange
            var blog = new Blog {
                Title = "Test Blog Title"
            };
            var context = new Mock <ISubtextContext>();

            context.Setup(c => c.Repository.GetCategories(CategoryType.PostCollection, false)).Returns(new List <LinkCategory>());
            context.Setup(c => c.Blog).Returns(blog);
            var converter = new Mock <IBlogMLExportMapper>();

            converter.Setup(c => c.ConvertBlog(blog)).Returns(new BlogMLBlog {
                Title = "Converted"
            });
            var source = new BlogMLSource(context.Object, converter.Object);

            // act
            var blogMLBlog = source.GetBlog();

            // assert
            Assert.AreEqual("Converted", blogMLBlog.Title);
        }