public UpdatingRelationshipsTests(TestFixture <TestStartup> fixture) { _fixture = fixture; _context = fixture.GetService <AppDbContext>(); _personFaker = new Faker <Person>() .RuleFor(t => t.FirstName, f => f.Name.FirstName()) .RuleFor(t => t.LastName, f => f.Name.LastName()); _todoItemFaker = new Faker <TodoItem>() .RuleFor(t => t.Description, f => f.Lorem.Sentence()) .RuleFor(t => t.Ordinal, f => f.Random.Number()) .RuleFor(t => t.CreatedDate, f => f.Date.Past()); }
public Included(TestFixture <Startup> fixture) { _context = fixture.GetService <AppDbContext>(); _personFaker = new Faker <Person>() .RuleFor(p => p.FirstName, f => f.Name.FirstName()) .RuleFor(p => p.LastName, f => f.Name.LastName()); _todoItemFaker = new Faker <TodoItem>() .RuleFor(t => t.Description, f => f.Lorem.Sentence()) .RuleFor(t => t.Ordinal, f => f.Random.Number()) .RuleFor(t => t.CreatedDate, f => f.Date.Past()); _todoItemCollectionFaker = new Faker <TodoItemCollection>() .RuleFor(t => t.Name, f => f.Company.CatchPhrase()); }
private Ticket[] GetTicketsSeed() { var owners = new List <string>(); for (var i = 0; i < 20; i++) { var faker2 = new Faker("en"); var owner = faker2.Person.FullName;//.Generate(); owners.Add(owner); } var faker = new Bogus.Faker <Ticket>() .RuleFor(t => t.TicketType, (f, u) => f.PickRandom("new", "open", "refused", "closed")) .RuleFor(t => t.Title, (f, u) => f.Lorem.Sentence()) .RuleFor(t => t.Details, (f, u) => f.Lorem.Paragraph()) .RuleFor(t => t.IsHtml, (f, u) => false) .RuleFor(t => t.TagList, (f, u) => string.Join(",", f.Commerce.Categories(3))) .RuleFor(t => t.CreatedDate, (f, u) => f.Date.Recent(100)) .RuleFor(t => t.Owner, (f, u) => f.PickRandom(owners)) .RuleFor(t => t.AssignedTo, (f, u) => f.Person.FullName) .RuleFor(t => t.TicketStatus, (f, u) => f.PickRandom(1, 2, 3)) .RuleFor(t => t.LastUpdateBy, (f, u) => f.Person.FullName) .RuleFor(t => t.LastUpdateDate, (f, u) => f.Date.Soon(5)) .RuleFor(t => t.Priority, (f, u) => f.PickRandom("low", "medium", "high", "critical")) .RuleFor(t => t.AffectedCustomer, (f, u) => f.PickRandom(true, false)) .RuleFor(t => t.Version, (f, u) => f.PickRandom("1.0.0", "1.1.0", "2.0.0")) .RuleFor(t => t.ProjectId, (f, u) => f.Random.Number(100)) .RuleFor(t => t.DueDate, (f, u) => f.Date.Soon(5)) .RuleFor(t => t.EstimatedDuration, (f, u) => f.Random.Number(20)) .RuleFor(t => t.ActualDuration, (f, u) => f.Random.Number(20)) .RuleFor(t => t.TargetDate, (f, u) => f.Date.Soon(5)) .RuleFor(t => t.ResolutionDate, (f, u) => f.Date.Soon(5)) .RuleFor(t => t.Type, (f, u) => f.PickRandom(1, 2, 3)) .RuleFor(t => t.ParentId, () => 0) .RuleFor(t => t.PreferredLanguage, (f, u) => f.PickRandom("fr", "en", "es")) ; var fakeModels = new List <Ticket>(); for (var i = 0; i < 500; i++) { var t = faker.Generate(); t.Id = i + 1; fakeModels.Add(t); } return(fakeModels.ToArray()); }
// private ReadOnlyObservableCollection<PassFail> b; public ListBoxCriteriaUserControl() { Random random = new Random(); InitializeComponent(); new Faker <PassFail>() .RuleFor(a => a.Key, f => f.Name.FirstName()) .RuleFor(a => a.Expired, f => f.Random.Bool()) .GenerateLazy(10000) .ToObservable().Zip(Observable.Interval(TimeSpan.FromSeconds(3)), (a, b) => a) .ToObservableChangeSet(a => a.Key) .Sort(new DefaultComparer <PassFail, string>(new Func <PassFail, string>(a => a.Key))) .Top(10) .ObserveOnDispatcher() .Bind(out a) .Subscribe(ss => { }); passFail.ItemsSource = a; //new Faker<PassFail>() // .RuleFor(a => a.Key, f => "Bob") // .RuleFor(a => a.Expired, f => f.Random.Bool()) // .GenerateLazy(10000) // .ToObservable().Zip(Observable.Interval(TimeSpan.FromSeconds(3)), (a, b) => a) // .ToObservableChangeSet(a => a.Key) // .Sort(new DefaultComparer<PassFail, string>(new Func<PassFail, string>(a => a.Key))) // .Top(10) // .ObserveOnDispatcher() // .Bind(out b) // .Subscribe(a => // { // }); //passFail2.ItemsSource = b; var c = new Bogus.Faker <ServerFile>() .RuleFor(a => a.Download, f => f.Date.Past()) .RuleFor(a => a.Upload, f => f.Date.Past()) .RuleFor(a => a.Link, f => "www.xd.com/link") .Generate(20); file1.ItemsSource = c; }
private Task[] GetTaskSeed() { var faker = new Bogus.Faker <Task>() .RuleFor(t => t.Name, (f, u) => f.Lorem.Sentence()) .RuleFor(t => t.OrderNumber, (f, u) => f.Random.Number(10000000)) .RuleFor(t => t.AssignedLogId, (f, u) => f.Random.Number(10000000)) .RuleFor(t => t.IsAssigned, (f, u) => f.PickRandom(0, 1)) .RuleFor(t => t.OTSTaskTypeId, (f, u) => f.PickRandom(1, 2, 3, 4)) .RuleFor(t => t.Comment, (f) => f.Lorem.Paragraph()) .RuleFor(t => t.LogComplete, f => f.Date.Soon(5)) .RuleFor(t => t.IsLogComplete, f => f.PickRandom(true, false)) .RuleFor(t => t.ActualComplete, f => f.PickRandom(true, false)) .RuleFor(t => t.PlannedStartDate, f => f.Date.Soon(5)) .RuleFor(t => t.PlannedCompleteStartDate, f => f.Date.Soon(5)) .RuleFor(t => t.IsComplete, f => f.PickRandom(true, false)) .RuleFor(t => t.Unplanned, f => f.PickRandom(true, false)) .RuleFor(t => t.UnplannedCodeId, f => f.Random.Number(10000000)) .RuleFor(t => t.UnplannedComments, f => f.Lorem.Paragraph()) .RuleFor(t => t.IsImport, f => f.PickRandom(true, false)) .RuleFor(t => t.IsArchived, f => f.PickRandom(true, false)) .RuleFor(t => t.OTSProjectId, f => f.Random.Number(10000000)) .RuleFor(t => t.BarrierTypeId, f => f.Random.Number(10000000)) .RuleFor(t => t.IsBarrier, f => f.PickRandom(true, false)) .RuleFor(t => t.IsActive, f => f.PickRandom(true, false)) .RuleFor(t => t.IsDeleted, f => f.PickRandom(true, false)) .RuleFor(t => t.CreatedBy, f => f.Person.FullName) .RuleFor(t => t.CreatedDate, f => f.Date.Soon(5)) .RuleFor(t => t.LastModifiedDate, f => f.Date.Soon(5)) .RuleFor(t => t.LastModifiedBy, f => f.Person.FullName) ; var fakeModels = new List <Task>(); for (var i = 0; i < 500; i++) { var t = faker.Generate(); t.Id = i + 1; fakeModels.Add(t); } return(fakeModels.ToArray()); }
private static async Task ObserveThrottling(Container transactionContainer) { var transactions = new Bogus.Faker <Transaction>() .RuleFor(t => t.id, (fake) => Guid.NewGuid().ToString()) .RuleFor(t => t.amount, (fake) => Math.Round(fake.Random.Double(5, 500), 2)) .RuleFor(t => t.processed, (fake) => fake.Random.Bool(0.6f)) .RuleFor(t => t.paidBy, (fake) => $"{fake.Name.FirstName().ToLower()}.{fake.Name.LastName().ToLower()}") .RuleFor(t => t.costCenter, (fake) => fake.Commerce.Department(1).ToLower()) .GenerateLazy(10000); List <Task <ItemResponse <Transaction> > > tasks = new List <Task <ItemResponse <Transaction> > >(); foreach (var transaction in transactions) { Task <ItemResponse <Transaction> > resultTask = transactionContainer.CreateItemAsync(transaction); tasks.Add(resultTask); } Task.WaitAll(tasks.ToArray()); foreach (var task in tasks) { await Console.Out.WriteLineAsync($"Item Created\t{task.Result.Resource.id}"); } }