/// <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)); } DrawingInfoPart part = new Faker <DrawingInfoPart>() .RuleFor(p => p.Description, f => f.Lorem.Sentence()) // TODO: add thesaurus-derived values for subjects .RuleFor(p => p.Subjects, f => new List <string>(new[] { f.PickRandom("man", "animal") })) .RuleFor(p => p.Date, f => HistoricalDate.Parse($"{f.Random.Number(1500, 1600)} AD")) .RuleFor(p => p.Color, f => f.PickRandom("black", "red")) .RuleFor(p => p.Links, f => f.Random.Bool(0.2f)? new List <TaggedId>(new TaggedId[] { new TaggedId { Id = f.Lorem.Word().ToLowerInvariant(), Tag = f.Lorem.Word().ToLowerInvariant() } }) : null) .Generate(); SetPartMetadata(part, roleId, item); 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)); } ChronotopicsPart part = new ChronotopicsPart(); SetPartMetadata(part, roleId, item); for (int n = 1; n <= Randomizer.Seed.Next(1, 3 + 1); n++) { part.Chronotopes.Add(new Faker <Chronotope>() .RuleFor(c => c.Tag, f => f.Lorem.Word()) .RuleFor(c => c.Place, f => f.Lorem.Word()) .RuleFor(c => c.Date, HistoricalDate.Parse($"{1200 + n} AD")) .Generate()); } return(part); }
private static List <MsHistoryPerson> GetPersons(int count) { List <MsHistoryPerson> persons = new List <MsHistoryPerson>(); for (int n = 1; n <= count; n++) { persons.Add(new MsHistoryPerson { Role = "owner", Name = new PersonName { Language = "eng", Parts = new List <PersonNamePart> { new PersonNamePart { Type = "first", Value = "Robert" }, new PersonNamePart { Type = "last", Value = $"Mc{n}" } } }, Date = HistoricalDate.Parse((1200 + n) .ToString(CultureInfo.InvariantCulture) + " AD"), Note = "Note", ExternalIds = new List <string>(new[] { "uri" }) }); } return(persons); }
/// <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)); } int birth = Randomizer.Seed.Next(1500, 1520); PrisonerInfoPart part = new Faker <PrisonerInfoPart>() .RuleFor(p => p.PrisonerId, f => f.Lorem.Word().ToLowerInvariant()) .RuleFor(p => p.PrisonId, f => f.Lorem.Word().ToLowerInvariant()) .RuleFor(p => p.Sex, f => f.PickRandom('M', 'F')) .RuleFor(p => p.Name, SeederHelper.GetPersonName()) .RuleFor(p => p.BirthDate, HistoricalDate.Parse($"{birth} AD")) .RuleFor(p => p.DeathDate, HistoricalDate.Parse($"{birth + 40} AD")) // TODO: use thesauri for these data .RuleFor(p => p.Origin, f => f.PickRandom("it", "fr", "sp")) .RuleFor(p => p.Charge, f => f.PickRandom( "heresy", "blasphemy", "witchcraft")) .RuleFor(p => p.Judgement, f => f.PickRandom("conviction", "acquittal")) .RuleFor(p => p.DetentionStart, HistoricalDate.Parse($"{birth + 20} AD")) .RuleFor(p => p.DetentionEnd, HistoricalDate.Parse($"{birth + 40} AD")) .Generate(); SetPartMetadata(part, roleId, item); return(part); }
private static ChronotopicsPart GetPart(int count) { ChronotopicsPart part = new ChronotopicsPart { ItemId = Guid.NewGuid().ToString(), RoleId = "some-role", CreatorId = "zeus", UserId = "another", }; for (int n = 1; n <= count; n++) { HistoricalDate date = HistoricalDate.Parse(n + 1200 + " AD"); var coords = new Chronotope { Tag = n % 2 == 0? "even" : "odd", Place = $"place {n}", Date = date, TextDate = $"text date {n}", Sources = TestHelper.GetDocReferences(2) }; part.Chronotopes.Add(coords); } return(part); }
private static PersonEventsPart GetPart(int count) { PersonEventsPart part = new PersonEventsPart { ItemId = Guid.NewGuid().ToString(), RoleId = "some-role", CreatorId = "zeus", UserId = "another", }; for (int n = 1; n <= count; n++) { part.Events.Add(new BioEvent { Type = n % 2 == 0 ? "even" : "odd", Date = HistoricalDate.Parse($"{1200 + n} AD"), Places = new List <string>(new[] { "place-1", "place-2" }), Description = "A description.", Sources = TestHelper.GetDocReferences(2), Participants = new List <DecoratedId>(new[] { new DecoratedId { Id = "guy-1", Tag = "tag", Rank = 1 }, new DecoratedId { Id = "guy-2", Tag = "tag", Rank = 1 } }) }); } return(part); }
private List <MsHand> GetHands(int count) { List <MsHand> hands = new List <MsHand>(); for (int n = 1; n <= count; n++) { bool even = n % 2 == 0; hands.Add(new Faker <MsHand>() .RuleFor(h => h.Id, f => f.Lorem.Word()) .RuleFor(h => h.Date, HistoricalDate.Parse($"{1300 + n}")) .RuleFor(h => h.Start, f => new MsLocation { N = n, S = even ? "v" : "r", L = f.Random.Number(1, 40) }) .RuleFor(h => h.End, f => new MsLocation { N = n + 3, S = even ? "v" : "r", L = f.Random.Number(1, 40) }) .RuleFor(h => h.Description, f => f.Lorem.Sentence()) .RuleFor(h => h.Abbreviations, f => f.Lorem.Sentence()) .RuleFor(h => h.Letters, f => GetLetters(f.Random.Number(0, 3))) .Generate()); } return(hands); }
private static LitDedicationsPart GetPart(int count) { LitDedicationsPart part = new LitDedicationsPart { ItemId = Guid.NewGuid().ToString(), RoleId = "some-role", CreatorId = "zeus", UserId = "another", }; for (int n = 1; n <= count; n++) { HistoricalDate date = HistoricalDate.Parse(n + 1200 + " AD"); var dedication = new LitDedication { Title = $"Dedication {n}", Date = date, DateSent = n % 2 == 0 ? date : null, Participants = new List <DecoratedId>(new[] { new DecoratedId { Id = $"guy{n}", Rank = 1, Tag = "target", Sources = TestHelper.GetDocReferences(1) } }), Sources = TestHelper.GetDocReferences(2) }; part.Dedications.Add(dedication); } 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)); } MsWatermarksPart part = new MsWatermarksPart(); SetPartMetadata(part, roleId, item); for (int n = 1; n <= Randomizer.Seed.Next(1, 3 + 1); n++) { part.Watermarks.Add(new Faker <MsWatermark>() .RuleFor(w => w.Subject, f => f.Lorem.Word()) .RuleFor(w => w.SimilarityRank, f => f.Random.Short(1, 5)) .RuleFor(w => w.Description, f => f.Lorem.Sentence()) .RuleFor(w => w.Place, f => f.Lorem.Word()) .RuleFor(w => w.Date, HistoricalDate.Parse($"{1200 + n} AD")) .RuleFor(w => w.ExternalIds, SeederHelper.GetExternalIds(1, 3)) .Generate()); } 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)); } MsMaterialDscPart part = new Faker <MsMaterialDscPart>() .RuleFor(p => p.Material, f => f.PickRandom("paper", "parchment")) .RuleFor(p => p.Format, f => f.Lorem.Word()) .RuleFor(p => p.State, f => f.Lorem.Word()) .RuleFor(p => p.StateNote, f => f.Lorem.Sentence()) .Generate(); SetPartMetadata(part, roleId, item); // counts for (int n = 1; n <= Randomizer.Seed.Next(1, 3 + 1); n++) { part.Counts.Add(new Faker <DecoratedCount>() .RuleFor(d => d.Id, f => f.Lorem.Word()) .RuleFor(d => d.Value, f => f.Random.Number(1, 100)) .RuleFor(d => d.Note, f => f.PickRandom(null, f.Lorem.Sentence())) .Generate()); } // palimpsests for (int n = 1; n <= Randomizer.Seed.Next(1, 3 + 1); n++) { part.Palimpsests.Add(new Faker <MsPalimpsest>() .RuleFor(p => p.Range, f => new MsLocationRange { Start = new MsLocation { N = (short)n, S = n % 2 == 0 ? "v" : "r", L = (short)(f.Random.Number(1, 20)) }, End = new MsLocation { N = (short)n + 1, S = (n + 1) % 2 == 0 ? "v" : "r", L = (short)(f.Random.Number(1, 20)) } }) .RuleFor(p => p.Date, HistoricalDate.Parse($"{1300 + n} AD")) .Generate()); } return(part); }
/// <summary> /// Gets a chronotope. /// </summary> /// <param name="tag">The tag.</param> /// <param name="year">The year.</param> /// <returns>The chronotope.</returns> public static Chronotope GetChronotope(string tag, int year) { return(new Faker <Chronotope>() .RuleFor(c => c.Tag, tag) .RuleFor(c => c.Place, f => f.Address.City()) .RuleFor(c => c.Date, HistoricalDate.Parse($"{year} AD")) .RuleFor(c => c.TextDate, f => f.Lorem.Sentence(3)) .RuleFor(c => c.Sources, GetDocReferences(1, 3)) .Generate()); }
private static ChronologyLayerFragment GetFragment() { return(new ChronologyLayerFragment { Location = "1.23", Label = "Battle of Marathon", Tag = "battle", Date = HistoricalDate.Parse("490 BC") }); }
public void GetDataPins_Coordinates_Ok() { ChronotopicsPart part = GetPart(3); List <DataPin> pins = part.GetDataPins(null).ToList(); Assert.Equal(12, pins.Count); TestHelper.AssertValidDataPinNames(pins); DataPin pin = pins.Find(p => p.Name == "tot-count"); Assert.NotNull(pin); TestHelper.AssertPinIds(part, pin); Assert.Equal("3", pin.Value); pin = pins.Find(p => p.Name == "tag-even-count"); Assert.NotNull(pin); TestHelper.AssertPinIds(part, pin); Assert.Equal("1", pin.Value); pin = pins.Find(p => p.Name == "tag-odd-count"); Assert.NotNull(pin); TestHelper.AssertPinIds(part, pin); Assert.Equal("2", pin.Value); pin = pins.Find(p => p.Name == "tag-place" && p.Value == "odd:place 1"); Assert.NotNull(pin); TestHelper.AssertPinIds(part, pin); pin = pins.Find(p => p.Name == "tag-place" && p.Value == "even:place 2"); Assert.NotNull(pin); TestHelper.AssertPinIds(part, pin); pin = pins.Find(p => p.Name == "tag-place" && p.Value == "odd:place 3"); Assert.NotNull(pin); TestHelper.AssertPinIds(part, pin); for (int n = 1; n <= 3; n++) { HistoricalDate date = HistoricalDate.Parse(n + 1200 + " AD"); double d = date.GetSortValue(); pin = pins.Find(p => p.Name == "date-value" && p.Value == d.ToString(CultureInfo.InvariantCulture)); Assert.NotNull(pin); TestHelper.AssertPinIds(part, pin); string tag = n % 2 == 0 ? "even" : "odd"; pin = pins.Find(p => p.Name == "tag-date" && p.Value == $"{tag}:{+d:0000.00;-d:0000.00}"); Assert.NotNull(pin); TestHelper.AssertPinIds(part, pin); } }
private static MsCompositionPart GetPart(int sectionCount) { MsCompositionPart part = new MsCompositionPart { ItemId = Guid.NewGuid().ToString(), RoleId = "some-role", CreatorId = "zeus", UserId = "another", SheetCount = 10, GuardSheetCount = 2 }; for (int n = 1; n <= sectionCount; n++) { string oddEven = n % 2 == 0 ? "even" : "odd"; part.GuardSheets.Add(new MsGuardSheet { IsBack = n % 2 == 0, Material = oddEven, Range = new MsLocationRange { Start = new MsLocation { N = n, S = n % 2 == 0 ? "v" : "r", L = 1 }, End = new MsLocation { N = n + 1, S = n % 2 == 0 ? "v" : "r", L = 1 } }, Date = HistoricalDate.Parse(n + 1300 + " AD") }); part.Sections.Add(new MsSection { Tag = oddEven, Label = $"Section {n}", Date = HistoricalDate.Parse(n + 1200 + " AD"), Start = new MsLocation { N = (short)n, S = n % 2 == 0 ? "v" : "r", L = 1 } }); } return(part); }
private static HistoricalDatePart GetPart() { return(new HistoricalDatePart { ItemId = Guid.NewGuid().ToString(), RoleId = "some-role", CreatorId = "zeus", UserId = "another", Date = HistoricalDate.Parse("c. 12 mag 23 AD -- 25 AD") }); }
private static PersonPart GetPart() { return(new PersonPart { ItemId = Guid.NewGuid().ToString(), RoleId = "some-role", CreatorId = "zeus", UserId = "another", PersonId = "dillinger", ExternalIds = new List <string>( new[] { "dillinger", "villains.com/dillinger" }), Names = new List <PersonName>(new[] { new PersonName { Language = "eng", Tag = "tag", Parts = new List <PersonNamePart>( new[] { new PersonNamePart { Type = "first", Value = "John" }, new PersonNamePart { Type = "last", Value = "Dillinger" } }) } }), Sex = 'M', Chronotopes = new List <Chronotope>(new[] { new Chronotope { Tag = "birth", Date = HistoricalDate.Parse("1903"), TextDate = "A text date.", Place = "Indianapolis", Sources = TestHelper.GetDocReferences(2) }, new Chronotope { Tag = "death", Date = HistoricalDate.Parse("1934"), Place = "Chicago" } }), Bio = "The bio." }); }
private static MsMaterialDscPart GetPart() { return(new MsMaterialDscPart { ItemId = Guid.NewGuid().ToString(), RoleId = "some-role", CreatorId = "zeus", UserId = "another", Material = "material", Format = "format", State = "state", StateNote = "A note about state.", Counts = new List <DecoratedCount>(new[] { new DecoratedCount { Id = "sheets", Value = 24, Note = "Note" }, new DecoratedCount { Id = "guard-sheets", Value = 2, Note = "Note" } }), Palimpsests = new List <MsPalimpsest>(new[] { new MsPalimpsest { Range = new MsLocationRange { Start = new MsLocation { N = 3, S = "v", L = 1 }, End = new MsLocation { N = 4, S = "r", L = 20 } }, Date = HistoricalDate.Parse("1200 AD"), Note = "Note" } }) }); }
public void GetDataPins_Events_Ok() { PersonEventsPart part = GetPart(3); List <DataPin> pins = part.GetDataPins(null).ToList(); Assert.Equal(10, pins.Count); TestHelper.AssertValidDataPinNames(pins); DataPin pin = pins.Find(p => p.Name == "tot-count"); Assert.NotNull(pin); TestHelper.AssertPinIds(part, pin); Assert.Equal("3", pin.Value); pin = pins.Find(p => p.Name == "type-odd-count" && p.Value == "2"); Assert.NotNull(pin); TestHelper.AssertPinIds(part, pin); pin = pins.Find(p => p.Name == "type-even-count" && p.Value == "1"); Assert.NotNull(pin); TestHelper.AssertPinIds(part, pin); for (int n = 1; n <= 3; n++) { double expected = HistoricalDate.Parse($"{1200 + n} AD") .GetSortValue(); pin = pins.Find(p => p.Name == "date-value" && p.Value == expected.ToString(CultureInfo.InvariantCulture)); Assert.NotNull(pin); TestHelper.AssertPinIds(part, pin); } for (int n = 1; n <= 2; n++) { pin = pins.Find(p => p.Name == "place" && p.Value == $"place{n}"); Assert.NotNull(pin); TestHelper.AssertPinIds(part, pin); pin = pins.Find(p => p.Name == "participant" && p.Value == $"tag:guy{n}"); Assert.NotNull(pin); TestHelper.AssertPinIds(part, pin); } }
public void GetDataPins_Ok() { GraffitiInfoPart part = GetEmptyPart(); part.GraffitiId = "gid"; part.Language = "lat"; part.Verse = "7s"; part.Rhyme = "AABB"; part.Author = "Stephanus"; part.Identifications.Add(new RankedId { Id = "steph", Rank = 1 }); part.Date = HistoricalDate.Parse("1500"); List <DataPin> pins = part.GetDataPins(null).ToList(); Assert.Equal(6, pins.Count); DataPin pin = pins.Find(p => p.Name == "id" && p.Value == "gid"); Assert.NotNull(pin); TestHelper.AssertPinIds(part, pin); pin = pins.Find(p => p.Name == "language" && p.Value == "lat"); Assert.NotNull(pin); TestHelper.AssertPinIds(part, pin); pin = pins.Find(p => p.Name == "verse" && p.Value == "7s"); Assert.NotNull(pin); TestHelper.AssertPinIds(part, pin); pin = pins.Find(p => p.Name == "author" && p.Value == "stephanus"); Assert.NotNull(pin); TestHelper.AssertPinIds(part, pin); pin = pins.Find(p => p.Name == "pid" && p.Value == "steph"); Assert.NotNull(pin); TestHelper.AssertPinIds(part, pin); pin = pins.Find(p => p.Name == "date-value" && p.Value == "1500"); Assert.NotNull(pin); TestHelper.AssertPinIds(part, pin); }
private static List <MsRestoration> GetRestorations(int count) { List <MsRestoration> annotations = new List <MsRestoration>(); for (int n = 1; n <= count; n++) { annotations.Add(new MsRestoration { Type = n % 2 == 0 ? "even" : "odd", Place = "place", Date = HistoricalDate.Parse((1200 + n).ToString() + " AD"), Note = "A note.", Sources = TestHelper.GetDocReferences(2) }); } return(annotations); }
/// <summary> /// Gets a random number of chronotopes. /// </summary> /// <param name="min">The min number of chronotopes to get.</param> /// <param name="max">The max number of chronotopes to get.</param> /// <returns>References.</returns> public static List <Chronotope> GetChronotopes(int min, int max) { List <Chronotope> refs = new List <Chronotope>(); for (int n = 1; n <= Randomizer.Seed.Next(min, max + 1); n++) { refs.Add(new Faker <Chronotope>() .RuleFor(r => r.Tag, f => f.PickRandom(null, "tag")) .RuleFor(r => r.Place, f => f.Address.City()) .RuleFor(r => r.IsPlaceDubious, f => f.Random.Bool(0.2f)) .RuleFor(r => r.Date, HistoricalDate.Parse($"{1300 + n} AD")) .RuleFor(r => r.TextDate, f => f.PickRandom(null, "text date")) .RuleFor(r => r.Sources, GetDocReferences(1, 3)) .Generate()); } return(refs); }
public static List <Chronotope> GetChronotopes(int count) { List <Chronotope> chronotopes = new List <Chronotope>(); for (int n = 1; n <= count; n++) { chronotopes.Add(new Chronotope { Place = $"place-{n}", Date = HistoricalDate.Parse((1300 + n) + " AD"), IsPlaceDubious = n % 1 != 0, Sources = GetDocReferences(1), Tag = "tag", TextDate = "text date" }); } return(chronotopes); }
public void GetDataPins_Watermarks_Ok() { MsWatermarksPart part = GetPart(3); List <DataPin> pins = part.GetDataPins(null).ToList(); Assert.Equal(9, pins.Count); TestHelper.AssertValidDataPinNames(pins); // tot-count DataPin pin = pins.Find(p => p.Name == "tot-count"); Assert.NotNull(pin); TestHelper.AssertPinIds(part, pin); Assert.Equal("3", pin.Value); pin = pins.Find(p => p.Name == "subject-even-count"); Assert.NotNull(pin); TestHelper.AssertPinIds(part, pin); Assert.Equal("1", pin.Value); pin = pins.Find(p => p.Name == "subject-odd-count"); Assert.NotNull(pin); TestHelper.AssertPinIds(part, pin); Assert.Equal("2", pin.Value); for (int n = 1; n <= 3; n++) { // place pin = pins.Find(p => p.Name == "place" && p.Value == $"place {n}"); Assert.NotNull(pin); TestHelper.AssertPinIds(part, pin); // date-value HistoricalDate date = HistoricalDate.Parse(n + 1200 + " AD"); double value = date.GetSortValue(); pin = pins.Find(p => p.Name == "date-value" && p.Value == value.ToString(CultureInfo.InvariantCulture)); Assert.NotNull(pin); TestHelper.AssertPinIds(part, pin); } }
public void GetDataPins_Tag_1() { DrawingInfoPart part = GetEmptyPart(); part.Description = "A description"; part.Subjects.Add("subject-1"); part.Subjects.Add("subject-2"); part.Date = HistoricalDate.Parse("1523 AD"); part.Color = "red"; part.Links.Add(new TaggedId { Id = "target-1", Tag = "tag" }); List <DataPin> pins = part.GetDataPins(null).ToList(); Assert.Equal(5, pins.Count); DataPin pin = pins.Find( p => p.Name == "subject" && p.Value == "subject-1"); Assert.NotNull(pin); TestHelper.AssertPinIds(part, pin); pin = pins.Find( p => p.Name == "subject" && p.Value == "subject-2"); Assert.NotNull(pin); TestHelper.AssertPinIds(part, pin); pin = pins.Find(p => p.Name == "date-value" && p.Value == "1523"); Assert.NotNull(pin); TestHelper.AssertPinIds(part, pin); pin = pins.Find(p => p.Name == "color" && p.Value == "red"); Assert.NotNull(pin); TestHelper.AssertPinIds(part, pin); pin = pins.Find(p => p.Name == "target-id" && p.Value == "target-1"); Assert.NotNull(pin); TestHelper.AssertPinIds(part, pin); }
private static CorrExchangesPart GetPart(int count) { CorrExchangesPart part = new CorrExchangesPart { ItemId = Guid.NewGuid().ToString(), RoleId = "some-role", CreatorId = "zeus", UserId = "another" }; for (int n = 1; n <= count; n++) { part.Exchanges.Add(new CorrExchange { IsDubious = n % 2 == 0, IsIndirect = n % 2 == 0, IsFromParticipant = n % 2 != 0, Chronotopes = new List <Chronotope>(new[] { new Chronotope { Tag = "from", Date = HistoricalDate.Parse(n + 1200 + " AD"), TextDate = "kal.apr.", Place = (n % 2 == 0? "Even" : "Odd") + " town", Sources = TestHelper.GetDocReferences(2) }, new Chronotope { Tag = "to", Date = HistoricalDate.Parse(n + 1201 + " AD"), Place = (n % 2 == 0 ? "Even" : "Odd") + " lake" } }), Participants = GetParticipants(2), Sources = TestHelper.GetDocReferences(2), Attachments = GetAttachments(2) }); } 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)); } MsDecorationsPart part = new MsDecorationsPart(); SetPartMetadata(part, roleId, item); int count = Randomizer.Seed.Next(1, 3); for (int n = 1; n <= count; n++) { int sn = (n - 1) * 2; part.Decorations.Add(new Faker <MsDecoration>() .RuleFor(d => d.Id, f => "d" + f.UniqueIndex) .RuleFor(d => d.Name, f => f.Lorem.Word()) .RuleFor(d => d.Type, f => f.PickRandom(_types)) .RuleFor(d => d.Date, HistoricalDate.Parse($"{1300 + n} AD")) .RuleFor(d => d.Flags, f => new List <string>(new[] { f.PickRandom(_flags) })) .RuleFor(d => d.Place, f => f.Address.Country()) .RuleFor(d => d.Artist, GetArtist()) .RuleFor(d => d.Note, f => f.Random.Bool(0.25f) ? f.Lorem.Sentence() : null) .RuleFor(d => d.References, SeederHelper.GetDocReferences(1, 3)) .RuleFor(d => d.Elements, f => GetElements(f.Random.Number(1, 3), f)) .Generate()); } 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)); } GraffitiInfoPart part = new Faker <GraffitiInfoPart>() .RuleFor(p => p.GraffitiId, f => f.Lorem.Word().ToLowerInvariant()) .RuleFor(p => p.Language, f => f.PickRandom("ita", "lat")) .RuleFor(p => p.Verse, f => f.PickRandom(null, "7s")) .RuleFor(p => p.Rhyme, f => f.PickRandom("AABB", "ABAB")) .RuleFor(p => p.Author, f => f.Person.FirstName) .RuleFor(p => p.Identifications, GetIds(1, 3)) .RuleFor(p => p.Date, f => HistoricalDate.Parse ($"{f.Random.Number(1500, 1600)} AD")) .Generate(); SetPartMetadata(part, roleId, item); return(part); }
public void GetDataPins_Dedications_Ok() { LitDedicationsPart part = GetPart(3); List <DataPin> pins = part.GetDataPins(null).ToList(); Assert.Equal(10, pins.Count); TestHelper.AssertValidDataPinNames(pins); // tot-count DataPin pin = pins.Find(p => p.Name == "tot-count"); Assert.NotNull(pin); TestHelper.AssertPinIds(part, pin); Assert.Equal("3", pin.Value); for (int n = 1; n <= 3; n++) { // title pin = pins.Find(p => p.Name == "title" && p.Value == $"dedication {n}"); Assert.NotNull(pin); TestHelper.AssertPinIds(part, pin); // date-value HistoricalDate date = HistoricalDate.Parse(n + 1200 + " AD"); double value = date.GetSortValue(); pin = pins.Find(p => p.Name == "date-value" && p.Value == value.ToString(CultureInfo.InvariantCulture)); Assert.NotNull(pin); TestHelper.AssertPinIds(part, pin); // pid pin = pins.Find(p => p.Name == "pid" && p.Value == $"guy{n}"); Assert.NotNull(pin); TestHelper.AssertPinIds(part, pin); } }
/// <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)); } PersonEventsPart part = new PersonEventsPart(); SetPartMetadata(part, roleId, item); for (int n = 1; n <= Randomizer.Seed.Next(1, 3 + 1); n++) { part.Events.Add(new Faker <BioEvent>() .RuleFor(e => e.Type, f => n == 1? "birth" : f.PickRandom("work", "marriage")) .RuleFor(e => e.Date, HistoricalDate.Parse($"{n} AD")) .RuleFor(e => e.Places, f => new List <string>(new[] { f.Lorem.Word() })) .RuleFor(e => e.Description, f => f.Lorem.Sentence()) .RuleFor(e => e.Sources, SeederHelper.GetDocReferences(1, 3)) .RuleFor(e => e.Participants, SeederHelper.GetDecoratedIds(1, 3)) .RuleFor(e => e.Work, f => f.Lorem.Sentence(1, 3)) .RuleFor(e => e.Rank, f => f.Random.Short(0, 3)) .RuleFor(e => e.IsWorkDubious, f => f.Random.Bool(0.2f)) .RuleFor(e => e.IsWorkLost, f => f.Random.Bool(0.2f)) .RuleFor(e => e.ExternalIds, SeederHelper.GetExternalIds(1, 3)) .Generate()); } return(part); }
private static MsDecorationsPart GetPart(int count) { MsDecorationsPart part = new MsDecorationsPart { ItemId = Guid.NewGuid().ToString(), RoleId = "some-role", CreatorId = "zeus", UserId = "another", }; for (int n = 1; n <= count; n++) { string alt = n % 2 == 0 ? "even" : "odd"; part.Decorations.Add(new MsDecoration { Id = $"d{n}", Name = "Decoration " + n, Type = n % 2 == 0? "even" : "odd", Date = HistoricalDate.Parse($"{1300 + n}"), Flags = new List <string>(new[] { "f-" + alt }), Place = "Paris", Note = "Note", Artist = new MsDecorationArtist { Id = "artist", Name = "name", Note = "note", Type = "type", Sources = TestHelper.GetDocReferences(2) }, References = TestHelper.GetDocReferences(1), Elements = GetElements(3) }); } return(part); }