using System.Configuration;
using System.Collections.Generic;
public static void Main()
acc = Builder<Account>.CreateNew().With(x => x.ID = "1").Build();
subs = (List<Subscription>)Builder<Subscription>.CreateListOfSize(20).All().With(s => s.ID).Build();
addOns = (List<AddOn>)Builder<AddOn>.CreateListOfSize(20).All().With(a => a.Quantity = 3).Build();
GenerateAddOnVariations(rdn, addOns);
GenerateSubscriptionVariationsAddingAddOn(rdn, subs, addOns);
acc.Subscriptions = subs;
foreach (var item in acc.Subscriptions)
Console.WriteLine(item.ID);
var groupAddOnsByCode = acc.Subscriptions.Select(s => s.AddOns.GroupBy(a => a.Variations.Select(v => v.Code).FirstOrDefault())).ToList();
public IEnumerable<Subscription> Subscriptions
public class Subscription
public IEnumerable<AddOn> AddOns
public IEnumerable<Variation> Variations
public IEnumerable<Variation> Variations
public string ValueExternal
private static void GenerateAddOnVariations(Random rdn, List<AddOn> addOns)
foreach (var addOn in addOns)
var _genAddOnVar = Builder<Variation>.CreateListOfSize(1).All().With(v => v.Code = rdn.Next(1, 4).ToString()).Build();
addOn.Variations = _genAddOnVar;
private static void GenerateSubscriptionVariationsAddingAddOn(Random rdn, List<Subscription> subs, List<AddOn> addOns)
foreach (var sub in subs)
var _genSubVar = Builder<Variation>.CreateListOfSize(1).All().With(v => v.Code = rdn.Next(1, 4).ToString()).Build();
sub.Variations = _genSubVar;