Use new API for blog
This commit is contained in:
parent
e389b2404a
commit
25c320bf6b
17 changed files with 356 additions and 314 deletions
|
@ -1,5 +1,4 @@
|
|||
using FluentAssertions;
|
||||
using Website.Data.States;
|
||||
using FluentAssertions;
|
||||
using Website.Models;
|
||||
using Website.ViewModels;
|
||||
using Xunit;
|
||||
|
@ -10,22 +9,16 @@ namespace Website.Tests.VIewModels
|
|||
{
|
||||
[Fact]
|
||||
public void Constructor_WithContentOver1000Characters_LimitsContentTo1000Chars() {
|
||||
var state = new BlogPostState {
|
||||
Post_Content = new string('a', 1001)
|
||||
};
|
||||
var post = new BlogPost(state);
|
||||
var post = new BlogPost {Content = new string('a', 1001)};
|
||||
var vm = new BlogPostSnippetViewModel(post);
|
||||
vm.Content.Length.Should().Be(1000);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Constructor_WithContentUnder1000Characters_ContentIsIdenticalLength() {
|
||||
var state = new BlogPostState {
|
||||
Post_Content = new string('a', 900)
|
||||
};
|
||||
var post = new BlogPost(state);
|
||||
var post = new BlogPost{Content = new string('a', 900)};
|
||||
var vm = new BlogPostSnippetViewModel(post);
|
||||
vm.Content.Length.Should().Be(900);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,55 +1,48 @@
|
|||
using System;
|
||||
using System;
|
||||
using FluentAssertions;
|
||||
using Website.Data.States;
|
||||
using Website.Models;
|
||||
using Website.ViewModels;
|
||||
using Xunit;
|
||||
|
||||
namespace Website.Tests.VIewModels
|
||||
{
|
||||
public class BlogPostViewModelTests
|
||||
{
|
||||
namespace Website.Tests.VIewModels {
|
||||
public class BlogPostViewModelTests {
|
||||
[Fact]
|
||||
public void ContentHtml_WithMarkdownContent_ReturnsHtml() {
|
||||
var state = new BlogPostState {
|
||||
Post_Content="# header"
|
||||
var post = new BlogPost {
|
||||
Content = "# header"
|
||||
};
|
||||
var post = new BlogPost(state);
|
||||
var vm = new BlogPostViewModel(post, false);
|
||||
vm.ContentHtml.Should().Be("<h1>header</h1>");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Timestamp_OnThe1st_IsFriendlyString() {
|
||||
var state = new BlogPostState {
|
||||
Post_Content = "",
|
||||
Post_Timestamp = new DateTime(2018, 10, 01, 15, 1, 25)
|
||||
var post = new BlogPost {
|
||||
Content = "",
|
||||
Timestamp = new DateTime(2018, 10, 01, 15, 1, 25)
|
||||
};
|
||||
var post = new BlogPost(state);
|
||||
var vm = new BlogPostViewModel(post, false);
|
||||
vm.Timestamp.Should().Be("Monday the 1st of October 2018");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Timestamp_OnThe2nd_IsFriendlyString() {
|
||||
var state = new BlogPostState {
|
||||
Post_Content = "",
|
||||
Post_Timestamp = new DateTime(2018, 10, 02, 15, 1, 25)
|
||||
var post = new BlogPost {
|
||||
Content = "",
|
||||
Timestamp = new DateTime(2018, 10, 02, 15, 1, 25)
|
||||
};
|
||||
var post = new BlogPost(state);
|
||||
var vm = new BlogPostViewModel(post, false);
|
||||
vm.Timestamp.Should().Be("Tuesday the 2nd of October 2018");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Timestamp_OnThe3rd_IsFriendlyString() {
|
||||
var state = new BlogPostState {
|
||||
Post_Content = "",
|
||||
Post_Timestamp = new DateTime(2018, 10, 03, 15, 1, 25)
|
||||
var post = new BlogPost {
|
||||
Content = "",
|
||||
Timestamp = new DateTime(2018, 10, 03, 15, 1, 25)
|
||||
};
|
||||
var post = new BlogPost(state);
|
||||
var vm = new BlogPostViewModel(post, false);
|
||||
vm.Timestamp.Should().Be("Wednesday the 3rd of October 2018");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue