示例#1
0
        public void UpdatePost_PublishedToDraft_TitleIsUpdated_DoNotUpdateSlug()
        {
            var testDataStore    = new BlogDataStore(new FakeFileSystem());
            var slugGenerator    = new SlugGenerator(testDataStore);
            var excerptGenerator = new ExcerptGenerator(140);

            var post = new Post {
                Title    = "Title",
                Slug     = "Title",
                IsPublic = true,
            };

            testDataStore.SavePost(post);

            var testEditModel = new EditModel(testDataStore, slugGenerator, excerptGenerator);

            testEditModel.PageContext = new PageContext();
            testEditModel.EditedPost  = new EditModel.EditedPostModel {
                Title   = "Edited Title",
                Excerpt = "Excerpt",
            };

            testEditModel.OnPostSaveDraft(post.Id.ToString("N"));

            post = testDataStore.GetPost(post.Id.ToString("N"));

            Assert.Equal("Title", post.Slug);
        }