This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
using Ludarium.Application;
|
||||
using Ludarium.Domain;
|
||||
|
||||
namespace Ludarium.UnitTests;
|
||||
|
||||
public sealed class GameDataVaultPolicyTests
|
||||
{
|
||||
[Fact]
|
||||
public void MetadataIsTrimmedAndBounded()
|
||||
{
|
||||
var result = GameDataVaultPolicy.Normalize(new GameDataEntryInput(GameDataKind.Save,
|
||||
" Main slot ", " mGBA ", " Steam Deck ", " Before the final dungeon "));
|
||||
Assert.Equal("Main slot", result.Name);
|
||||
Assert.Equal("mGBA", result.Emulator);
|
||||
Assert.Equal("Steam Deck", result.Device);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("../slot.sav")]
|
||||
[InlineData("folder\\slot.sav")]
|
||||
[InlineData("payload.exe")]
|
||||
[InlineData("script.ps1")]
|
||||
public void UnsafeFileNamesAreRejected(string fileName) =>
|
||||
Assert.Throws<ArgumentException>(() => GameDataVaultPolicy.ValidateFileName(fileName));
|
||||
|
||||
[Fact]
|
||||
public void NormalSaveFileNameIsPreserved() =>
|
||||
Assert.Equal("campaign-slot-1.srm", GameDataVaultPolicy.ValidateFileName("campaign-slot-1.srm"));
|
||||
|
||||
[Fact]
|
||||
public void UnknownKindIsRejected() =>
|
||||
Assert.Throws<ArgumentException>(() => GameDataVaultPolicy.Normalize(
|
||||
new GameDataEntryInput((GameDataKind)999, "Slot", null, null, null)));
|
||||
}
|
||||
Reference in New Issue
Block a user