From 33427169956e866dee2a139170a0f5c3cbb6ce8c Mon Sep 17 00:00:00 2001 From: Vlad Sandu Date: Sun, 23 Jun 2019 18:14:12 +0300 Subject: [PATCH] Add support for unsigned integral data types --- Mustachio.Tests/TemplateFixture.cs | 13 ++++++++++++- Mustachio/ContextObject.cs | 8 +++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/Mustachio.Tests/TemplateFixture.cs b/Mustachio.Tests/TemplateFixture.cs index 9a88b5b..6d4c1d9 100644 --- a/Mustachio.Tests/TemplateFixture.cs +++ b/Mustachio.Tests/TemplateFixture.cs @@ -9,7 +9,7 @@ namespace Mustachio.Tests { public class TemplateFixture { - + [Fact] public void TemplateRendersContentWithNoVariables() { @@ -71,6 +71,17 @@ public void NegationGroupRendersContentWhenValueNotSet() Assert.Equal("No Stuff Here.", rendered); } + [Fact] + public void UnsignedIntegralTypeModelVariablesAreSupported() + { + var model = new Dictionary(){ + {"uint", (uint)123}, + {"ushort", (ushort)234}, + {"ulong", (ulong)18446744073709551615} // max ulong + }; + + Assert.Equal("123;234;18446744073709551615", Parser.Parse("{{uint}};{{ushort}};{{ulong}}")(model)); + } [Fact] public void TemplateRendersWithComplextEachPath() diff --git a/Mustachio/ContextObject.cs b/Mustachio/ContextObject.cs index 8c10604..cbff73d 100644 --- a/Mustachio/ContextObject.cs +++ b/Mustachio/ContextObject.cs @@ -100,6 +100,9 @@ public bool Exists() typeof(byte), typeof(sbyte), typeof(decimal), + typeof(uint), + typeof(ushort), + typeof(ulong), typeof(int?), typeof(bool?), typeof(double?), @@ -109,7 +112,10 @@ public bool Exists() typeof(long?), typeof(byte?), typeof(sbyte?), - typeof(decimal?) + typeof(decimal?), + typeof(uint?), + typeof(ushort?), + typeof(ulong?) }; public override string ToString()