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); }
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. }
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()); }
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); }
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)); }
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)); }
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. }
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); }
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)); }
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)); }
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); }
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)); }
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); }
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)); }
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); }
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); }
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); }
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); }
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)); }
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)); }
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)); }
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); }
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)); }
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); }
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)); }
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); }
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); }
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)); }
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); }