Skip to content

Added support for Guid values #60

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
13 changes: 13 additions & 0 deletions Liquid.NET.Tests/Utils/LiquidValueConverterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,19 @@ public void It_Should_Covert_A_DateTime()
Assert.That(val.Value, Is.EqualTo(new LiquidDate(dateTime)));
}

[Test]
public void It_Should_Convert_Guid_To_LiquidString()
{
// Act
var testValue = new Guid();
var val = _converter.Convert(testValue);

// Assert
Assert.That(val.HasValue, Is.True);
Assert.That(val.Value, Is.TypeOf<LiquidString>());
Assert.That(val.Value, Is.EqualTo(LiquidString.Create(testValue.ToString("D"))));
}

[Test]
public void It_Should_Convert_Generic_List_To_Collection()
{
Expand Down
6 changes: 6 additions & 0 deletions Liquid.NET/src/Utils/LiquidValueConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,12 @@ private Option<ILiquidValue> FromPrimitive(Object obj)
var val = obj as IDictionary;
return CreateHash(val);
}

var guidVal = obj as Guid?;
if (guidVal.HasValue)
{
return LiquidString.Create(guidVal.Value.ToString("D"));
}
return null;
}

Expand Down