Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions source/Handlebars.Test/IssueTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,42 @@ public void UnrecognisedExpressionThrowsOutOfMemoryException()
Assert.Throws<HandlebarsCompilerException>(()=> Handlebars.Compile(source));
}

// Issue: https://github.com/Handlebars-Net/Handlebars.Net/issues/521
// Hashtable with an uppercase key should be accessible using the same-cased expression.
// The IDictionary accessor was incorrectly lowercasing the lookup key.
[Fact]
public void HashtableUppercaseKeyResolvesWithMatchingExpression()
{
var template = Handlebars.Compile("Hello {{NAME}}");
var result = template(new Hashtable { { "NAME", "alice" } });
Assert.Equal("Hello alice", result);
}

[Fact]
public void HashtableLowercaseKeyStillResolves()
{
var template = Handlebars.Compile("Hello {{name}}");
var result = template(new Hashtable { { "name", "bob" } });
Assert.Equal("Hello bob", result);
}

[Fact]
public void GenericDictionaryUppercaseKeyUnchanged()
{
var template = Handlebars.Compile("Hello {{NAME}}");
var result = template(new Dictionary<string, string> { { "NAME", "charlie" } });
Assert.Equal("Hello charlie", result);
}

[Fact]
public void HashtableLookupIsCaseSensitive()
{
// {{name}} should NOT resolve a key "NAME" — JS objects are case-sensitive
var template = Handlebars.Compile("Hello {{name}}");
var result = template(new Hashtable { { "NAME", "dave" } });
Assert.Equal("Hello ", result);
}

// Issue: https://github.com/Handlebars-Net/Handlebars.Net/issues/605
// #if not evaluated when variable name contains invisible characters (BOM)
[Fact]
Expand Down
Loading