예제 #1
0
        public void ProgramDescription_CreateWithMatchingCrcWithNullRomInformationWithFeaturesAndMatchingCrcMultipleIncompatibilities_FeaturesIncludesAllIncompatibilities()
        {
            var information = new TestProgramInformation();
            var crc         = 1u;
            var name        = "AgletMaster 5300";

            information.AddCrc(crc, name, IncompatibilityFlags.None);
            information.AddCrc(crc + 1, name, IncompatibilityFlags.Jlp);
            information.AddCrc(crc + 2, name, IncompatibilityFlags.LtoFlash);
            information.Features = new ProgramFeaturesBuilder().WithPalCompatibility(FeatureCompatibility.Enhances).Build() as ProgramFeatures;

            var description = new ProgramDescription(crc, null, information);

            Assert.Equal(FeatureCompatibility.Enhances, description.Features.Pal);
            Assert.Equal(JlpFeatures.Incompatible, description.Features.Jlp);
            Assert.Equal(LtoFlashFeatures.Incompatible, description.Features.LtoFlash);
        }
예제 #2
0
        public void ProgramDescription_CreateWithMatchingCrcWithNullRomInformationWithMatchingCrcOneIncompatibility_ThrowsNullReferenceException()
        {
            var information = new TestProgramInformation();
            var crc         = 1u;
            var name        = "AgletMaster 5100";

            information.AddCrc(crc, name, IncompatibilityFlags.Jlp);

            Assert.Throws <NullReferenceException>(() => new ProgramDescription(crc, null, information)); // Throws because there are no features in information.
        }
예제 #3
0
        public void ProgramDescription_GetHashCode_ProducesExpectedHashCode()
        {
            var crc         = 0x82736455u;
            var information = new TestProgramInformation();

            information.AddCrc(crc);
            var description = new ProgramDescription(crc, null, information);

            var expectedHashCode = crc.GetHashCode();

            Assert.Equal(expectedHashCode, description.GetHashCode());
        }
예제 #4
0
        public void ProgramDescription_SetCrcWhenFoundInDatabase_UpdatesCrc()
        {
            var information = new TestProgramInformation();
            var crc         = 1u;

            information.AddCrc(crc);
            var newCrc = 0x32547698u;

            information.AddCrc(newCrc);
            var description = new ProgramDescription(crc, null, information);
            var testTable   = new TestProgramInformationTable();

            testTable.AddEntries(information);
            var defaultTable = ProgramInformationTable.Default as MergedProgramInformationTable; // Eewwww!

            defaultTable.MergeTable(testTable);

            description.Crc = newCrc;

            Assert.Equal(newCrc, description.Crc);
        }
예제 #5
0
        public void IProgramInformation_AddCrc_AddsTheCrc()
        {
            var information = new TestProgramInformation();

            var crc = 0x00112233u;

            Assert.True(information.AddCrc(crc));
            Assert.Equal(1, information.Crcs.Count());
            Assert.Equal(crc, information.Crcs.First().Crc);
            Assert.Equal(IncompatibilityFlags.None, information.Crcs.First().Incompatibilities);
            Assert.True(string.IsNullOrEmpty(information.Crcs.First().Description));
        }
예제 #6
0
        public void ProgramDescription_EqualsNull_ReturnsFalse()
        {
            var information = new TestProgramInformation();
            var crc         = 1u;
            var name        = "AgletMaster 5800a";

            information.AddCrc(crc, name);

            var description = new ProgramDescription(crc, null, information);

            Assert.False(description.Equals(null));
        }
예제 #7
0
        public void ProgramDescription_ValidateWithNullRom_ThrowsNullReferenceException()
        {
            var information = new TestProgramInformation();
            var crc         = 1u;
            var name        = "AgletMaster 5400";

            information.AddCrc(crc, name);

            var description = new ProgramDescription(crc, null, information);

            Assert.Throws <NullReferenceException>(() => ProgramDescription.Validate(description, null, null, reportMessagesChanged: false)); // Throws because ROM is null.
        }
예제 #8
0
        public void IProgramInformation_AddCrcWithDescription_AddsTheCrc()
        {
            var information = new TestProgramInformation();

            var crc         = 0x00112233u;
            var description = "Latest";

            Assert.True(information.AddCrc(crc, description));
            Assert.Equal(1, information.Crcs.Count());
            Assert.Equal(crc, information.Crcs.First().Crc);
            Assert.Equal(IncompatibilityFlags.None, information.Crcs.First().Incompatibilities);
            Assert.Equal(description, information.Crcs.First().Description);
        }
