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));
            }

            CorrExchangesPart part = new CorrExchangesPart();

            SetPartMetadata(part, roleId, item);

            for (int n = 1; n <= Randomizer.Seed.Next(1, 3 + 1); n++)
            {
                part.Exchanges.Add(new Faker <CorrExchange>()
                                   .RuleFor(e => e.IsDubious, f => f.Random.Bool(0.3f))
                                   .RuleFor(e => e.IsIndirect, f => f.Random.Bool())
                                   .RuleFor(e => e.IsFromParticipant, f => f.Random.Bool())
                                   .RuleFor(e => e.Chronotopes,
                                            new List <Chronotope> {
                    SeederHelper.GetChronotope("from", 1200)
                })
                                   .RuleFor(e => e.Participants, SeederHelper.GetDecoratedIds(1, 2))
                                   .RuleFor(e => e.Sources, SeederHelper.GetDocReferences(1, 3))
                                   .RuleFor(e => e.Attachments, SeederHelper.GetAttachments(1, 3))
                                   .Generate());
            }

            return(part);
        }
Ejemplo n.º 2
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));
            }

            AttachmentsPart part = new AttachmentsPart();

            SetPartMetadata(part, roleId, item);

            part.Attachments = SeederHelper.GetAttachments(1, 3);

            return(part);
        }