public void IProgramInformation_MergeInvalidField_ThrowsArgumentException() { var information = new TestProgramInformation(); var field = (ProgramInformationMergeFieldsFlags)(1u << 12); Assert.Throws <ArgumentException>(() => information.Merge(field)); }
public void XmlRomInformationToProgramRomInformationConverter_CreateDefaultAndConvertXmlInfoWithMultipleCorruptions_ProducesValidConversion() { var converter = XmlRomInformationToProgramRomInformationConverter.Create(); var columnsToCorrupt = new[] { XmlRomInformationDatabaseColumnName.vendor, XmlRomInformationDatabaseColumnName.short_name, XmlRomInformationDatabaseColumnName.release_date, XmlRomInformationDatabaseColumnName.soundfx, XmlRomInformationDatabaseColumnName.game_docs }; var xmlRomInformation = CreateTestInformationForConversion(XmlInformationKind.FullyPopulated, columnsToCorrupt); xmlRomInformation.GetColumn(XmlRomInformationDatabaseColumnName.build_date).Value = "2020"; // corrupted because it's not YYYY-MM-DD var convertedInformation = converter.Convert(xmlRomInformation); var builder = new ProgramMetadataBuilder().WithInitialMetadata(XmlProgramMetadata.Value); builder.WithPublishers(null).WithShortNames(null).WithReleaseDates(null).WithSoundEffects(null).WithDocumentation(null).WithBuildDates(null); var expectedMetadata = builder.Build(); var expectedProgramInformation = new TestProgramInformation(XmlProgramInformation) { Vendor = null, ShortName = null, Year = null }; var expectedProgramDescription = new TestProgramDescription(XmlProgramDescription) { Vendor = null, ShortName = null, Year = null }; ValidateInformation(expectedProgramInformation, convertedInformation); ValidateDescription(expectedProgramDescription, convertedInformation); ValidateFeatures(XmlProgramFeatures.Value, convertedInformation.Features); ValidateMetadata(expectedMetadata, convertedInformation.Metadata); }
public void IProgramInformation_MergeInvalidFieldInOtherSources_ThrowsArgumentException() { var information = new TestProgramInformation(); var toMerge = new Tuple <IProgramInformation, ProgramInformationMergeFieldsFlags>(new TestProgramInformation(), (ProgramInformationMergeFieldsFlags)(1u << 12)); Assert.Throws <ArgumentException>(() => information.Merge(ProgramInformationMergeFieldsFlags.All, toMerge)); }
internal void AddEntries(TestProgramInformation information) { foreach (var crcData in information.Crcs.Cast <CrcData>()) { _entries[crcData.Crc] = information; } }
public void ProgramDescription_Copy_ProducesEquivalentCopy() { var information = new TestProgramInformation(); var crc = 5u; var name = "AgletMaster 5905"; information.AddCrc(crc, name); var description0 = new ProgramDescription(crc, null, information); description0.ShortName = "A\aa"; description0.Vendor = "V\vv"; var description1 = description0.Copy(); Assert.Equal(description0.Name, description1.Name); Assert.Equal(description0.ShortName, description1.ShortName); Assert.Equal(description0.Vendor, description1.Vendor); Assert.Equal(description0.Year, description1.Year); Assert.Equal(description0.Features, description1.Features); Assert.False(object.ReferenceEquals(description0.XmlName, description1.XmlName)); Assert.Equal(description0.XmlName.XmlText, description1.XmlName.XmlText); Assert.Equal(description0.XmlName.Escaped, description1.XmlName.Escaped); Assert.False(object.ReferenceEquals(description0.XmlShortName, description1.XmlShortName)); Assert.Equal(description0.XmlShortName.XmlText, description1.XmlShortName.XmlText); Assert.Equal(description0.XmlShortName.Escaped, description1.XmlShortName.Escaped); Assert.Equal(description0.Vendor, description1.Vendor); Assert.False(object.ReferenceEquals(description0.XmlVendor, description1.XmlVendor)); Assert.Equal(description0.XmlVendor.XmlText, description1.XmlVendor.XmlText); Assert.Equal(description0.XmlVendor.Escaped, description1.XmlVendor.Escaped); Assert.True(object.ReferenceEquals(description0.Rom, description1.Rom)); VerifyProgramInformation(description0.ProgramInformation, description1.ProgramInformation); VerifyProgramSupportFiles(description0.Files, description1.Files); Assert.Equal(description0, description1); }
public TestProgramInformation(TestProgramInformation otherInformation) { Title = otherInformation.Title; Vendor = otherInformation.Vendor; Year = otherInformation.Year; ShortName = otherInformation.ShortName; Features = otherInformation.Features; }
public void ProgramDescription_CreateWithZeroCrcNullRomInformationWithOneCrc_ThrowsInvalidOperationException() { var information = new TestProgramInformation(); information.AddCrc(1u); Assert.Throws <InvalidOperationException>(() => new ProgramDescription(0u, null, information)); // Throws because no CRC matches the one passed into the constructor. }
internal void AddEntries(TestProgramInformation information) { foreach (var crcData in information.Crcs.Cast <CrcDataAdvanced>()) { var programIdentifier = new ProgramIdentifier(crcData.Crc, crcData.CfgCrc); _entries[programIdentifier] = information; } }
public void UserSpecifiedProgramInformation_ConstructWithEmptyNonMetadataProgramInformation_CreatesExpectedInformation() { var sourceInformation = new TestProgramInformation(); var information = new UserSpecifiedProgramInformation(sourceInformation); Assert.False(information.IsModified); VerifyInformation(sourceInformation, information); }
public void IProgramInformation_GetDatabaseCodeOnInformationThatDoesNotSupportCode_ReturnsNullCode() { var information = new TestProgramInformation() { Title = "No code for you!" }; Assert.Null(information.GetDatabaseCode()); }
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 IProgramInformationToXmlRomInformationConverter_ConvertInformationWithNoCrcData_ProducesNoResults() { var information = new TestProgramInformation() { Title = "Nothing to see here" }; var xmlRomInformation = IProgramInformationToXmlRomInformationConverter.Instance.Convert(information); Assert.False(xmlRomInformation.Any()); }
public void IProgramInformationToXmlRomInformationConverter_ConvertInformationWithoutCrcs_ProducesNoResultsRegardlessOfSettings(bool convertAll, bool setFeatures, bool setMetadata) { var information = new TestProgramInformation() { Title = "What, me worry?" }; var xmlRomInformation = IProgramInformationToXmlRomInformationConverter.Instance.Convert(information, convertAll, setFeatures, setMetadata); Assert.False(xmlRomInformation.Any()); }
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_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 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 TestProgramInformation ToInformation() { var information = new TestProgramInformation() { Title = Name, Vendor = Vendor, Year = Year, ShortName = ShortName, }; return(information); }
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 IProgramInformationToXmlRomInformationConverter_ConvertInformationWithOneCrc_XmlRomInformationHasExpectedReleaseDateString(string programInfoYear, string expectedYearString) { var information = new TestProgramInformation() { Title = "Year tester info", Year = programInfoYear }; information.AddCrcs(1, setVersionMetadata: false); var xmlRomInformation = IProgramInformationToXmlRomInformationConverter.Instance.Convert(information).Single(); Assert.Equal(expectedYearString, xmlRomInformation.GetColumn(XmlRomInformationDatabaseColumnName.release_date).Value); }
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_AddDuplicateCrc_DoesNotAddTheCrc() { var information = new TestProgramInformation(); var crc = 0x44556677u; Assert.True(information.AddCrc(crc)); Assert.False(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_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 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_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 IProgramInformationToXmlRomInformationConverter_ConvertInformationWithOneCrc_XmlRomInformationHasExpectedOriginString(ProgramInformationOrigin originToTest, string expectedOriginString) { var information = new TestProgramInformation() { Title = "Origin tester info" }; information.SetOrigin(originToTest); information.AddCrcs(1, setVersionMetadata: false); var xmlRomInformation = IProgramInformationToXmlRomInformationConverter.Instance.Convert(information).Single(); Assert.Equal(expectedOriginString, xmlRomInformation.GetColumn(XmlRomInformationDatabaseColumnName.origin).Value); }
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 IProgramInformationToXmlRomInformationConverter_ConvertInformationWithOneCrc_XmlRomInformationHasExpectedTypeString(GeneralFeatures generalFeatures, string expectedRomTypeString) { var features = new ProgramFeaturesBuilder().WithGeneralFeatures(generalFeatures).Build(); var information = new TestProgramInformation() { Title = "Rom Type tester info", Features = (ProgramFeatures)features }; information.AddCrcs(1, setVersionMetadata: false); var xmlRomInformation = IProgramInformationToXmlRomInformationConverter.Instance.Convert(information, convertAll: false, setFeatures: false, setMetadata: false).Single(); Assert.Equal(expectedRomTypeString, xmlRomInformation.GetColumn(XmlRomInformationDatabaseColumnName.type).Value); }
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_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)); }