Esempio n. 1
0
        public void CreateCategories_WithBlogHavingNoCategories_DoesNotCreateCategories()
        {
            // arrange
            var context = new Mock <ISubtextContext>();

            context.Setup(c => c.Blog).Returns(new Blog {
                Id = 123
            });
            context.Setup(c => c.Repository.CreateLinkCategory(It.IsAny <LinkCategory>())).Throws(new InvalidOperationException());
            var blog       = new BlogMLBlog();
            var repository = new BlogImportRepository(context.Object, null, null, new BlogMLImportMapper());

            // act, assert
            repository.CreateCategories(blog);
        }
Esempio n. 2
0
        public void CreateCategories_WithBlogHavingCategories_CreatesCategories()
        {
            // arrange
            var context = new Mock <ISubtextContext>();

            context.Setup(c => c.Blog).Returns(new Blog {
                Id = 123
            });
            bool categoryCreated = false;

            context.Setup(c => c.Repository.CreateLinkCategory(It.IsAny <LinkCategory>())).Callback(() => categoryCreated = true);
            var blog = new BlogMLBlog();

            blog.Categories.Add(new BlogMLCategory {
                Title = "Category Title", ID = "123"
            });
            var repository = new BlogImportRepository(context.Object, null, null, new BlogMLImportMapper());

            // act
            repository.CreateCategories(blog);

            // assert
            Assert.IsTrue(categoryCreated);
        }