예제 #1
0
        public void LuigiFormatRom_Load_VerifyCrc24()
        {
            var romPath = LuigiFormatRomTestStorageAccess.Initialize(TestRomResources.TestLuigiFromBinPath).First();
            var rom     = Rom.AsSpecificRomType <LuigiFormatRom>(Rom.Create(romPath, null));

            Assert.Equal(0x0035f671u, rom.Crc24);
        }
예제 #2
0
        public void LuigiFormatRom_LoadStandardLuigi_VerifyTargetDeviceUniqueId()
        {
            var romPath = LuigiFormatRomTestStorageAccess.Initialize(TestRomResources.TestLuigiFromBinPath).First();
            var rom     = Rom.AsSpecificRomType <LuigiFormatRom>(Rom.Create(romPath, null));

            Assert.True(string.IsNullOrEmpty(rom.TargetDeviceUniqueId));
        }
예제 #3
0
        public void LuigiFormatRom_LoadScrambledForAnyLuigiWithMetadataRequestTestBlock_VerifyTestBlockNotFound()
        {
            var romPath = LuigiFormatRomTestStorageAccess.Initialize(TestRomResources.TestLuigiWithMetadatdaScrambledForAnyDevicePath).First();
            var rom     = Rom.AsSpecificRomType <LuigiFormatRom>(Rom.Create(romPath, null));

            Assert.Null(rom.LocateDataBlock <LuigiTestDataBlock>());
        }
예제 #4
0
        public void LuigiFormatRom_LoadScrambledForAnyLuigi_VerifyTargetDeviceUniqueId()
        {
            var romPath = LuigiFormatRomTestStorageAccess.Initialize(TestRomResources.TestLuigiScrambledForAnyDevicePath).First();
            var rom     = Rom.AsSpecificRomType <LuigiFormatRom>(Rom.Create(romPath, null));

            Assert.Equal(LuigiScrambleKeyBlock.AnyLTOFlashId, rom.TargetDeviceUniqueId);
        }
예제 #5
0
        public void LuigiFormatRom_Load_VerifyCrc()
        {
            var romPath = LuigiFormatRomTestStorageAccess.Initialize(TestRomResources.TestLuigiFromBinPath).First();
            var rom     = Rom.Create(romPath, null);

            Assert.Equal(TestRomResources.TestBinCrc, rom.Crc);
            Assert.Equal(TestRomResources.TestCfgCrc, rom.CfgCrc);
        }
예제 #6
0
        public void LuigiFormatRom_LoadAndValidateRom_RomFormatIdentifiedCorrectly()
        {
            var romPath = LuigiFormatRomTestStorageAccess.Initialize(TestRomResources.TestLuigiFromBinPath).First();
            var rom     = Rom.Create(romPath, null);

            Assert.NotNull(rom);
            Assert.Equal(RomFormat.Luigi, rom.Format);
            Assert.True(rom.Validate());
        }
예제 #7
0
        public void LuigiFormatRomFromFuture_Load_DoesNotLoadAsLuigiFormatRom()
        {
            var romPath = LuigiFormatRomTestStorageAccess.Initialize(TestRomResources.TestLuigiFromFuturePath).First();
            var rom     = Rom.Create(romPath, null);

            // At this time, the ROM *just happens* to pass the .bin format tests! Depending on
            // many factors, differently "fake corrupted" ROMs could fail to load or not.
            // This test is OK with a null or .bin result.
            Assert.True((rom == null) || (rom.Format == RomFormat.Bin));
        }
예제 #8
0
        public void LuigiFormatRom_CheckFormatOfCorruptFile_ThrowsNullReferenceException()
        {
            IReadOnlyList <string> paths;
            var storageAccess = LuigiFormatRomTestStorageAccess.Initialize(out paths, TestRomResources.TestLuigiWithBadHeaderPath);

            var corrupted = storageAccess.IntroduceCorruption(paths.First());

            Assert.True(corrupted);
            Assert.Throws <NullReferenceException>(() => LuigiFormatRom.CheckFormat(paths.First()));
        }
예제 #9
0
        public void LuigiFormatRom_GetMetadata_ReturnsExpectedMetadata()
        {
            var romPath = LuigiFormatRomTestStorageAccess.Initialize(TestRomResources.TestLuigiWithMetadataPath).First();

            var rom      = Rom.Create(romPath, null);
            var metadata = rom.GetLuigiFileMetadata();

            Assert.NotNull(metadata);
            VerifyExpectedMetadata(metadata);
        }
예제 #10
0
        public void LuigiFormatRom_GetCrcsFromFileWithZeroCrcs_CrcMatchesCrcOfFile()
        {
            var romPath = LuigiFormatRomTestStorageAccess.Initialize(TestRomResources.TestLuigiWithZeroCrcsPath).First();

            uint cfgCrc;
            var  crc = LuigiFormatRom.GetCrcs(romPath, null, out cfgCrc);

            Assert.Equal(TestRomResources.TestLuigiWithZeroCrcsCrc, crc);
            Assert.Equal(0u, cfgCrc);
        }
예제 #11
0
        public void LuigiFormatRom_GetCrcsFromRomOrigin_CrcsMatch()
        {
            var romPath = LuigiFormatRomTestStorageAccess.Initialize(TestRomResources.TestLuigiFromRomPath).First();

            uint cfgCrc;
            var  crc = LuigiFormatRom.GetCrcs(romPath, null, out cfgCrc);

            Assert.Equal(TestRomResources.TestRomCrc, crc);
            Assert.Equal(0u, cfgCrc);
        }
예제 #12
0
        public void LuigiFormatRom_LoadScrambledLuigis_VerifyTargetDeviceUniqueIds()
        {
            var paths = LuigiFormatRomTestStorageAccess.Initialize(TestRomResources.TestLuigiScrambledForDevice0Path, TestRomResources.TestLuigiScrambledForDevice1Path);
            var rom0  = Rom.AsSpecificRomType <LuigiFormatRom>(Rom.Create(paths[0], null));
            var rom1  = Rom.AsSpecificRomType <LuigiFormatRom>(Rom.Create(paths[1], null));

            Assert.NotEqual(rom0.TargetDeviceUniqueId, rom1.TargetDeviceUniqueId);
            Assert.Equal(TestRomResources.TestLuigiScrambledForDevice0UniqueId, rom0.TargetDeviceUniqueId);
            Assert.Equal(TestRomResources.TestLuigiScrambledForDevice1UniqueId, rom1.TargetDeviceUniqueId);
        }
예제 #13
0
        public void LuigiFormatRom_GetComparisonIgnoreRanges_ReturnsCorrectNumberOfExcludeRanges(bool excludeFeatureBits, int expectedNumberOfExcludeRanges)
        {
            var romPath = LuigiFormatRomTestStorageAccess.Initialize(TestRomResources.TestLuigiFromBinPath).First();
            var rom     = Rom.AsSpecificRomType <LuigiFormatRom>(Rom.Create(romPath, null));

            // Three ranges of values are ignored in this case:
            // 1. Feature flags (depends on value of excludeFeatureBits)
            // 2. The UID (which for this specific test ROM is the CRC32 of the .BIN and the CRC32 of the .CFG of the original ROM
            // 3. The CRC of the header
            var rangesToIgnore = rom.GetComparisonIgnoreRanges(excludeFeatureBits);

            Assert.Equal(expectedNumberOfExcludeRanges, rangesToIgnore.Count());
        }