示例#1
0
        public void ProgramDescription_GetRomWhenRomPathsInvalidAndAlternatePathsFound_ReturnsAlternateRom()
        {
            var alternatePaths = ProgramDescriptionHelpersTestStorage.Initialize(TestRomResources.TestBinPath, TestRomResources.TestCfgPath);
            var rom            = new XmlRom();

            rom.UpdateRomPath("/fleery/beery/neery.bin");
            rom.UpdateConfigPath("/fleery/beery/neery.cfg");
            var supportFiles = new ProgramSupportFiles(rom);

            supportFiles.AddSupportFile(ProgramFileKind.Rom, "/grab.bin");
            supportFiles.AddSupportFile(ProgramFileKind.Rom, alternatePaths[0]);
            supportFiles.AddSupportFile(ProgramFileKind.Rom, "/barg.bin");
            supportFiles.AddSupportFile(ProgramFileKind.CfgFile, "/grab.cfg");
            supportFiles.AddSupportFile(ProgramFileKind.CfgFile, alternatePaths[1]);
            supportFiles.AddSupportFile(ProgramFileKind.CfgFile, "/barg.cfg");
            var description = CreateProgramDescription(0x246u, rom);

            description.Files = supportFiles;

            var romFromDescription = description.GetRom();

            Assert.False(object.ReferenceEquals(rom, romFromDescription));
            Assert.Equal(alternatePaths[0], romFromDescription.RomPath);
            Assert.Equal(alternatePaths[1], romFromDescription.ConfigPath);
        }
示例#2
0
        public void ProgramDescription_GetRomWhenRomPathsAreNull_ThrowsArgumentNullException()
        {
            ProgramDescriptionHelpersTestStorage.Initialize();
            var rom         = new XmlRom();
            var description = CreateProgramDescription(0x456u, rom);

            Assert.Throws <ArgumentNullException>(() => description.GetRom());
        }
示例#3
0
        public void ProgramDescription_IsMatchingProgramDescriptionWithMatchingProgramIdentifierMatchingRomFormatCfgCrcMustMatchWithCodeInfoHasMismatchedCode_ReturnsFalse()
        {
            var romPaths    = ProgramDescriptionHelpersTestStorage.Initialize(TestRomResources.TestBinPath, TestRomResources.TestCfgPath);
            var rom         = Rom.Create(romPaths[0], romPaths[1]);
            var description = new TestProgramDescription(rom, "tod");

            Assert.False(description.IsMatchingProgramDescription(new ProgramIdentifier(rom.Crc, rom.CfgCrc), RomFormat.Bin, cfgCrcMustMatch: true, code: "tag"));
        }
示例#4
0
        public void ProgramDescription_IsMatchingProgramDescriptionWithMatchingProgramIdentifierMatchingRomFormatCfgCrcMustMatch_ReturnsTrue()
        {
            var romPaths = ProgramDescriptionHelpersTestStorage.Initialize(TestRomResources.TestBinPath, TestRomResources.TestCfgPath);
            var rom      = Rom.Create(romPaths[0], romPaths[1]);

            var description = CreateProgramDescription(rom.Crc, rom);

            Assert.True(description.IsMatchingProgramDescription(new ProgramIdentifier(rom.Crc, rom.CfgCrc), RomFormat.Bin, cfgCrcMustMatch: true));
        }
示例#5
0
        public void ProgramDescription_GetRomWhenRomPathInvalidCfgPathIsNullAndNoAlternatePaths_ReturnsOriginalRom()
        {
            ProgramDescriptionHelpersTestStorage.Initialize();
            var rom = new XmlRom();

            rom.UpdateRomPath("/flargy/bargy/nargy.rom");
            var description = CreateProgramDescription(0x789u, rom);

            Assert.True(object.ReferenceEquals(rom, description.GetRom()));
        }
示例#6
0
        public void ProgramDescription_GetRomWhenRomAndConfigPathsValidAlternatesAreDefined_ReturnsOriginalRom()
        {
            var romPaths    = ProgramDescriptionHelpersTestStorage.Initialize(TestRomResources.TestBinPath, TestRomResources.TestCfgPath);
            var rom         = Rom.Create(romPaths[0], romPaths[1]);
            var description = CreateProgramDescription(0x579u, rom);

            var romFromDescription = description.GetRom();

            Assert.True(object.ReferenceEquals(rom, romFromDescription));
        }
示例#7
0
        public void ProgramDescription_GetRomWhenRomAndCfgPathsInvalidAndNoAlternatePaths_ReturnsOriginalRom()
        {
            ProgramDescriptionHelpersTestStorage.Initialize();
            var rom = new XmlRom();

            rom.UpdateRomPath("/floogy/boogy/noogy.bin");
            rom.UpdateConfigPath("/floogy/boogy/noogy.cfg");
            var description = CreateProgramDescription(0x987u, rom);

            Assert.True(object.ReferenceEquals(rom, description.GetRom()));
        }