예제 #9
0
        public void ProgramDescription_EqualsSelf_ReturnsTrue()
        {
            var information = new TestProgramInformation();
            var crc         = 1u;
            var name        = "AgletMaster 5700a";

            information.AddCrc(crc, name);

            var description = new ProgramDescription(crc, null, information);
            var self        = description;

            Assert.True(description.Equals(self));
        }
예제 #10
0
        public void ProgramDescription_NullEquals_ThrowsNullReferenceException()
        {
            var information = new TestProgramInformation();
            var crc         = 1u;
            var name        = "AgletMaster 5900a";

            information.AddCrc(crc, name);

            var description = new ProgramDescription(crc, null, information);
            ProgramDescription nullProgramDescription = null;

            Assert.Throws <NullReferenceException>(() => nullProgramDescription.Equals(description));
        }
예제 #11
0
        public void IProgramInformation_MergeCrcs_CorrectlyMergesCrcs()
        {
            var emptyInformation = new TestProgramInformation();

            Assert.Null(emptyInformation.Features);
            var otherInformationSource = new TestProgramInformation();

            Assert.True(otherInformationSource.AddCrc(0x689504u, "Dreading it", IncompatibilityFlags.Pal));

            var mergedInformation = emptyInformation.Merge(ProgramInformationMergeFieldsFlags.Crcs, new Tuple <IProgramInformation, ProgramInformationMergeFieldsFlags>(otherInformationSource, ProgramInformationMergeFieldsFlags.Crcs));

            Assert.Equal(otherInformationSource.Crcs, mergedInformation.Crcs);
        }
예제 #12
0
        public void IProgramInformation_GetNameForCrcWithDescription_ReturnsExpectedName()
        {
            var information = new TestProgramInformation()
            {
                Title = "Best Game EVAR!"
            };

            var crc0         = 0x00112233u;
            var description0 = "Penultimate ROM";

            Assert.True(information.AddCrc(crc0, description0));
            var crc1         = 0x44332211u;
            var description1 = "Ultimate ROM";

            Assert.True(information.AddCrc(crc1, description1));

            var name0 = string.Format("{0} ({1})", information.Title, description0);
            var name1 = string.Format("{0} ({1})", information.Title, description1);

            Assert.Equal(name0, information.GetNameForCrc(crc0));
            Assert.Equal(name1, information.GetNameForCrc(crc1));
        }
예제 #13
0
        public void ProgramDescription_OperatorNullEquals_ReturnsFalse()
        {
            var information = new TestProgramInformation();
            var crc         = 1u;
            var name        = "AgletMaster 5900";

            information.AddCrc(crc, name);

            var description           = new ProgramDescription(crc, null, information);
            IProgramDescription other = null;

            Assert.False(other == description);
        }
예제 #14
0
        public void ProgramDescription_SetFeatures_UpdatesFeatures()
        {
            var information = new TestProgramInformation();
            var crc         = 1u;

            information.AddCrc(crc);
            var description = new ProgramDescription(crc, null, information);

            var newFeatures = new ProgramFeaturesBuilder().WithTutorvisionCompatibility(FeatureCompatibility.Requires).Build() as ProgramFeatures;

            description.Features = newFeatures;

            Assert.True(object.ReferenceEquals(newFeatures, description.Features));
        }
예제 #15
0
        public void ProgramDescription_SetCrcWhenNotInDatabase_UpdatesCrc()
        {
            var information = new TestProgramInformation();
            var crc         = 1u;

            information.AddCrc(crc);
            var description = new ProgramDescription(crc, null, information);

            var newCrc = 0x12346587u;

            description.Crc = newCrc;

            Assert.Equal(newCrc, description.Crc);
        }
예제 #16
0
        public void ProgramDescription_SetShortName_ShortNameIsExpectedValue(string newShortName, string expectedShortName)
        {
            var information = new TestProgramInformation()
            {
                Title = "Taterkins", ShortName = "Tater"
            };
            var crc = 1u;

            information.AddCrc(crc);
            var description = new ProgramDescription(crc, null, information);

            description.ShortName = newShortName;

            Assert.Equal(expectedShortName, description.ShortName);
        }
예제 #17
0
        public void ProgramDescription_SetVendor_VendorIsExpectedValue(string newVendor, string expectedVendor)
        {
            var information = new TestProgramInformation()
            {
                Vendor = "Vendorman"
            };
            var crc = 1u;

            information.AddCrc(crc);
            var description = new ProgramDescription(crc, null, information);

            description.Vendor = newVendor;

            Assert.Equal(expectedVendor, description.Vendor);
        }
예제 #18
0
        public void ProgramDescription_SetYear_YearIsExpectedValue(string newYear, string expectedYear)
        {
            var information = new TestProgramInformation()
            {
                Year = "1984"
            };
            var crc = 1u;

            information.AddCrc(crc);
            var description = new ProgramDescription(crc, null, information);

            description.Year = newYear;

            Assert.Equal(expectedYear, description.Year);
        }
