using XFEWarframe.Client.Runtime;
using XFEWarframe.Mods;
using Xunit;
namespace XFEWarframe.Client.Tests;
public sealed class PetFetchTests
{
[Fact] public void CustomFaceRoundTripsWithoutCollidingWithOriginalFetch()
{
var custom = new NativeCardIdentity(PetFetchMod.Type, "{\"lvl\":5}");
var wire = custom.ToGame(); Assert.Equal(PetFetchMod.Carrier, wire.Type);
Assert.True(PetFetchMod.HasMarker(wire.Fingerprint));
Assert.Equal(custom, NativeCardIdentity.FromGame(wire.Type, wire.Fingerprint));
var original = new NativeCardIdentity(PetFetchMod.Carrier, "{\"lvl\":5}");
Assert.Equal(original, original.ToGame());
Assert.Equal(original, NativeCardIdentity.FromGame(original.Type, original.Fingerprint));
Assert.NotEqual(VisualAssetCache.Key("card-compact", original.Type, original.Fingerprint, "zh"),
VisualAssetCache.Key("card-compact", custom.Type, custom.Fingerprint, "zh"));
}
[Theory]
[InlineData("{\"lvl\":5,\"xfe\":\"FetchOverdrive\"}", true)]
[InlineData("{\"xfe\":\"FetchOverdriveFake\"}", false)]
[InlineData("{\"other\":\"FetchOverdrive\"}", false)]
[InlineData("{\"xfe\":9}", false)]
[InlineData("[]", false)]
[InlineData("invalid", false)]
public void MarkerIsExactAndTyped(string fingerprint, bool enabled) => Assert.Equal(enabled, PetFetchMod.HasMarker(fingerprint));
[Fact] public void UnequippingRestoresNativeRadiusAndPreservesOtherNativeUpdates()
{
var lease = FetchRadiusLease.Capture(13.5f);
Assert.Equal(13.5f, lease.Restore(PetFetchMod.Radius));
Assert.Null(lease.Restore(8.5f));
lease = lease.Observe(PetFetchMod.Radius);
Assert.Equal(13.5f, lease.Original);
lease = lease.Observe(8.5f);
Assert.Equal(8.5f, lease.Restore(PetFetchMod.Radius));
Assert.Throws<ArgumentOutOfRangeException>(() => FetchRadiusLease.Capture(float.NaN));
Assert.Throws<ArgumentOutOfRangeException>(() => FetchRadiusLease.Capture(0));
Assert.Throws<ArgumentOutOfRangeException>(() => FetchRadiusLease.Capture(PetFetchMod.Radius));
}
}
using XFEWarframe.Client.Runtime;
using XFEWarframe.Mods;
using Xunit;
namespace XFEWarframe.Client.Tests;
public sealed class PetFetchTests
{
[Fact] public void CustomFaceRoundTripsWithoutCollidingWithOriginalFetch()
{
var custom = new NativeCardIdentity(PetFetchMod.Type, "{\"lvl\":5}");
var wire = custom.ToGame(); Assert.Equal(PetFetchMod.Carrier, wire.Type);
Assert.True(PetFetchMod.HasMarker(wire.Fingerprint));
Assert.Equal(custom, NativeCardIdentity.FromGame(wire.Type, wire.Fingerprint));
var original = new NativeCardIdentity(PetFetchMod.Carrier, "{\"lvl\":5}");
Assert.Equal(original, original.ToGame());
Assert.Equal(original, NativeCardIdentity.FromGame(original.Type, original.Fingerprint));
Assert.NotEqual(VisualAssetCache.Key("card-compact", original.Type, original.Fingerprint, "zh"),
VisualAssetCache.Key("card-compact", custom.Type, custom.Fingerprint, "zh"));
}
[Theory]
[InlineData("{\"lvl\":5,\"xfe\":\"FetchOverdrive\"}", true)]
[InlineData("{\"xfe\":\"FetchOverdriveFake\"}", false)]
[InlineData("{\"other\":\"FetchOverdrive\"}", false)]
[InlineData("{\"xfe\":9}", false)]
[InlineData("[]", false)]
[InlineData("invalid", false)]
public void MarkerIsExactAndTyped(string fingerprint, bool enabled) => Assert.Equal(enabled, PetFetchMod.HasMarker(fingerprint));
[Fact] public void UnequippingRestoresNativeRadiusAndPreservesOtherNativeUpdates()
{
var lease = FetchRadiusLease.Capture(13.5f);
Assert.Equal(13.5f, lease.Restore(PetFetchMod.Radius));
Assert.Null(lease.Restore(8.5f));
lease = lease.Observe(PetFetchMod.Radius);
Assert.Equal(13.5f, lease.Original);
lease = lease.Observe(8.5f);
Assert.Equal(8.5f, lease.Restore(PetFetchMod.Radius));
Assert.Throws<ArgumentOutOfRangeException>(() => FetchRadiusLease.Capture(float.NaN));
Assert.Throws<ArgumentOutOfRangeException>(() => FetchRadiusLease.Capture(0));
Assert.Throws<ArgumentOutOfRangeException>(() => FetchRadiusLease.Capture(PetFetchMod.Radius));
}
}