示例#8
0
        public void ProgramDescription_GetRomWhenRomPathValidAndNoConfig_ReturnsOriginalRom()
        {
            var romPath = ProgramDescriptionHelpersTestStorage.Initialize(TestRomResources.TestBinPath).First();
            var rom     = new XmlRom();

            rom.UpdateRomPath(romPath);
            var description = CreateProgramDescription(0x357u, rom);

            var romFromDescription = description.GetRom();

            Assert.True(object.ReferenceEquals(rom, romFromDescription));
        }
示例#9
0
        public void ProgramDescription_GetRomWhenRomPathValidAndCfgPathInvalidAndNoAlternates_ReturnsOriginalRom()
        {
            var romPath = ProgramDescriptionHelpersTestStorage.Initialize(TestRomResources.TestBinPath).First();
            var rom     = new XmlRom();

            rom.UpdateConfigPath("/flangy/bangy/nangy.cfg");
            rom.UpdateRomPath(romPath);
            var description = CreateProgramDescription(0x468u, rom);

            var romFromDescription = description.GetRom();

            Assert.True(object.ReferenceEquals(rom, romFromDescription));
        }
示例#10
0
        public void ProgramDescription_GetRomWhenRomAndCfgPathsInvalidAndUnbalancedAlternatePaths_ThrowsInvalidOperationException()
        {
            ProgramDescriptionHelpersTestStorage.Initialize();
            var rom = new XmlRom();

            rom.UpdateRomPath("/fleggy/beggy/neggy.bin");
            rom.UpdateConfigPath("/fleggy/beggy/neggy.cfg");
            var supportFiles = new ProgramSupportFiles(rom);

            supportFiles.AddSupportFile(ProgramFileKind.Rom, "/biff!");
            var description = CreateProgramDescription(0x654u, rom);

            description.Files = supportFiles;

            var exception = Assert.Throws <InvalidOperationException>(() => description.GetRom());

            Assert.Equal(Resources.Strings.ProgramDescription_MissingAlternateCfgFile, exception.Message);
        }
示例#11
0
        public void ProgramDescription_IsMatchingProgramDescriptionWithMatchingProgramIdentifierMatchingRomFormatCfgCrcMustMatchWithCodeInfoHasInfoButDoesNotSupportCode_ReturnsFalse()
        {
            var romPaths    = ProgramDescriptionHelpersTestStorage.Initialize(TestRomResources.TestBinPath, TestRomResources.TestCfgPath);
            var rom         = Rom.Create(romPaths[0], romPaths[1]);
            var code        = "tag";
            var information = new IntvFunhouseXmlProgramInformation()
            {
                ProgramTitle               = "Tagalong Tod",
                YearString                 = "2000",
                CrcString                  = "0x" + rom.Crc.ToString("x8", CultureInfo.InvariantCulture),
                CrcNotesString             = string.Empty,
                CrcIncompatibilitiesString = string.Empty,
                CfgFiles = "0",
                Code     = code
            };
            var description = new ProgramDescription(rom.Crc, rom, information);

            Assert.False(description.IsMatchingProgramDescription(new ProgramIdentifier(rom.Crc, rom.CfgCrc), RomFormat.Bin, cfgCrcMustMatch: true, code: code));
        }
示例#12
0
        public void ProgramDescription_GetRomWhenRomAndCfgPathsInvalidAndAlternatePathsNotFound_ReturnsOriginalRom()
        {
            ProgramDescriptionHelpersTestStorage.Initialize();
            var rom = new XmlRom();

            rom.UpdateRomPath("/flooty/booty/nooty.bin");
            rom.UpdateConfigPath("/flooty/booty/nooty.cfg");
            var supportFiles = new ProgramSupportFiles(rom);

            supportFiles.AddSupportFile(ProgramFileKind.Rom, "/banff.bin");
            supportFiles.AddSupportFile(ProgramFileKind.Rom, "/barff.bin");
            supportFiles.AddSupportFile(ProgramFileKind.CfgFile, "/banff.cfg");
            supportFiles.AddSupportFile(ProgramFileKind.CfgFile, "/barff.cfg");
            var description = CreateProgramDescription(0x321u, rom);

            description.Files = supportFiles;

            Assert.True(object.ReferenceEquals(rom, description.GetRom()));
        }
示例#13
0
        public void ProgramDescription_GetRomWhenRomPathInvalidAndAlternatePathFound_ReturnsAlternateRom()
        {
            var alternatePath = ProgramDescriptionHelpersTestStorage.Initialize(TestRomResources.TestCc3Path).First();
            var rom           = new XmlRom();

            rom.UpdateRomPath("/floory/boory/noory.rom");
            var supportFiles = new ProgramSupportFiles(rom);

            supportFiles.AddSupportFile(ProgramFileKind.Rom, "/grub.bin");
            supportFiles.AddSupportFile(ProgramFileKind.Rom, alternatePath);
            supportFiles.AddSupportFile(ProgramFileKind.Rom, "/burg.bin");
            var description = CreateProgramDescription(0x135u, rom);

            description.Files = supportFiles;

            var romFromDescription = description.GetRom();

            Assert.False(object.ReferenceEquals(rom, romFromDescription));
            Assert.Equal(alternatePath, romFromDescription.RomPath);
        }