public async void Author_Can_Publish_BlogPost_From_Browser()
        {
            // Arrange
            SeedTestPost();
            var createdOn = DateTimeOffset.Now; // user local time
            var blogPost  = new BlogPost        // A user posts this from browser
            {
                UserId        = Actor.AUTHOR_ID,
                Title         = "Hello World!",
                Slug          = null,               // user didn't input
                Body          = "This is my first post",
                Excerpt       = null,               // user didn't input
                CategoryId    = 1,
                TagTitles     = null,               // user didn't input
                CreatedOn     = createdOn,
                Status        = EPostStatus.Published,
                CommentStatus = ECommentStatus.AllowComments,
            };

            // Act
            var result = await _blogSvc.CreatePostAsync(blogPost);

            // Assert
            Assert.Equal(2, result.Id);
            Assert.Equal("hello-world", result.Slug);
            Assert.Equal(createdOn.ToUniversalTime(), result.CreatedOn);
            Assert.Equal(1, result.Category.Id);
            Assert.Empty(result.Tags);
        }
        public async void Admin_Can_Save_Draft_With_Empty_Title_And_Slug()
        {
            // Arrange
            SeedTestPost();
            var createdOn = DateTimeOffset.Now; // user local time
            var blogPost  = new BlogPost        // A user posts this from browser
            {
                UserId        = Actor.ADMIN_ID,
                Title         = null,
                Slug          = null,               // user didn't input
                Body          = "This is my first post",
                Excerpt       = null,               // user didn't input
                CategoryId    = 1,
                TagTitles     = null,               // user didn't input
                CreatedOn     = createdOn,
                Status        = EPostStatus.Draft,
                CommentStatus = ECommentStatus.AllowComments,
            };

            // Act
            var result = await _blogSvc.CreateAsync(blogPost);

            // Assert
            Assert.Equal(2, result.Id);
            Assert.Null(result.Slug);
            Assert.Null(result.Title);
            Assert.Equal(createdOn.ToUniversalTime(), result.CreatedOn);
            Assert.Equal(1, result.Category.Id);
            Assert.Empty(result.Tags);
        }
        public async void Admin_Can_Publish_BlogPost_From_Browser()
        {
            // Arrange
            SeedTestPost();
            var createdOn = DateTimeOffset.Now; // user local time
            var blogPost  = new BlogPost        // A user posts this from browser
            {
                UserId     = Actor.ADMIN_ID,
                Title      = "Hello World!",
                Slug       = null,                  // user didn't input
                Body       = "This is my first post",
                Excerpt    = null,                  // user didn't input
                CategoryId = 1,
                TagTitles  = new List <string> {
                    "test", TAG2_TITLE
                },
                //TagTitles = null,                   // user didn't input
                CreatedOn     = createdOn,
                Status        = EPostStatus.Published,
                CommentStatus = ECommentStatus.AllowComments,
            };

            // Act
            var result = await _blogSvc.CreateAsync(blogPost);

            var tags = await _tagSvc.GetAllAsync();

            // Assert
            Assert.Equal(2, result.Id);
            Assert.Equal("hello-world", result.Slug);
            Assert.Equal(createdOn.ToUniversalTime(), result.CreatedOn);
            Assert.Equal(1, result.Category.Id);
            Assert.Equal(2, result.Tags.Count);
            Assert.Contains(result.Tags, t => t.Title.Equals("test"));
            Assert.Equal(3, tags.Count);                                  // there are now 3 tags
            Assert.Equal(2, tags.Find(t => t.Title == TAG2_TITLE).Count); // C# has 2 posts
            Assert.Equal(1, tags.Find(t => t.Title == "test").Count);     // test has 1 post
        }
        public async void Visitor_Views_BlogPost_Date_In_Humanized_String()
        {
            // Arrange
            SeedTestPost();
            var blogPost = new BlogPost // A user posts this from browser
            {
                UserId        = Actor.AUTHOR_ID,
                Title         = "Hello World!",
                Slug          = null,               // user didn't input
                Body          = "This is my first post",
                Excerpt       = null,               // user didn't input
                CategoryId    = 1,
                TagTitles     = null,               // user didn't input
                Status        = EPostStatus.Published,
                CommentStatus = ECommentStatus.AllowComments,
                CreatedOn     = DateTimeOffset.Now  // user local time
            };

            // Act
            var postNow = await _blogSvc.CreatePostAsync(blogPost);

            // Assert
            Assert.Equal("now", postNow.CreatedOnFriendly);
        }