/// <summary> /// Determines if the given program ROM can be accepted. /// </summary> /// <returns><c>true</c> if the ROM can be accepted in the menu; otherwise, <c>false</c>.</returns> /// <param name="program">A program ROM.</param> /// <param name="reasonForRejection">Receives a reason for why a ROM was not accepted.</param> /// <remarks>ROMs that are too large, or are identified as 'System' ROMs are rejected.</remarks> internal static bool IsAcceptableRom(ProgramDescription program, out string reasonForRejection) { reasonForRejection = null; var rom = program.GetRom(); var file = rom.RomPath; var accept = !program.Features.GeneralFeatures.HasFlag(GeneralFeatures.SystemRom); if (!accept) { reasonForRejection = Resources.Strings.AddItemRejected_NotPlayable; } if (accept) { accept = !string.IsNullOrWhiteSpace(file); if (!accept) { reasonForRejection = Resources.Strings.AddItemRejected_NoFileName; } } if (accept) { accept = System.IO.File.Exists(file); if (!accept) { reasonForRejection = Resources.Strings.AddItemRejected_FileNotFound; } } if (accept) { var fileInfo = new System.IO.FileInfo(file); accept = (fileInfo.Length <= INTV.Core.Model.Rom.MaxROMSize) && (fileInfo.Length <= Device.TotalRAMSize); if (!accept) { reasonForRejection = string.Format(Resources.Strings.AddItemRejected_FileTooLargeFormat, fileInfo.Length, System.Math.Min(INTV.Core.Model.Rom.MaxROMSize, Device.TotalRAMSize)); } } return(accept); }
public void ProgramDescription_GetRomWhenDescriptionIsNull_ThrowsNullReferenceException() { ProgramDescription description = null; Assert.Throws <NullReferenceException>(() => description.GetRom()); }