Exemplo n.º 1
0
        public void MountCacheStorage_SdCardIsPreferredOverBis()
        {
            var applicationId   = new Ncm.ApplicationId(1);
            FileSystemClient fs = FileSystemServerFactory.CreateClient(true);

            fs.CreateCacheStorage(applicationId, SaveDataSpaceId.SdCache, applicationId.Value, 0, 0, SaveDataFlags.None);
            fs.MountCacheStorage("cache".ToU8Span(), applicationId);
            fs.CreateFile("cache:/sd".ToU8Span(), 0);
            fs.Commit("cache".ToU8Span());
            fs.Unmount("cache".ToU8Span());

            // Turn off the SD card so the User save is mounted
            fs.SetSdCardAccessibility(false);

            fs.CreateCacheStorage(applicationId, SaveDataSpaceId.User, applicationId.Value, 0, 0, SaveDataFlags.None);
            fs.MountCacheStorage("cache".ToU8Span(), applicationId);
            fs.CreateFile("cache:/bis".ToU8Span(), 0);
            fs.Commit("cache".ToU8Span());
            fs.Unmount("cache".ToU8Span());

            fs.SetSdCardAccessibility(true);

            Assert.Success(fs.MountCacheStorage("cache".ToU8String(), applicationId));
            Assert.Success(fs.GetEntryType(out _, "cache:/sd".ToU8Span()));
            Assert.Failure(fs.GetEntryType(out _, "cache:/bis".ToU8Span()));
        }
Exemplo n.º 2
0
        public void CreateCacheStorage_AlreadyExists_ReturnsPathAlreadyExists()
        {
            var applicationId   = new Ncm.ApplicationId(1);
            FileSystemClient fs = FileSystemServerFactory.CreateClient(true);

            Assert.Success(fs.CreateCacheStorage(applicationId, SaveDataSpaceId.User, applicationId.Value, 0, 0, SaveDataFlags.None));
            Assert.Result(ResultFs.PathAlreadyExists, fs.CreateCacheStorage(applicationId, SaveDataSpaceId.User, applicationId.Value, 0, 0, SaveDataFlags.None));
        }
Exemplo n.º 3
0
        public void CreateCacheStorage_InSdCacheSaveSpaceWhenNoSdCard_ReturnsSdCardNotFound()
        {
            var applicationId   = new Ncm.ApplicationId(1);
            FileSystemClient fs = FileSystemServerFactory.CreateClient(false);

            Assert.Result(ResultFs.PortSdCardNoDevice, fs.CreateCacheStorage(applicationId, SaveDataSpaceId.SdCache, applicationId.Value, 0, 0, SaveDataFlags.None));
        }
Exemplo n.º 4
0
        public void MountCacheStorage_CanMountCreatedCacheStorage()
        {
            var applicationId   = new Ncm.ApplicationId(1);
            FileSystemClient fs = FileSystemServerFactory.CreateClient(true);

            fs.CreateCacheStorage(applicationId, SaveDataSpaceId.User, applicationId.Value, 0, 0, SaveDataFlags.None);

            Assert.Success(fs.MountCacheStorage("cache".ToU8Span(), applicationId));
        }
Exemplo n.º 5
0
        public void CreateCacheStorage_WithIndex_CreatesMultiple()
        {
            var applicationId   = new Ncm.ApplicationId(1);
            FileSystemClient fs = FileSystemServerFactory.CreateClient(true);

            Assert.Success(fs.CreateCacheStorage(applicationId, SaveDataSpaceId.User, applicationId.Value, 0, 0, 0, SaveDataFlags.None));
            Assert.Success(fs.CreateCacheStorage(applicationId, SaveDataSpaceId.User, applicationId.Value, 1, 0, 0, SaveDataFlags.None));

            fs.OpenSaveDataIterator(out SaveDataIterator iterator, SaveDataSpaceId.User);

            var info = new SaveDataInfo[3];

            iterator.ReadSaveDataInfo(out long entriesRead, info);

            Assert.Equal(2, entriesRead);
            Assert.Equal(applicationId, info[0].ProgramId);
            Assert.Equal(applicationId, info[1].ProgramId);

            ushort[] expectedIndexes = { 0, 1 };
            ushort[] actualIndexes   = info.Take(2).Select(x => x.Index).OrderBy(x => x).ToArray();

            Assert.Equal(expectedIndexes, actualIndexes);
        }
Exemplo n.º 6
0
        public void MountCacheStorage_WrittenDataPersists()
        {
            var applicationId   = new Ncm.ApplicationId(1);
            FileSystemClient fs = FileSystemServerFactory.CreateClient(true);

            fs.CreateCacheStorage(applicationId, SaveDataSpaceId.SdCache, applicationId.Value, 0, 0, SaveDataFlags.None);
            fs.MountCacheStorage("cache".ToU8Span(), applicationId);

            fs.CreateFile("cache:/file".ToU8Span(), 0);
            fs.Commit("cache".ToU8Span());
            fs.Unmount("cache".ToU8Span());

            Assert.Success(fs.MountCacheStorage("cache".ToU8Span(), applicationId));
            Assert.Success(fs.GetEntryType(out DirectoryEntryType type, "cache:/file".ToU8Span()));
            Assert.Equal(DirectoryEntryType.File, type);
        }
Exemplo n.º 7
0
        public void CreateCacheStorage_InSdCacheSaveSpace_StorageIsCreated()
        {
            var applicationId   = new Ncm.ApplicationId(1);
            FileSystemClient fs = FileSystemServerFactory.CreateClient(true);

            Assert.Success(fs.CreateCacheStorage(applicationId, SaveDataSpaceId.SdCache, applicationId.Value, 0, 0, SaveDataFlags.None));

            fs.OpenSaveDataIterator(out SaveDataIterator iterator, SaveDataSpaceId.SdCache);

            var info = new SaveDataInfo[2];

            iterator.ReadSaveDataInfo(out long entriesRead, info);

            Assert.Equal(1, entriesRead);
            Assert.Equal(applicationId, info[0].ProgramId);
        }