2020-11-01 10:41:51 +01:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using LibHac.Common;
|
|
|
|
|
using LibHac.Fs;
|
2021-02-21 08:00:59 +01:00
|
|
|
|
using LibHac.Fs.Fsa;
|
2020-11-01 10:41:51 +01:00
|
|
|
|
using LibHac.Fs.Shim;
|
|
|
|
|
using LibHac.Tests.Fs.FileSystemClientTests;
|
|
|
|
|
using Xunit;
|
2022-01-24 23:02:32 +01:00
|
|
|
|
using static LibHac.Fs.SaveData;
|
|
|
|
|
|
2021-11-14 20:08:57 +01:00
|
|
|
|
namespace LibHac.Tests.Fs.FsaTests;
|
|
|
|
|
|
|
|
|
|
public class MultiCommitTests
|
2020-11-01 10:41:51 +01:00
|
|
|
|
{
|
2021-11-14 20:08:57 +01:00
|
|
|
|
[Fact]
|
|
|
|
|
public void Commit_MultipleFileSystems_AllFileSystemsAreCommitted()
|
2020-11-01 10:41:51 +01:00
|
|
|
|
{
|
2021-11-14 20:08:57 +01:00
|
|
|
|
FileSystemClient fs = FileSystemServerFactory.CreateClient(true);
|
2020-11-01 10:41:51 +01:00
|
|
|
|
|
2021-11-14 20:08:57 +01:00
|
|
|
|
var saveInfo = new List<(int id, string name)>
|
2022-11-12 02:21:07 +01:00
|
|
|
|
{
|
|
|
|
|
(1, "Save1"),
|
|
|
|
|
(3, "Save2"),
|
|
|
|
|
(2, "Save3")
|
|
|
|
|
};
|
2020-11-01 10:41:51 +01:00
|
|
|
|
|
2021-11-14 20:08:57 +01:00
|
|
|
|
foreach ((int id, string name) info in saveInfo)
|
|
|
|
|
{
|
|
|
|
|
var applicationId = new Ncm.ApplicationId((uint)info.id);
|
2022-01-24 23:02:32 +01:00
|
|
|
|
fs.CreateSaveData(applicationId, InvalidUserId, 0, 0x4000, 0x4000, SaveDataFlags.None);
|
|
|
|
|
fs.MountSaveData(info.name.ToU8Span(), applicationId, InvalidUserId);
|
2021-11-14 20:08:57 +01:00
|
|
|
|
}
|
2020-11-01 10:41:51 +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);
|
|
|
|
|
}
|
2020-11-01 10:41:51 +01:00
|
|
|
|
|
2021-11-14 20:08:57 +01:00
|
|
|
|
var names = new List<U8String>();
|
2020-11-01 10:41:51 +01:00
|
|
|
|
|
2021-11-14 20:08:57 +01:00
|
|
|
|
foreach ((int id, string name) info in saveInfo)
|
|
|
|
|
{
|
|
|
|
|
names.Add(info.name.ToU8String());
|
|
|
|
|
}
|
2020-11-01 10:41:51 +01:00
|
|
|
|
|
2021-11-14 20:08:57 +01:00
|
|
|
|
Assert.Success(fs.Commit(names.ToArray()));
|
2020-11-01 10:41:51 +01:00
|
|
|
|
|
2021-11-14 20:08:57 +01:00
|
|
|
|
foreach ((int id, string name) info in saveInfo)
|
|
|
|
|
{
|
|
|
|
|
fs.Unmount(info.name.ToU8Span());
|
|
|
|
|
}
|
2020-11-01 10:41:51 +01:00
|
|
|
|
|
2021-11-14 20:08:57 +01:00
|
|
|
|
foreach ((int id, string name) info in saveInfo)
|
|
|
|
|
{
|
|
|
|
|
var applicationId = new Ncm.ApplicationId((uint)info.id);
|
2022-01-24 23:02:32 +01:00
|
|
|
|
fs.MountSaveData(info.name.ToU8Span(), applicationId, InvalidUserId);
|
2021-11-14 20:08:57 +01:00
|
|
|
|
}
|
2020-11-01 10:41:51 +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()));
|
2020-11-01 10:41:51 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
2022-01-24 23:02:32 +01:00
|
|
|
|
}
|