private void VerifyMetadataInformation(LuigiFileMetadataProgramInformation information) { Assert.NotNull(information); Assert.Equal(ProgramInformationOrigin.LuigiMetadataBlock, information.DataOrigin); Assert.NotNull(information.Features); Assert.NotEmpty(information.Crcs); Assert.NotNull(information.Title); Assert.NotNull(information.Vendor); Assert.NotNull(information.Year); Assert.NotEmpty(information.LongNames); Assert.NotEmpty(information.ShortNames); Assert.NotEmpty(information.Descriptions); Assert.NotEmpty(information.Publishers); Assert.NotEmpty(information.Programmers); Assert.NotEmpty(information.Designers); Assert.NotEmpty(information.Graphics); Assert.NotEmpty(information.Music); Assert.NotEmpty(information.SoundEffects); Assert.NotEmpty(information.Voices); Assert.NotEmpty(information.Documentation); Assert.NotEmpty(information.Artwork); Assert.NotEmpty(information.ReleaseDates); Assert.NotEmpty(information.Licenses); Assert.NotEmpty(information.ContactInformation); Assert.NotEmpty(information.Versions); Assert.NotEmpty(information.BuildDates); Assert.Empty(information.AdditionalInformation); }
/// <summary> /// Gets IProgramInformation from a LUIGI file's metadata, if it is available. /// </summary> /// <param name="rom">The ROM from which metadata-based information is retrieved.</param> /// <returns>IProgramInformation retrieved from the LUIGI format ROM.</returns> public static LuigiFileMetadataProgramInformation GetLuigiFileMetadata(this IRom rom) { LuigiFileMetadataProgramInformation programInfo = null; var luigiRom = Rom.AsSpecificRomType <LuigiFormatRom>(rom); if (luigiRom != null) { try { var metadata = luigiRom.LocateDataBlock <LuigiMetadataBlock>(); if (metadata != null) { programInfo = new LuigiFileMetadataProgramInformation(luigiRom.Header, metadata); } } catch (Exception e) { // We don't really want to raise a lot of trouble if this is somehow wrong... Perhaps we should report this more aggressively // if it happens in the field, but for now, quietly fail. System.Diagnostics.Debug.WriteLine("Failed to get LUIGI metadata. Error: " + e.Message); #if DEBUG throw; #endif // DEBUG } } return(programInfo); }
public void LuigiFileMetadataProgramInformation_CreateWithMetadatda_DataOriginIsCorrect() { var path = LuigiFileMetadataProgramInformationTestStorageAccess.Initialize(TestRomResources.TestLuigiWithMetadataPath).Single(); var rom = Rom.AsSpecificRomType <LuigiFormatRom>(Rom.Create(path, null)); Assert.NotNull(rom); var metadataBlock = rom.LocateDataBlock <LuigiMetadataBlock>(); Assert.NotNull(metadataBlock); var information = new LuigiFileMetadataProgramInformation(rom.Header, metadataBlock); VerifyMetadataInformation(information); }
public void LuigiFileMetadataProgramInformation_AddCrc_ThrowsInvalidOperationException() { var path = LuigiFileMetadataProgramInformationTestStorageAccess.Initialize(TestRomResources.TestLuigiFromBinPath).Single(); var rom = Rom.AsSpecificRomType <LuigiFormatRom>(Rom.Create(path, null)); Assert.NotNull(rom); var metadataBlock = rom.LocateDataBlock <LuigiMetadataBlock>(); Assert.Null(metadataBlock); var information = new LuigiFileMetadataProgramInformation(rom.Header, metadataBlock); Assert.Throws <InvalidOperationException>(() => information.AddCrc(1u, "version", IncompatibilityFlags.None)); }
public void LuigiFileMetadataProgramInformation_CreateWithNoMetadatda_VerifySetYear() { var path = LuigiFileMetadataProgramInformationTestStorageAccess.Initialize(TestRomResources.TestLuigiFromBinPath).Single(); var rom = Rom.AsSpecificRomType <LuigiFormatRom>(Rom.Create(path, null)); Assert.NotNull(rom); var metadataBlock = rom.LocateDataBlock <LuigiMetadataBlock>(); Assert.Null(metadataBlock); var information = new LuigiFileMetadataProgramInformation(rom.Header, metadataBlock); Assert.Null(information.Year); var testYear = "1989"; information.Year = testYear; Assert.Equal(testYear, information.Year); }
public void LuigiFileMetadataProgramInformation_CreateWithNoMetadatda_VerifySetFeatures() { var path = LuigiFileMetadataProgramInformationTestStorageAccess.Initialize(TestRomResources.TestLuigiFromBinPath).Single(); var rom = Rom.AsSpecificRomType <LuigiFormatRom>(Rom.Create(path, null)); Assert.NotNull(rom); var metadataBlock = rom.LocateDataBlock <LuigiMetadataBlock>(); Assert.Null(metadataBlock); var information = new LuigiFileMetadataProgramInformation(rom.Header, metadataBlock); var currentFeatures = information.Features; Assert.NotNull(currentFeatures); var testFeatures = currentFeatures.Clone(); testFeatures.Ecs = EcsFeatures.Printer; information.Features = testFeatures; Assert.NotEqual(testFeatures, currentFeatures); Assert.True(object.ReferenceEquals(testFeatures, information.Features)); }