/// <summary> /// Gets a column. /// </summary> /// <param name="name">Identifies the column to get.</param> /// <returns>The database column, <c>null</c> if the column identified by <paramref name="name"/> cannot be found.</returns> public XmlRomInformationDatabaseColumn GetColumn(XmlRomInformationDatabaseColumnName name) { return(GetColumn(name, requiredColumn: false)); }
private static IEnumerable <Tuple <IProgramMetadata, XmlRomInformationDatabaseColumnName, string> > GetTestMetadataForColumn(XmlRomInformationDatabaseColumnName column, int numValues) { var strings = Enumerable.Repeat(string.Empty, 1); var suffixes = Enumerable.Range(0, numValues); var htmlEncode = true; var includeFirstOnly = false; string expectedString = null; for (int i = 0; i < 2; ++i) { var programMetadataBuilder = new ProgramMetadataBuilder(); expectedString = null; switch (column) { case XmlRomInformationDatabaseColumnName.title: programMetadataBuilder.WithLongNames(strings); includeFirstOnly = true; break; case XmlRomInformationDatabaseColumnName.short_name: programMetadataBuilder.WithShortNames(strings); includeFirstOnly = true; break; case XmlRomInformationDatabaseColumnName.vendor: programMetadataBuilder.WithPublishers(strings); includeFirstOnly = true; break; case XmlRomInformationDatabaseColumnName.description: programMetadataBuilder.WithDescriptions(strings); includeFirstOnly = true; break; case XmlRomInformationDatabaseColumnName.release_date: if (i == 0) { var date = new MetadataDateTimeBuilder(1981).WithMonth(12).WithDay(25).Build(); programMetadataBuilder.WithReleaseDates(new[] { date }); expectedString = "1981-12-25"; } else { var dates = suffixes.Select(d => new MetadataDateTimeBuilder(1982).WithMonth(8).WithDay(d + 1).Build()); programMetadataBuilder.WithReleaseDates(dates); expectedString = "1982-08-01"; } includeFirstOnly = true; break; case XmlRomInformationDatabaseColumnName.program: programMetadataBuilder.WithProgrammers(strings); break; case XmlRomInformationDatabaseColumnName.concept: programMetadataBuilder.WithDesigners(strings); break; case XmlRomInformationDatabaseColumnName.game_graphics: programMetadataBuilder.WithGraphics(strings); break; case XmlRomInformationDatabaseColumnName.soundfx: programMetadataBuilder.WithSoundEffects(strings); break; case XmlRomInformationDatabaseColumnName.music: programMetadataBuilder.WithMusic(strings); break; case XmlRomInformationDatabaseColumnName.voices: programMetadataBuilder.WithVoices(strings); break; case XmlRomInformationDatabaseColumnName.game_docs: programMetadataBuilder.WithDocumentation(strings); break; case XmlRomInformationDatabaseColumnName.box_art: programMetadataBuilder.WithArtwork(strings); break; case XmlRomInformationDatabaseColumnName.name: programMetadataBuilder.WithVersions(strings); includeFirstOnly = true; break; case XmlRomInformationDatabaseColumnName.build_date: if (i == 0) { var date = new MetadataDateTimeBuilder(1980).WithMonth(8).WithDay(4).Build(); programMetadataBuilder.WithBuildDates(new[] { date }); expectedString = "1980-08-04"; } else { var dates = suffixes.Select(d => new MetadataDateTimeBuilder(1984).WithMonth(6).WithDay(d + 12).Build()); programMetadataBuilder.WithBuildDates(dates); expectedString = "1984-06-12"; } includeFirstOnly = true; break; case XmlRomInformationDatabaseColumnName.other: programMetadataBuilder.WithAdditionalInformation(strings); break; case XmlRomInformationDatabaseColumnName.license: programMetadataBuilder.WithLicenses(strings); break; case XmlRomInformationDatabaseColumnName.contact_info: programMetadataBuilder.WithContactInformation(strings); htmlEncode = false; break; default: throw new InvalidOperationException(); } if (string.IsNullOrEmpty(expectedString)) { if (includeFirstOnly) { strings = new[] { strings.First() }; } if (htmlEncode) { expectedString = string.Join("|", strings.Select(s => HtmlEncode(s))); } else { expectedString = string.Join("|", strings); } } yield return(new Tuple <IProgramMetadata, XmlRomInformationDatabaseColumnName, string>(programMetadataBuilder.Build(), column, expectedString)); strings = suffixes.Select(s => "Abbott & Costello Part " + s.ToString(CultureInfo.InvariantCulture)); } yield return(new Tuple <IProgramMetadata, XmlRomInformationDatabaseColumnName, string>(new ProgramMetadata(), column, includeFirstOnly ? null : string.Empty)); }
public void XmlRomInformationDatabaseColumn_CreateWithColumnName_ValueNotNull(XmlRomInformationDatabaseColumnName name) { var column = new XmlRomInformationDatabaseColumn(name); Assert.Equal(name.ToString(), column.Name); Assert.NotNull(column.Value); }