mfgames-cil/tests/MfGames.Nitride.Json.Tests/TextContentJsonTests.cs
D. Moonfire ba75ffd766
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
refactor: code cleanup
2023-07-22 13:36:30 -05:00

52 lines
1 KiB
C#

using MfGames.Gallium;
using MfGames.Nitride.Tests;
using Xunit;
using Xunit.Abstractions;
namespace MfGames.Nitride.Json.Tests;
public class TextContentJsonTests : NitrideTestBase
{
public TextContentJsonTests(ITestOutputHelper output)
: base(output)
{
}
[Fact]
public void NoTextContent()
{
Entity entity = new();
TestContent? output = entity.GetTextContentJson<TestContent>();
Assert.Null(output);
}
[Fact]
public void SetAndGetContent()
{
Entity entity = new Entity()
.SetTextContentJson(new TestContent { Value = "t1" });
TestContent? output = entity.GetTextContentJson<TestContent>();
Assert.NotNull(output);
Assert.Equal("t1", output.Value);
}
[Fact]
public void SetNullRemovesContent()
{
Entity entity = new Entity()
.SetTextContentJson(new TestContent { Value = "t1" })
.SetTextContentJson<TestContent>(null);
TestContent? output = entity.GetTextContentJson<TestContent>();
Assert.Null(output);
}
private class TestContent
{
public string? Value { get; set; }
}
}