42 lines
No EOL
1.1 KiB
C#
42 lines
No EOL
1.1 KiB
C#
using FluentAssertions;
|
|
using Website.Models;
|
|
using Xunit;
|
|
|
|
namespace Website.Tests.Models {
|
|
public class BlogPostTests {
|
|
[Fact]
|
|
public void UpdateTitle_WithNewTitle_UpdatesTitlePropertyAndRegeneratesUrl() {
|
|
var post = new BlogPost();
|
|
post.UpdateTitle("new title");
|
|
|
|
post.Title.Should().Be("new title");
|
|
post.Url.Should().Be("new-title");
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData("new:title", "new-title")]
|
|
[InlineData("new: title", "new-title")]
|
|
[InlineData("new$title", "new-title")]
|
|
[InlineData("new TITle", "new-title")]
|
|
public void UpdateTitle_WithUnsafeCharsInTitle_RegeneratesSafeUrl(string title, string url) {
|
|
var post = new BlogPost();
|
|
post.UpdateTitle(title);
|
|
post.Url.Should().Be(url);
|
|
}
|
|
|
|
[Fact]
|
|
public void UpdateDraft_WithContent_UpdatesDraftProperty() {
|
|
var post = new BlogPost();
|
|
post.UpdateDraft("content");
|
|
post.Draft.Should().Be("content");
|
|
}
|
|
|
|
[Fact]
|
|
public void Publish_SetsContentToDraft() {
|
|
var post = new BlogPost();
|
|
post.UpdateDraft("content");
|
|
post.Publish();
|
|
post.Content.Should().Be("content");
|
|
}
|
|
}
|
|
} |