Skip to content

Commit

Permalink
Added Enum test
Browse files Browse the repository at this point in the history
  • Loading branch information
taks committed Jul 11, 2023
1 parent 9c71992 commit 3995a66
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/Tomlyn.Tests/ModelTests/ReflectionModelTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,28 @@ private class TestConfigWithUri
public Uri? ServiceUri { get; set; }
}

[Test]
public void TestEnum()
{
var text = @$"enum_value = ""EnumValue1""";
var result = Toml.ToModel<TestConfigWithEnum>(text);
Assert.AreEqual(EnumType.EnumValue1, result.EnumValue);

var tomlText = Toml.FromModel(result);
Assert.AreEqual(text, tomlText.TrimEnd());
}

private enum EnumType
{
EnumValue0,
EnumValue1,
}

private class TestConfigWithEnum
{
public EnumType EnumValue { get; set; }
}

/// <summary>
/// Serialize back and forth all integer/float primitives.
/// </summary>
Expand Down

0 comments on commit 3995a66

Please sign in to comment.