예제 #19
0
        public void ProgramDescription_RomIsNullSetProgramSupportFilesWithNullRom_UpdatesFilesAndLeavesRomUnchanged()
        {
            var information = new TestProgramInformation();
            var crc         = 1u;

            information.AddCrc(crc);
            var description = new ProgramDescription(crc, null, information);

            var newFiles = new ProgramSupportFiles(null);

            description.Files = newFiles;

            Assert.Null(description.Rom);
            Assert.True(object.ReferenceEquals(newFiles, description.Files));
        }
예제 #20
0
        public void ProgramDescription_ValidateWithValidRom_ReturnsTrue()
        {
            var romPath = ProgramDescriptionTestStorage.Initialize(TestRomResources.TestRomPath).First();
            var rom     = Rom.Create(romPath, null);

            Assert.NotNull(rom);
            var information = new TestProgramInformation();
            var crc         = rom.Crc;
            var name        = "AgletMaster 5500";

            information.AddCrc(crc, name);

            var description = new ProgramDescription(crc, rom, information);

            Assert.True(ProgramDescription.Validate(description, null, null, reportMessagesChanged: false));
        }
예제 #21
0
        public void ProgramDescription_ValidateWithValidRomWhoseCfgFileIsMissing_ReturnsFalse()
        {
            var romPath = ProgramDescriptionTestStorage.Initialize(TestRomResources.TestLuigiScrambledForDevice0Path).First();
            var rom     = Rom.Create(romPath, null);

            Assert.NotNull(rom);
            var information = new TestProgramInformation();
            var crc         = 0x8C29E37Du;
            var name        = "AgletMaster 5600";

            information.AddCrc(crc, name);

            var description = new ProgramDescription(crc, rom, information);
            var v           = ProgramDescription.Validate(description, null, null, reportMessagesChanged: false);

            Assert.False(ProgramDescription.Validate(description, null, null, reportMessagesChanged: false));
        }
예제 #22
0
        public void ProgramDescription_CreateWithMatchingCrcWithNullRomInformationWithFeaturesAndMatchingCrcOneIncompatibility_RetainsFeatures()
        {
            var information = new TestProgramInformation();
            var crc         = 1u;
            var name        = "AgletMaster 5200";

            information.AddCrc(crc, name, IncompatibilityFlags.Jlp);
            information.Features = new ProgramFeaturesBuilder()
                                   .WithJlpFeatures(JlpFeatures.Incompatible)
                                   .WithLtoFlashFeatures(LtoFlashFeatures.Tolerates)
                                   .WithBee3Features(Bee3Features.Tolerates)
                                   .WithHiveFeatures(HiveFeatures.Tolerates)
                                   .Build() as ProgramFeatures;

            var description = new ProgramDescription(crc, null, information);

            Assert.Equal(information.Features, description.Features);
        }
예제 #23
0
        public void ProgramDescription_EqualsForTwoInstancesOfEqualDescriptionsWithNullRom_ReturnsTrue()
        {
            var information0 = new TestProgramInformation();
            var crc0         = 3u;
            var name0        = "AgletMaster 5903a";

            information0.AddCrc(crc0, name0);
            var information1 = new TestProgramInformation();
            var crc1         = 3u;
            var name1        = "AgletMaster 5903";

            information1.AddCrc(crc1, name1);

            var description0 = new ProgramDescription(crc0, null, information0);
            var description1 = new ProgramDescription(crc1, null, information1);

            Assert.True(description0.Equals(description1));
        }
예제 #24
0
        public void ProgramDescription_OperatorNotEqualsForTwoInstancesOfEqualDescriptionsWithNullRom_ReturnsFalse()
        {
            var information0 = new TestProgramInformation();
            var crc0         = 4u;
            var name0        = "AgletMaster 5904";

            information0.AddCrc(crc0, name0);
            var information1 = new TestProgramInformation();
            var crc1         = 4u;
            var name1        = "AgletMaster 5904";

            information1.AddCrc(crc1, name1);

            var description0 = new ProgramDescription(crc0, null, information0);
            var description1 = new ProgramDescription(crc1, null, information1);

            Assert.False(description0 != description1);
        }
예제 #25
0
        public void ProgramDescription_EqualsForTwoDifferentDescriptionsWithNullRom_ReturnsFalse()
        {
            var information0 = new TestProgramInformation();
            var crc0         = 1u;
            var name0        = "AgletMaster 5901a";

            information0.AddCrc(crc0, name0);
            var information1 = new TestProgramInformation();
            var crc1         = 2u;
            var name1        = "AgletMaster 5902a";

            information1.AddCrc(crc1, name1);

            var description0 = new ProgramDescription(crc0, null, information0);
            var description1 = new ProgramDescription(crc1, null, information1);

            Assert.False(description0.Equals(description1));
        }
