public void GetProgramIndexForAccessLog_IsMultiProgram_ReturnsCorrectIndex()
        {
            const int count = 7;

            Horizon hos = HorizonFactory.CreateBasicHorizon();

            var programs = new HorizonClient[count];

            programs[0] = hos.CreateHorizonClient(new ProgramId(1), AccessControlBits.Bits.RegisterProgramIndexMapInfo);

            for (int i = 1; i < programs.Length; i++)
            {
                programs[i] = hos.CreateHorizonClient(new ProgramId((ulong)(i + 1)), AccessControlBits.Bits.None);
            }

            var map = new ProgramIndexMapInfo[count];

            for (int i = 0; i < map.Length; i++)
            {
                map[i].MainProgramId = new ProgramId(1);
                map[i].ProgramId     = new ProgramId((ulong)(i + 1));
                map[i].ProgramIndex  = (byte)i;
            }

            Assert.Success(programs[0].Fs.RegisterProgramIndexMapInfo(map));

            for (int i = 0; i < programs.Length; i++)
            {
                Assert.Success(programs[i].Fs.GetFileSystemProxyServiceObject()
                               .GetProgramIndexForAccessLog(out int programIndex, out int programCount));

                Assert.Equal(i, programIndex);
                Assert.Equal(count, programCount);
            }
        }
        private ProgramIndexMapInfoManager CreatePopulatedManager(int count, Func <int, long> idCreator)
        {
            var manager = new ProgramIndexMapInfoManager();

            var map = new ProgramIndexMapInfo[count];

            for (int i = 0; i < map.Length; i++)
            {
                map[i].MainProgramId = new ProgramId((ulong)idCreator(0));
                map[i].ProgramId     = new ProgramId((ulong)idCreator(i));
                map[i].ProgramIndex  = (byte)i;
            }

            Assert.Success(manager.Reset(map));

            return(manager);
        }
示例#3
0
        public void GetProgramIndexForAccessLog_IsMultiProgram_ReturnsCorrectIndex()
        {
            const int count = 7;

            Horizon hos = HorizonFactory.CreateBasicHorizon();

            var programs = new HorizonClient[count];

            programs[0] = hos.CreateHorizonClient(new ProgramLocation(new ProgramId(1), StorageId.BuiltInSystem),
                                                  AccessControlBits.Bits.RegisterProgramIndexMapInfo);

            for (int i = 1; i < programs.Length; i++)
            {
                programs[i] =
                    hos.CreateHorizonClient(new ProgramLocation(new ProgramId((ulong)(i + 1)), StorageId.BuiltInSystem),
                                            AccessControlBits.Bits.None);
            }

            var map = new ProgramIndexMapInfo[count];

            for (int i = 0; i < map.Length; i++)
            {
                map[i].MainProgramId = new ProgramId(1);
                map[i].ProgramId     = new ProgramId((ulong)(i + 1));
                map[i].ProgramIndex  = (byte)i;
            }

            Assert.Success(programs[0].Fs.RegisterProgramIndexMapInfo(map));

            for (int i = 0; i < programs.Length; i++)
            {
                using ReferenceCountedDisposable <LibHac.FsSrv.Sf.IFileSystemProxy> fsProxy =
                          programs[i].Fs.Impl.GetFileSystemProxyServiceObject();
                Assert.Success(fsProxy.Target.GetProgramIndexForAccessLog(out int programIndex, out int programCount));

                Assert.Equal(i, programIndex);
                Assert.Equal(count, programCount);
            }
        }