Example #1
0
        public async void Update_post_title_will_not_alter_slug()
        {
            // 1. user writes a post with title
            var title  = "A blog post title";
            var dt     = DateTimeOffset.Now;
            var postId = 1;

            // Very important to setup return null for Post or it'll go into infinite loop
            postRepoMock.Setup(r => r.GetAsync(It.IsAny <string>(), dt.Year, dt.Month, dt.Day))
            .Returns(Task.FromResult((Post)null));

            // 2. user publishes the post
            var slug = await blogPostService.GetBlogPostSlugAsync(title, dt, ECreateOrUpdate.Create, postId);

            // 3. user goes back to update post title
            // NOTE: at the point the existing slug is being passed in
            // See BlogService.PrepPostAsync()
            var theSlug = await blogPostService.GetBlogPostSlugAsync(slug, dt, ECreateOrUpdate.Update, postId);

            Assert.Equal(theSlug, slug);
        }