Ejemplo n.º 1
0
        /// <summary>
        /// Creates and seeds a new part.
        /// </summary>
        /// <param name="item">The item this part should belong to.</param>
        /// <param name="roleId">The optional part role ID.</param>
        /// <param name="factory">The part seeder factory. This is used
        /// for layer parts, which need to seed a set of fragments.</param>
        /// <returns>A new part.</returns>
        /// <exception cref="ArgumentNullException">item or factory</exception>
        public override IPart GetPart(IItem item, string roleId,
                                      PartSeederFactory factory)
        {
            if (item == null)
            {
                throw new ArgumentNullException(nameof(item));
            }
            if (factory == null)
            {
                throw new ArgumentNullException(nameof(factory));
            }

            CitedPersonsPart part = new CitedPersonsPart();

            SetPartMetadata(part, roleId, item);

            part.Persons = SeederHelper.GetCitedPersons(1, 3);

            return(part);
        }
        /// <summary>
        /// Creates and seeds a new part.
        /// </summary>
        /// <param name="item">The item this part should belong to.</param>
        /// <param name="roleId">The optional part role ID.</param>
        /// <param name="factory">The part seeder factory. This is used
        /// for layer parts, which need to seed a set of fragments.</param>
        /// <returns>A new part.</returns>
        /// <exception cref="ArgumentNullException">item or factory</exception>
        public override IPart GetPart(IItem item, string roleId,
                                      PartSeederFactory factory)
        {
            if (item == null)
            {
                throw new ArgumentNullException(nameof(item));
            }
            if (factory == null)
            {
                throw new ArgumentNullException(nameof(factory));
            }

            SerialTextInfoPart part = new Faker <SerialTextInfoPart>()
                                      .RuleFor(p => p.TextId, f => f.Lorem.Word().ToLowerInvariant())
                                      .RuleFor(p => p.Language, f => f.PickRandom("ita", "fra", "lat"))
                                      .RuleFor(p => p.Subject, f => f.Lorem.Sentence(2, 4))
                                      .RuleFor(p => p.Genre, f => f.PickRandom(new string[]
                                                                               { "lettera", "canzone" }))
                                      .RuleFor(p => p.Verse, f => f.PickRandom(new string[]
                                                                               { "settenario", "ottonario" }))
                                      .RuleFor(p => p.Rhyme, f => f.PickRandom(new string[]
            {
                "AABBCC", "ABCA"
            }))
                                      .RuleFor(p => p.Authors, SeederHelper.GetCitedPersons(1, 3))
                                      .RuleFor(p => p.Headings, f =>
                                               new List <string>(new[] { f.Lorem.Sentence(3, 5) }))
                                      .RuleFor(p => p.Recipients, SeederHelper.GetDecoratedIds(1, 3))
                                      .RuleFor(p => p.ReplyingTo, SeederHelper.GetDecoratedIds(1, 3))
                                      .RuleFor(p => p.Note, f => f.Lorem.Sentence())
                                      .Generate();

            SetPartMetadata(part, roleId, item);

            return(part);
        }