2020-02-14 01:21:24 +01:00
|
|
|
|
using LibHac.Common;
|
|
|
|
|
using LibHac.Fs;
|
2020-06-10 07:55:59 +02:00
|
|
|
|
using LibHac.Fs.Fsa;
|
2020-02-14 01:21:24 +01:00
|
|
|
|
using LibHac.Fs.Shim;
|
|
|
|
|
using Xunit;
|
|
|
|
|
|
2021-11-14 20:08:57 +01:00
|
|
|
|
namespace LibHac.Tests.Fs.FileSystemClientTests.ShimTests;
|
|
|
|
|
|
|
|
|
|
public class SdCard
|
2020-02-14 01:21:24 +01:00
|
|
|
|
{
|
2021-11-14 20:08:57 +01:00
|
|
|
|
[Fact]
|
|
|
|
|
public void MountSdCard_CardIsInserted_Succeeds()
|
2020-02-14 01:21:24 +01:00
|
|
|
|
{
|
2021-11-14 20:08:57 +01:00
|
|
|
|
FileSystemClient fs = FileSystemServerFactory.CreateClient(true);
|
2020-02-14 01:21:24 +01:00
|
|
|
|
|
2021-11-14 20:08:57 +01:00
|
|
|
|
Assert.Success(fs.MountSdCard("sdcard".ToU8Span()));
|
|
|
|
|
}
|
2020-02-14 01:21:24 +01:00
|
|
|
|
|
2021-11-14 20:08:57 +01:00
|
|
|
|
[Fact]
|
|
|
|
|
public void MountSdCard_CardIsNotInserted_Fails()
|
|
|
|
|
{
|
|
|
|
|
FileSystemClient fs = FileSystemServerFactory.CreateClient(false);
|
2020-02-14 01:21:24 +01:00
|
|
|
|
|
2021-11-14 20:08:57 +01:00
|
|
|
|
Assert.Result(ResultFs.PortSdCardNoDevice, fs.MountSdCard("sdcard".ToU8Span()));
|
|
|
|
|
}
|
2020-02-14 01:21:24 +01:00
|
|
|
|
|
2021-11-14 20:08:57 +01:00
|
|
|
|
[Fact]
|
|
|
|
|
public void MountSdCard_CanWriteToFsAfterMounted()
|
|
|
|
|
{
|
|
|
|
|
FileSystemClient fs = FileSystemServerFactory.CreateClient(true);
|
2020-02-14 01:21:24 +01:00
|
|
|
|
|
2021-11-14 20:08:57 +01:00
|
|
|
|
fs.MountSdCard("sdcard".ToU8String());
|
2020-02-14 01:21:24 +01:00
|
|
|
|
|
2021-11-14 20:08:57 +01:00
|
|
|
|
Assert.Success(fs.CreateFile("sdcard:/file".ToU8Span(), 100, CreateFileOptions.None));
|
|
|
|
|
}
|
2020-02-14 01:21:24 +01:00
|
|
|
|
|
2021-11-14 20:08:57 +01:00
|
|
|
|
[Fact]
|
|
|
|
|
public void IsSdCardInserted_CardIsInserted_ReturnsTrue()
|
|
|
|
|
{
|
|
|
|
|
FileSystemClient fs = FileSystemServerFactory.CreateClient(true);
|
2020-02-14 01:21:24 +01:00
|
|
|
|
|
2021-11-14 20:08:57 +01:00
|
|
|
|
Assert.True(fs.IsSdCardInserted());
|
|
|
|
|
}
|
2020-02-14 01:21:24 +01:00
|
|
|
|
|
2021-11-14 20:08:57 +01:00
|
|
|
|
[Fact]
|
|
|
|
|
public void IsSdCardInserted_CardIsNotInserted_ReturnsFalse()
|
|
|
|
|
{
|
|
|
|
|
FileSystemClient fs = FileSystemServerFactory.CreateClient(false);
|
2020-02-14 01:21:24 +01:00
|
|
|
|
|
2021-11-14 20:08:57 +01:00
|
|
|
|
Assert.False(fs.IsSdCardInserted());
|
|
|
|
|
}
|
2020-02-14 01:21:24 +01:00
|
|
|
|
|
2021-11-14 20:08:57 +01:00
|
|
|
|
[Fact]
|
|
|
|
|
public void IsSdCardAccessible_CardIsInserted_ReturnsTrue()
|
|
|
|
|
{
|
|
|
|
|
FileSystemClient fs = FileSystemServerFactory.CreateClient(true);
|
2020-02-14 01:21:24 +01:00
|
|
|
|
|
2021-11-14 20:08:57 +01:00
|
|
|
|
Assert.True(fs.IsSdCardAccessible());
|
|
|
|
|
}
|
2020-02-14 01:21:24 +01:00
|
|
|
|
|
2021-11-14 20:08:57 +01:00
|
|
|
|
[Fact]
|
|
|
|
|
public void IsSdCardAccessible_CardIsNotInserted_ReturnsFalse()
|
|
|
|
|
{
|
|
|
|
|
FileSystemClient fs = FileSystemServerFactory.CreateClient(false);
|
2020-02-14 01:21:24 +01:00
|
|
|
|
|
2021-11-14 20:08:57 +01:00
|
|
|
|
Assert.False(fs.IsSdCardAccessible());
|
|
|
|
|
}
|
2020-02-14 01:21:24 +01:00
|
|
|
|
|
2021-11-14 20:08:57 +01:00
|
|
|
|
[Fact]
|
|
|
|
|
public void SetSdCardAccessibility_SetAccessibilityPersists()
|
|
|
|
|
{
|
|
|
|
|
FileSystemClient fs = FileSystemServerFactory.CreateClient(false);
|
2020-02-14 01:21:24 +01:00
|
|
|
|
|
2021-11-14 20:08:57 +01:00
|
|
|
|
fs.SetSdCardAccessibility(true);
|
|
|
|
|
Assert.True(fs.IsSdCardAccessible());
|
2020-02-14 01:21:24 +01:00
|
|
|
|
|
2021-11-14 20:08:57 +01:00
|
|
|
|
fs.SetSdCardAccessibility(false);
|
|
|
|
|
Assert.False(fs.IsSdCardAccessible());
|
2020-02-14 01:21:24 +01:00
|
|
|
|
}
|
|
|
|
|
}
|