public void after_creating_new_blog_blogs_count_in_db_equals_one()
        {
            var testBlogTitle = "test blog title";

            var count = new BlogRepository().GetBlogsCount();
            Assert.AreEqual(0, count);

            new BlogRepository().CreateBlog(GetSampleBlog(testBlogTitle));

            count = new BlogRepository().GetBlogsCount();
            Assert.AreEqual(1, count);
        }
        public void should_be_able_to_add_and_read_blog_from_database()
        {
            var blogRepository = new BlogRepository();

            var testBlogTitle = "test blog title";
            var blogToCreate = GetSampleBlog(testBlogTitle);

            var blogCreated = blogRepository.CreateBlog(blogToCreate);
            var blogToTest = blogRepository.GetBlogById(blogCreated.Id);

            Assert.NotNull(blogToTest);
            Assert.AreEqual(testBlogTitle, blogToTest.Title);
            Assert.GreaterOrEqual(blogToTest.Id, 1);
        }
        public void can_get_default_blog()
        {
            var blogRepository = new BlogRepository();

            var testBlogTitle = "test blog title";
            var blogToCreate = GetSampleBlog(testBlogTitle);

            var blogCreated = blogRepository.CreateBlog(blogToCreate);
            var blogToTest = blogRepository.GetDefaultBlog();

            Assert.NotNull(blogToTest);
            Assert.AreEqual(blogCreated.Title, blogToTest.Title);
            Assert.AreEqual(blogCreated.Id, blogToTest.Id);
        }
        public void when_db_empty_default_blog_is_null()
        {
            var blogRepository = new BlogRepository();

            var blogToTest = blogRepository.GetDefaultBlog();

            Assert.Null(blogToTest);
        }
Beispiel #5
0
 public BlogService()
 {
     _blogRepository = new BlogRepository();
 }