예제 #26
0
        public void UserSpecifiedProgramInformation_ConstructWithNonMetadataProgramInformation_CreatesExpectedInformation(string year)
        {
            var sourceInformation = new TestProgramInformation(0x24680246, null, IncompatibilityFlags.KeyboardComponent)
            {
                Title     = "Sumpin' Mysterious",
                Vendor    = "Somewhat Mysterious, Inc.",
                Year      = year,
                ShortName = "S.M.",
                Features  = new ProgramFeaturesBuilder().WithEcsFeatures(EcsFeatures.Synthesizer).Build() as ProgramFeatures
            };

            sourceInformation.AddCrc(0x13579135, "(revised)", IncompatibilityFlags.Tutorvision);
            sourceInformation.SetOrigin(ProgramInformationOrigin.UpdateFragment);

            var information = new UserSpecifiedProgramInformation(sourceInformation);

            Assert.False(information.IsModified);
            VerifyInformation(sourceInformation, information);
        }
예제 #27
0
        public void IProgramInformation_ModifyCrcWithDescription_UpdatesTheCrc()
        {
            var information       = new TestProgramInformation();
            var crc               = 0x00112233u;
            var description       = "Penultimate ROM";
            var incompatibilities = IncompatibilityFlags.IntellivisionII;

            Assert.True(information.AddCrc(crc, description, incompatibilities));

            var newDescription       = "Ultimate ROM";
            var newIncompatibilities = IncompatibilityFlags.Tutorvision;

            Assert.True(information.ModifyCrc(crc, newDescription, newIncompatibilities));

            Assert.Equal(1, information.Crcs.Count());
            Assert.Equal(crc, information.Crcs.First().Crc);
            Assert.Equal(newIncompatibilities, information.Crcs.First().Incompatibilities);
            Assert.Equal(newDescription, information.Crcs.First().Description);
        }
예제 #28
0
        public void ProgramDescription_ValidRomSetProgramSupportFilesWithNullRom_UpdatesFilesAndLeavesRomUnchanged()
        {
            var romPath = ProgramDescriptionTestStorage.Initialize(TestRomResources.TestRomPath).First();
            var rom     = Rom.Create(romPath, null);

            Assert.NotNull(rom);
            var information = new TestProgramInformation();
            var crc         = rom.Crc;

            information.AddCrc(crc);
            var description = new ProgramDescription(crc, rom, information);

            var newFiles = new ProgramSupportFiles(null);

            description.Files = newFiles;

            Assert.True(object.ReferenceEquals(rom, description.Rom));
            Assert.True(object.ReferenceEquals(newFiles, description.Files));
        }
예제 #29
0
        public void ProgramDescription_CreateWithMatchingCrcNullRomInformationWithMatchingCrc_CreatesDescription()
        {
            var information = new TestProgramInformation();
            var crc         = 1u;
            var name        = "AgletMaster 5000";

            information.AddCrc(crc, name);

            var description = new ProgramDescription(crc, null, information);

            Assert.Equal(crc, description.Crc);
            Assert.Null(description.Rom);
            Assert.NotNull(description.ProgramInformation);
            Assert.Equal(" (" + name + ")", description.Name); // title is null; name from ROM variant is appended in parentheses
            Assert.Equal(information.ShortName, description.ShortName);
            Assert.Equal(information.Vendor, description.Vendor);
            Assert.Equal(information.Year, description.Year);
            Assert.Null(description.Features);
            Assert.NotNull(description.Files);
        }
        public void MergedProgramInformationTable_FindRomWithProgramIdentifier_FindsInformationAsExpected()
        {
            var mergedInformationTable = new MergedProgramInformationTable();
            var testProgramIdentifier  = new ProgramIdentifier(0x123u, 0x456u);
            var testProgramInformation = new TestProgramInformation()
            {
                Title = "Buffy Buckingham", Features = ProgramFeatures.GetUnrecognizedRomFeatures()
            };

            testProgramInformation.AddCrcs(3);
            testProgramInformation.AddCrc(testProgramIdentifier.DataCrc, "Version 0", IncompatibilityFlags.Tutorvision, testProgramIdentifier.OtherData);
            var table = new TestProgramInformationTable();

            table.AddEntries(testProgramInformation);
            mergedInformationTable.MergeTable(table);

            var foundInformation = mergedInformationTable.FindProgram(testProgramIdentifier);

            Assert.NotNull(foundInformation);
        }