public static IListBuilder <Product> AllWithLongTitles(this IListBuilder <Product> listBuilder) { var listBuilderImpl = (IListBuilderImpl <Product>)listBuilder; var declaration = new GlobalDeclaration <Product>(listBuilderImpl, listBuilderImpl.CreateObjectBuilder()); declaration.With(x => x.Title = "blahblahblahblahblahblahblahblahblahblahblahblahblahblah"); return(declaration); }
public static IList <T> Persist <T>(this IListBuilder <T> listBuilder) { var list = listBuilder.Build(); var persistenceService = listBuilder.BuilderSettings.GetPersistenceService(); persistenceService.Create(list); return(list); }
public static IList <T> BuildHierarchy <T>(this IListBuilder <T> listBuilder, IHierarchySpec <T> hierarchySpec) { var list = listBuilder.Build(); var hierarchy = new HierarchyGenerator <T>(list, hierarchySpec.AddMethod, hierarchySpec.NumberOfRoots, hierarchySpec.Depth, hierarchySpec.MinimumChildren, hierarchySpec.MaximumChildren, new RandomGenerator(), hierarchySpec.NamingMethod, null).Generate(); return(hierarchy); }
public static IOperable <T> TheFirst <T>(this IListBuilder <T> listBuilder, int amount) { var listBuilderImpl = GetListBuilderImpl <T>(listBuilder); Guard.Against(amount < 1, "TheFirst amount must be 1 or greater"); Guard.Against(amount > listBuilderImpl.Capacity, "TheFirst amount must be less than the size of the list that is being generated"); var declaration = new RangeDeclaration <T>(listBuilderImpl, listBuilderImpl.CreateObjectBuilder(), 0, amount - 1); return((IOperable <T>)listBuilderImpl.AddDeclaration(declaration)); }
public static IOperable <T> AllEven <T>(this IListBuilder <T> listBuilder) { var listBuilderImpl = listBuilder as Implementation.IListBuilderImpl <T>; if (listBuilderImpl == null) { throw new ArgumentException("List builder must implement IListBuilderImpl<T>"); } return((IOperable <T>)listBuilderImpl.AddDeclaration(new EvenDeclaration <T>(listBuilderImpl, listBuilderImpl.CreateObjectBuilder()))); }
public static IOperable <T> Random <T>(this IListBuilder <T> listBuilder, int amount, int start, int end) { var listBuilderImpl = GetListBuilderImpl <T>(listBuilder); // TODO: Put these in a specification Guard.Against(amount < 1, "Random amount must be 1 or greater"); Guard.Against(amount > listBuilderImpl.Capacity, "Random amount must be less than the size of the list that is being generated"); var declaration = new RandomDeclaration <T>(listBuilderImpl, listBuilderImpl.CreateObjectBuilder(), listBuilderImpl.ScopeUniqueRandomGenerator, amount, start, end); return((IOperable <T>)listBuilderImpl.AddDeclaration(declaration)); }
public static IList <T> PersistHierarchy <T>(this IListBuilder <T> listBuilder, IHierarchySpec <T> hierarchySpec) { // 1. Create var list = listBuilder.Build(); // 2. Reorganise var hierarchy = new HierarchyGenerator <T>(list, hierarchySpec.AddMethod, hierarchySpec.NumberOfRoots, hierarchySpec.Depth, hierarchySpec.MinimumChildren, hierarchySpec.MaximumChildren, new RandomGenerator(), hierarchySpec.NamingMethod, listBuilder.BuilderSetup.GetPersistenceService()).Generate(); return(hierarchy); }
public static IOperable <T> IndexOf <T>(this IListBuilder <T> listBuilder, params int[] indexes) { Guard.Against(indexes == null, new ArgumentNullException(nameof(indexes))); Guard.Against(indexes.Length < 1, new ArgumentException(nameof(indexes), "At least one item should be included")); var listBuilderImpl = GetListBuilderImpl <T>(listBuilder); Guard.Against(indexes.Any(i => i < 0), new ArgumentOutOfRangeException(nameof(indexes), "Index must be 0 or greater")); Guard.Against(indexes.Any(i => i > listBuilderImpl.Capacity - 1), new ArgumentOutOfRangeException(nameof(indexes), $"Index must be less than the size of the list ({listBuilderImpl.Capacity}) that is being generated")); var declaration = new IndexedElementDeclaration <T>(listBuilderImpl, listBuilderImpl.CreateObjectBuilder(), indexes); return((IOperable <T>)listBuilderImpl.AddDeclaration(declaration)); }
public static IListBuilder <TopMakelaar> WithDefaults( this IListBuilder <TopMakelaar> topMakelaarBuilder, bool hasTuin = false) { if (topMakelaarBuilder == null) { throw new ArgumentNullException(nameof(topMakelaarBuilder)); } return(topMakelaarBuilder .All() .And(x => x.MakelaarId = hasTuin ? MakelaarsTestDefaults.MakelaarIdWithTuin : MakelaarsTestDefaults.MakelaarId) .And(x => x.Count = MakelaarsTestDefaults.Count) .And(x => x.MakelaarName = hasTuin ? MakelaarsTestDefaults.MakelaarNaamWithTuin : MakelaarsTestDefaults.MakelaarNaam)); }
public static IOperable <T> TheLast <T>(this IListBuilder <T> listBuilder, int amount) { var listBuilderImpl = GetListBuilderImpl <T>(listBuilder); // TODO: Put these in a specification Guard.Against(amount < 1, "TheLast amount must be 1 or greater"); Guard.Against(amount > listBuilderImpl.Capacity, "TheLast amount must be less than the size of the list that is being generated"); int start = listBuilderImpl.Capacity - amount; var declaration = new RangeDeclaration <T>(listBuilderImpl, listBuilderImpl.CreateObjectBuilder(), start, listBuilderImpl.Capacity - 1); return((IOperable <T>)listBuilderImpl.AddDeclaration(declaration)); }
public static IListBuilder <Object> WithDefaults( this IListBuilder <Object> objectBuilder, bool hasTuin = false) { if (objectBuilder == null) { throw new ArgumentNullException(nameof(objectBuilder)); } return(objectBuilder .All() .And(x => x.MakelaarId = hasTuin ? MakelaarsTestDefaults.MakelaarIdWithTuin : MakelaarsTestDefaults.MakelaarId) .And(x => x.Woonplaats = MakelaarsTestDefaults.Woonplaats) .And(x => x.MakelaarNaam = hasTuin ? MakelaarsTestDefaults.MakelaarNaamWithTuin : MakelaarsTestDefaults.MakelaarNaam)); }
public static IOperable <T> Section <T>(this IListBuilder <T> listBuilder, int start, int end) { var listBuilderImpl = GetListBuilderImpl <T>(listBuilder); var capacity = listBuilderImpl.Capacity; // TODO: Put these in a specification Guard.Against(start < 0, "Section - start must be zero or greater"); Guard.Against(start >= capacity, "Section - start must be less than the capacity"); Guard.Against(end < 1, "Section - end must be greater than one"); Guard.Against(end >= capacity, "Section - end must be less than the capacity"); Guard.Against(start >= end, "Section - end must be greater than start"); var declaration = new RangeDeclaration <T>(listBuilderImpl, listBuilderImpl.CreateObjectBuilder(), start, end); return((IOperable <T>)listBuilderImpl.AddDeclaration(declaration)); }
public static IOperable <T> TheRest <T>(this IListBuilder <T> listBuilder) { var listBuilderImpl = GetListBuilderImpl <T>(listBuilder); var lastDeclaration = listBuilderImpl.Declarations.GetLastItem(); var rangeDeclaration = lastDeclaration as RangeDeclaration <T>; if (rangeDeclaration == null) { throw new BuilderException("Before using TheNext you must have just used a RangeDeclaration - i.e. (TheFirst or Section)"); } int start = rangeDeclaration.End + 1; int end = listBuilderImpl.Length - start; var andTheNextDeclaration = new RangeDeclaration <T>(listBuilderImpl, listBuilderImpl.CreateObjectBuilder(), start, listBuilderImpl.Length - 1); listBuilderImpl.AddDeclaration(andTheNextDeclaration); return(andTheNextDeclaration); }
public static IOperable <T> ThePrevious <T>(this IListBuilder <T> listBuilder, int amount) { var listBuilderImpl = GetListBuilderImpl <T>(listBuilder); var lastDeclaration = listBuilderImpl.Declarations.GetLastItem(); var rangeDeclaration = lastDeclaration as RangeDeclaration <T>; if (rangeDeclaration == null) { throw new BuilderException("Before using ThePrevious you must have just used a RangeDeclaration - i.e. (TheFirst or Section)"); } int start = rangeDeclaration.Start - amount; int end = start + amount - 1; var andTheNextDeclaration = new RangeDeclaration <T>(listBuilderImpl, listBuilderImpl.CreateObjectBuilder(), start, end); listBuilderImpl.AddDeclaration(andTheNextDeclaration); return(andTheNextDeclaration); }
public static IOperable <T> TheNext <T>(this IListBuilder <T> listBuilder, int amount) { // TODO: Put this in a specification Guard.Against(amount < 1, "TheNext - amount must be one or greater"); var listBuilderImpl = GetListBuilderImpl <T>(listBuilder); var lastDeclaration = listBuilderImpl.Declarations.GetLastItem(); var rangeDeclaration = lastDeclaration as RangeDeclaration <T>; if (rangeDeclaration == null) { throw new BuilderException("Before using TheNext you must have just used a RangeDeclaration - i.e. (TheFirst or Section)"); } int start = rangeDeclaration.End + 1; int end = start + amount - 1; var andTheNextDeclaration = new RangeDeclaration <T>(listBuilderImpl, listBuilderImpl.CreateObjectBuilder(), start, end); listBuilderImpl.AddDeclaration(andTheNextDeclaration); return(andTheNextDeclaration); }
////public static IOperable<T> TheRemaining<T>(this IListBuilder<T> listBuilder) ////{ //// var listBuilderImpl = GetListBuilderImpl<T>(listBuilder); //// var lastDeclaration = listBuilderImpl.Declarations.GetLastItem(); //// var rangeDeclaration = lastDeclaration as RangeDeclaration<T>; //// var remainingItems = listBuilderImpl.Capacity - rangeDeclaration.End; //// return TheLast(listBuilder, remainingItems); ////} public static IOperable <T> Random <T>(this IListBuilder <T> listBuilder, int amount) { var listBuilderImpl = GetListBuilderImpl <T>(listBuilder); return(Random(listBuilderImpl, amount, 0, listBuilderImpl.Capacity)); }
public static IListBuilder <T> WithValidData <T>(this IListBuilder <T> value) { return(value.All().With(ValidData)); }
/// <summary> /// Builds a list of entities given an NBuilder list expression of data builders. /// </summary> /// <typeparam name="TBuilder">The type of the builder being built using NBuilder</typeparam> /// <typeparam name="TObject">The type of object being generated</typeparam> /// <param name="builderList">The NBuilder list of builders</param> /// <returns>The built list of objects</returns> public static IList <TObject> BuildList <TObject, TBuilder>(this IListBuilder <TBuilder> builderList) where TBuilder : ITestDataBuilder <TObject> where TObject : class { return(builderList.All().BuildList <TObject, TBuilder>()); }
public static IOperable <T> WhereTheLast <T>(this IListBuilder <T> listBuilder, int amount) { return(TheLast(listBuilder, amount)); }
public static List <T> BuildListOfNew <T>(this IListBuilder <T> builder) where T : ModelBase, new() { return(BuildList <T>(builder.All().With(c => c.Id = 0))); }
public static List <T> BuildList <T>(this IListBuilder <T> builder) where T : ModelBase, new() { return(builder.Build().ToList()); }
public static IOperable <T> AndThePrevious <T>(this IListBuilder <T> listBuilder, int amount) { return(ThePrevious(listBuilder, amount)); }
public void Build(IListBuilder builder) { builder.Add(Information?.UsedMembers); }
public static IOperable <T> AndTheNext <T>(this IListBuilder <T> listBuilder, int amount) { return(TheNext(listBuilder, amount)); }
public void Build(IListBuilder builder) { builder.Add(Available.Keys); }
public void Build(IListBuilder builder) { builder.Add(Information?.UsedGenerics); }
public static IOperable <T> WhereRandom <T>(this IListBuilder <T> listBuilder, int amount, int start, int end) { return(Random(listBuilder, amount, start, end)); }
public static IOperable <T> WhereSection <T>(this IListBuilder <T> listBuilder, int start, int end) { return(Section(listBuilder, start, end)); }
public static IList <Customer> BuildList(this IListBuilder <CustomerBuilder> list) { return(list.BuildList <Customer, CustomerBuilder>()); }
public static ObservableCollection <T> BuildObservable <T>(this IListBuilder <T> buildable) { return(new ObservableCollection <T>(buildable.Build())); }