LibHac/tests/LibHac.Tests/Fs/FsaTests/MultiCommitTests.cs

63 lines
1.8 KiB
C#
Raw Normal View History

using System.Collections.Generic;
using LibHac.Common;
using LibHac.Fs;
using LibHac.Fs.Fsa;
using LibHac.Fs.Shim;
using LibHac.Tests.Fs.FileSystemClientTests;
using Xunit;
using static LibHac.Fs.SaveData;
2021-11-14 20:08:57 +01:00
namespace LibHac.Tests.Fs.FsaTests;
public class MultiCommitTests
{
2021-11-14 20:08:57 +01:00
[Fact]
public void Commit_MultipleFileSystems_AllFileSystemsAreCommitted()
{
2021-11-14 20:08:57 +01:00
FileSystemClient fs = FileSystemServerFactory.CreateClient(true);
2021-11-14 20:08:57 +01:00
var saveInfo = new List<(int id, string name)>
{
(1, "Save1"),
(3, "Save2"),
(2, "Save3")
};
2021-11-14 20:08:57 +01:00
foreach ((int id, string name) info in saveInfo)
{
var applicationId = new Ncm.ApplicationId((uint)info.id);
fs.CreateSaveData(applicationId, InvalidUserId, 0, 0x4000, 0x4000, SaveDataFlags.None);
fs.MountSaveData(info.name.ToU8Span(), applicationId, InvalidUserId);
2021-11-14 20:08:57 +01:00
}
2021-11-14 20:08:57 +01:00
foreach ((int id, string name) info in saveInfo)
{
fs.CreateFile($"{info.name}:/file{info.id}".ToU8Span(), 0);
}
2021-11-14 20:08:57 +01:00
var names = new List<U8String>();
2021-11-14 20:08:57 +01:00
foreach ((int id, string name) info in saveInfo)
{
names.Add(info.name.ToU8String());
}
2021-11-14 20:08:57 +01:00
Assert.Success(fs.Commit(names.ToArray()));
2021-11-14 20:08:57 +01:00
foreach ((int id, string name) info in saveInfo)
{
fs.Unmount(info.name.ToU8Span());
}
2021-11-14 20:08:57 +01:00
foreach ((int id, string name) info in saveInfo)
{
var applicationId = new Ncm.ApplicationId((uint)info.id);
fs.MountSaveData(info.name.ToU8Span(), applicationId, InvalidUserId);
2021-11-14 20:08:57 +01:00
}
2021-11-14 20:08:57 +01:00
foreach ((int id, string name) info in saveInfo)
{
Assert.Success(fs.GetEntryType(out _, $"{info.name}:/file{info.id}".ToU8Span()));
}
}
}