-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2f9051b
commit 4d41bda
Showing
9 changed files
with
1,226 additions
and
1,227 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
219 changes: 109 additions & 110 deletions
219
src/Trackyt.Tests/Tests/Helpers/BlogPostsHelperTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,110 +1,109 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using NUnit.Framework; | ||
using Trackyt.Core.DAL.DataModel; | ||
using Web.Helpers; | ||
|
||
namespace Trackyt.Core.Tests.Tests.Helpers | ||
{ | ||
[TestFixture] | ||
public class BlogPostsHelperTests | ||
{ | ||
[Test] | ||
public void GetPreviewPost_WithoutPreviewTag_ReturnPostAsOneParagraph() | ||
{ | ||
// arrange | ||
var blogPost = new BlogPost | ||
{ | ||
Url = "post-url", | ||
Title = "post-title", | ||
Body = @"<p>First.</p><p>Second.</p>", | ||
CreatedBy = "alexanderb" | ||
}; | ||
|
||
// act | ||
var postBody = BlogPostsHelper.GetPreviewPostBody(blogPost); | ||
|
||
// assert | ||
Assert.That(postBody, Is.EqualTo("First. Second.")); | ||
} | ||
|
||
[Test] | ||
public void GetPreviewPost_WithPreviewTag_ReturnPreviewTextAsOneParagraph() | ||
{ | ||
// arrange | ||
var blogPost = new BlogPost | ||
{ | ||
Url = "post-url", | ||
Title = "post-title", | ||
Body = @"<post-preview><p>First from preview.</p><p>Second from preview.</p></post-preview><p>First.</p><p>Second.</p>", | ||
CreatedBy = "alexanderb" | ||
}; | ||
|
||
// act | ||
var postBody = BlogPostsHelper.GetPreviewPostBody(blogPost); | ||
|
||
// assert | ||
Assert.That(postBody, Is.EqualTo("First from preview. Second from preview. <a href=\"blog/posts/post-url\">Read more...</a>")); | ||
} | ||
|
||
[Test] | ||
[ExpectedException(typeof(Exception), ExpectedMessage = "Bad post format: no </post-preview> closing tag.")] | ||
public void GetPreviewPost_WithPreviewOpenedButNotClosed_ExceptionThrown() | ||
{ | ||
// arrange | ||
var blogPost = new BlogPost | ||
{ | ||
Url = "post-url", | ||
Title = "post-title", | ||
Body = @"<post-preview><p>First from preview.</p><p>Second from preview.</p><post-preview><p>First.</p><p>Second.</p>", | ||
CreatedBy = "alexanderb" | ||
}; | ||
|
||
// act | ||
var postBody = BlogPostsHelper.GetPreviewPostBody(blogPost); | ||
|
||
// assert | ||
} | ||
|
||
[Test] | ||
public void GetPostPreview_WithPreviewTag_ReadMoreHrefAdded() | ||
{ | ||
// arrange | ||
var blogPost = new BlogPost | ||
{ | ||
Url = "post-url", | ||
Title = "post-title", | ||
Body = @"<post-preview><p>First from preview.</p><p>Second from preview.</p></post-preview><p>First.</p><p>Second.</p>", | ||
CreatedBy = "alexanderb" | ||
}; | ||
|
||
// act | ||
var postBody = BlogPostsHelper.GetPreviewPostBody(blogPost); | ||
|
||
// assert | ||
Assert.That(postBody, Is.EqualTo("First from preview. Second from preview. <a href=\"blog/posts/post-url\">Read more...</a>")); | ||
} | ||
|
||
[Test] | ||
public void GetPost_WithoutPreviewTag_ReturnsUnmodifiedPost() | ||
{ | ||
// arrange | ||
var blogPost = new BlogPost | ||
{ | ||
Url = "post-url", | ||
Title = "post-title", | ||
Body = @"<p>First.</p><p>Second.</p>", | ||
CreatedBy = "alexanderb" | ||
}; | ||
|
||
// act | ||
var postBody = BlogPostsHelper.GetPostBody(blogPost); | ||
|
||
// assert | ||
Assert.That(postBody, Is.EqualTo("<p>First.</p><p>Second.</p>")); | ||
} | ||
|
||
} | ||
} | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using NUnit.Framework; | ||
using Trackyt.Core.DAL.DataModel; | ||
using Web.Helpers; | ||
|
||
namespace Trackyt.Core.Tests.Tests.Helpers | ||
{ | ||
[TestFixture] | ||
public class BlogPostsHelperTests | ||
{ | ||
[Test] | ||
public void GetPreviewPost_WithoutPreviewTag_ReturnPostAsOneParagraph() | ||
{ | ||
// arrange | ||
var blogPost = new BlogPost | ||
{ | ||
Url = "post-url", | ||
Title = "post-title", | ||
Body = @"<p>First.</p><p>Second.</p>", | ||
CreatedBy = "alexanderb" | ||
}; | ||
|
||
// act | ||
var postBody = BlogPostsHelper.GetPreviewPostBody(blogPost); | ||
|
||
// assert | ||
Assert.That(postBody, Is.EqualTo("First. Second.")); | ||
} | ||
|
||
[Test] | ||
public void GetPreviewPost_WithPreviewTag_ReturnPreviewTextAsOneParagraph() | ||
{ | ||
// arrange | ||
var blogPost = new BlogPost | ||
{ | ||
Url = "post-url", | ||
Title = "post-title", | ||
Body = @"<post-preview><p>First from preview.</p><p>Second from preview.</p></post-preview><p>First.</p><p>Second.</p>", | ||
CreatedBy = "alexanderb" | ||
}; | ||
|
||
// act | ||
var postBody = BlogPostsHelper.GetPreviewPostBody(blogPost); | ||
|
||
// assert | ||
Assert.That(postBody, Is.EqualTo("First from preview. Second from preview. <a href=\"blog/posts/post-url\">Read more...</a>")); | ||
} | ||
|
||
[Test] | ||
[ExpectedException(typeof(Exception), ExpectedMessage = "Bad post format: no </post-preview> closing tag.")] | ||
public void GetPreviewPost_WithPreviewOpenedButNotClosed_ExceptionThrown() | ||
{ | ||
// arrange | ||
var blogPost = new BlogPost | ||
{ | ||
Url = "post-url", | ||
Title = "post-title", | ||
Body = @"<post-preview><p>First from preview.</p><p>Second from preview.</p><post-preview><p>First.</p><p>Second.</p>", | ||
CreatedBy = "alexanderb" | ||
}; | ||
|
||
// act | ||
var postBody = BlogPostsHelper.GetPreviewPostBody(blogPost); | ||
|
||
// assert | ||
} | ||
|
||
[Test] | ||
public void GetPostPreview_WithPreviewTag_ReadMoreHrefAdded() | ||
{ | ||
// arrange | ||
var blogPost = new BlogPost | ||
{ | ||
Url = "post-url", | ||
Title = "post-title", | ||
Body = @"<post-preview><p>First from preview.</p><p>Second from preview.</p></post-preview><p>First.</p><p>Second.</p>", | ||
CreatedBy = "alexanderb" | ||
}; | ||
|
||
// act | ||
var postBody = BlogPostsHelper.GetPreviewPostBody(blogPost); | ||
|
||
// assert | ||
Assert.That(postBody, Is.EqualTo("First from preview. Second from preview. <a href=\"blog/posts/post-url\">Read more...</a>")); | ||
} | ||
|
||
[Test] | ||
public void GetPost_WithoutPreviewTag_ReturnsUnmodifiedPost() | ||
{ | ||
// arrange | ||
var blogPost = new BlogPost | ||
{ | ||
Url = "post-url", | ||
Title = "post-title", | ||
Body = @"<p>First.</p><p>Second.</p>", | ||
CreatedBy = "alexanderb" | ||
}; | ||
|
||
// act | ||
var postBody = BlogPostsHelper.GetPostBody(blogPost); | ||
|
||
// assert | ||
Assert.That(postBody, Is.EqualTo("<p>First.</p><p>Second.</p>")); | ||
} | ||
} | ||
} |
Oops, something went wrong.