forked from andrewdavey/cassette
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
InlineHtmlTemplateRenderer includes custom HtmlAttributes from bundle.
- Loading branch information
1 parent
3233908
commit 2743e6d
Showing
6 changed files
with
122 additions
and
14 deletions.
There are no files selected for viewing
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
54 changes: 54 additions & 0 deletions
54
src/Cassette.UnitTests/HtmlTemplates/InlineHtmlTemplateRenderer.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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using System; | ||
using Cassette.Utilities; | ||
using Moq; | ||
using Should; | ||
using Xunit; | ||
|
||
namespace Cassette.HtmlTemplates | ||
{ | ||
public class InlineHtmlTemplateRenderer_Tests | ||
{ | ||
readonly InlineHtmlTemplateBundleRenderer render; | ||
|
||
public InlineHtmlTemplateRenderer_Tests() | ||
{ | ||
render = new InlineHtmlTemplateBundleRenderer(); | ||
} | ||
|
||
[Fact] | ||
public void GivenHtmlTemplateBundleWithNoAssets_WhenRender_ThenReturnEmptyString() | ||
{ | ||
var bundle = new HtmlTemplateBundle("~"); | ||
var html = render.Render(bundle); | ||
html.ShouldEqual(""); | ||
} | ||
|
||
[Fact] | ||
public void GivenHtmlTemplateBundleWithOneAsset_WhenRender_ThenReturnsAssetsOpenStreamResult() | ||
{ | ||
var bundle = new HtmlTemplateBundle("~"); | ||
bundle.Assets.Add(StubAsset("content")); | ||
|
||
var html = render.Render(bundle); | ||
html.ShouldEqual("content"); | ||
} | ||
|
||
[Fact] | ||
public void GivenHtmlTemplateBundleWithTwoAssets_WhenRender_ThenReturnsEachAssetsOpenStreamResultSeparatedByNewLine() | ||
{ | ||
var bundle = new HtmlTemplateBundle("~"); | ||
bundle.Assets.Add(StubAsset("content1")); | ||
bundle.Assets.Add(StubAsset("content2")); | ||
|
||
var html = render.Render(bundle); | ||
html.ShouldEqual("content1" + Environment.NewLine + "content2"); | ||
} | ||
|
||
IAsset StubAsset(string content) | ||
{ | ||
var asset = new Mock<IAsset>(); | ||
asset.Setup(a => a.OpenStream()).Returns(content.AsStream()); | ||
return asset.Object; | ||
} | ||
} | ||
} |
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
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 |
---|---|---|
|
@@ -14,4 +14,4 @@ public string Render(HtmlTemplateBundle bundle) | |
); | ||
} | ||
} | ||
} | ||
} |
3 changes: 1 addition & 2 deletions
3
src/Cassette/HtmlTemplates/RemoteHtmlTemplateBundleRenderer.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
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