2022-09-06 05:53:22 +00:00
|
|
|
using MfGames.Gallium;
|
2022-06-05 18:44:51 +00:00
|
|
|
|
2022-09-06 05:53:22 +00:00
|
|
|
using MfGames.Nitride.Contents;
|
2022-06-05 18:44:51 +00:00
|
|
|
|
|
|
|
using Xunit;
|
|
|
|
using Xunit.Abstractions;
|
|
|
|
|
2022-09-06 05:53:22 +00:00
|
|
|
namespace MfGames.Nitride.Tests;
|
2022-06-05 18:44:51 +00:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Tests the various functionality of the high-level content methods and
|
|
|
|
/// extension methods.
|
|
|
|
/// </summary>
|
|
|
|
public class EntityContentTest : NitrideTestBase
|
|
|
|
{
|
|
|
|
public EntityContentTest(ITestOutputHelper output)
|
|
|
|
: base(output)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
public void AddBinaryContent()
|
|
|
|
{
|
|
|
|
var content = new ByteArrayBinaryContent(new byte[0]);
|
|
|
|
Entity entity = new Entity().SetBinaryContent(content);
|
|
|
|
|
|
|
|
Assert.Equal(1, entity.Count);
|
|
|
|
Assert.True(entity.HasContent());
|
|
|
|
Assert.True(entity.HasBinaryContent());
|
|
|
|
Assert.False(entity.HasTextContent());
|
|
|
|
}
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
public void AddTextContent()
|
|
|
|
{
|
|
|
|
var content = new StringTextContent("contents");
|
|
|
|
Entity entity = new Entity().SetTextContent(content);
|
|
|
|
|
|
|
|
Assert.Equal(1, entity.Count);
|
|
|
|
Assert.True(entity.HasContent());
|
|
|
|
Assert.False(entity.HasBinaryContent());
|
|
|
|
Assert.True(entity.HasTextContent());
|
|
|
|
}
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
public void SwitchBinaryToTextContent()
|
|
|
|
{
|
|
|
|
var binaryContent = new ByteArrayBinaryContent(new byte[0]);
|
|
|
|
var textContent = new StringTextContent("contents");
|
2022-07-09 04:52:10 +00:00
|
|
|
|
|
|
|
Entity entity = new Entity().SetBinaryContent(binaryContent)
|
|
|
|
.SetTextContent(textContent);
|
2022-06-05 18:44:51 +00:00
|
|
|
|
|
|
|
Assert.Equal(1, entity.Count);
|
|
|
|
Assert.True(entity.HasContent());
|
|
|
|
Assert.False(entity.HasBinaryContent());
|
|
|
|
Assert.True(entity.HasTextContent());
|
|
|
|
}
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
public void SwitchTextToBinaryContent()
|
|
|
|
{
|
|
|
|
var binaryContent = new ByteArrayBinaryContent(new byte[0]);
|
|
|
|
var textContent = new StringTextContent("contents");
|
2022-07-09 04:52:10 +00:00
|
|
|
|
|
|
|
Entity entity = new Entity().SetContent<ITextContent>(textContent)
|
|
|
|
.SetContent<IBinaryContent>(binaryContent);
|
2022-06-05 18:44:51 +00:00
|
|
|
|
|
|
|
Assert.Equal(1, entity.Count);
|
|
|
|
Assert.True(entity.HasContent());
|
|
|
|
Assert.True(entity.HasBinaryContent());
|
|
|
|
Assert.False(entity.HasTextContent());
|
|
|
|
}
|
|
|
|
}
|