48 lines
1.2 KiB
C#
48 lines
1.2 KiB
C#
using StellaOps.TestKit;
|
|
using Xunit;
|
|
|
|
namespace StellaOps.Canonical.Json.Tests;
|
|
|
|
public partial class CanonVersionTests
|
|
{
|
|
[Trait("Category", TestCategories.Unit)]
|
|
[Fact]
|
|
public void IsVersioned_VersionedJson_ReturnsTrue()
|
|
{
|
|
var json = """{"_canonVersion":"stella:canon:v1","foo":"bar"}"""u8;
|
|
Assert.True(CanonVersion.IsVersioned(json));
|
|
}
|
|
|
|
[Trait("Category", TestCategories.Unit)]
|
|
[Fact]
|
|
public void IsVersioned_LegacyJson_ReturnsFalse()
|
|
{
|
|
var json = """{"foo":"bar"}"""u8;
|
|
Assert.False(CanonVersion.IsVersioned(json));
|
|
}
|
|
|
|
[Trait("Category", TestCategories.Unit)]
|
|
[Fact]
|
|
public void IsVersioned_EmptyJson_ReturnsFalse()
|
|
{
|
|
var json = "{}"u8;
|
|
Assert.False(CanonVersion.IsVersioned(json));
|
|
}
|
|
|
|
[Trait("Category", TestCategories.Unit)]
|
|
[Fact]
|
|
public void IsVersioned_TooShort_ReturnsFalse()
|
|
{
|
|
var json = """{"_ca":"v"}"""u8;
|
|
Assert.False(CanonVersion.IsVersioned(json));
|
|
}
|
|
|
|
[Trait("Category", TestCategories.Unit)]
|
|
[Fact]
|
|
public void IsVersioned_WrongFieldName_ReturnsFalse()
|
|
{
|
|
var json = """{"_version":"stella:canon:v1","foo":"bar"}"""u8;
|
|
Assert.False(CanonVersion.IsVersioned(json));
|
|
}
|
|
}
|