Skip to content
This repository has been archived by the owner on Dec 19, 2018. It is now read-only.

Commit

Permalink
Addressed feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
ajaybhargavb committed Apr 17, 2017
1 parent 9e06e0e commit 9378055
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,53 @@ public void WriteSetTagHelperProperty_NonStringAttribute_RendersCorrectly()
@"#line 3 ""test.cshtml""
__InputTagHelper.FooProp = 42;
#line default
#line hidden
",
csharp,
ignoreLineEndingDifferences: true);
}

[Fact]
public void WriteSetTagHelperProperty_IndexerAttribute_RendersCorrectly()
{
// Arrange
var descriptors = new[]
{
CreateTagHelperDescriptor(
tagName: "input",
typeName: "InputTagHelper",
assemblyName: "TestAssembly",
attributes: new Action<ITagHelperBoundAttributeDescriptorBuilder>[]
{
builder => builder
.Name("bound")
.PropertyName("FooProp")
.TypeName("System.Collections.Generic.Dictionary<System.String, System.Int32>")
.AsDictionary("foo-", "System.Int32"),
})
};
var engine = RazorEngine.Create(builder => builder.AddTagHelpers(descriptors));
var content = @"
@addTagHelper *, TestAssembly
<input foo-bound=""42"" />";
var sourceDocument = TestRazorSourceDocument.Create(content);
var codeDocument = RazorCodeDocument.Create(sourceDocument);
var irDocument = Lower(codeDocument, engine);
var node = irDocument.Children.Last().Children[2] as SetTagHelperPropertyIRNode;

var writer = new DesignTimeTagHelperWriter();
var context = GetCSharpRenderingContext(writer, codeDocument);

// Act
writer.WriteSetTagHelperProperty(context, node);

// Assert
var csharp = context.Writer.Builder.ToString();
Assert.Equal(
@"#line 3 ""test.cshtml""
__InputTagHelper.FooProp[""bound""] = 42;
#line default
#line hidden
",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,8 @@ public void WriteSetTagHelperProperty_RendersCorrectly()

// Assert
var csharp = context.Writer.Builder.ToString();

// The attribute value is not rendered inline because we are not using the preallocated writer.
Assert.Equal(
@"BeginWriteTagHelperAttribute();
Render Children
Expand Down

0 comments on commit 9378055

Please sign in to comment.