public KafkaMessageConsumerTests(KafkaFixture fixture) { _fixture = fixture; randomizerString = RandomizerFactory.GetRandomizer(new FieldOptionsTextRegex { Pattern = @"^[A-Z]{10}" }); }
public SQSMessageConsumerTests(SQSFixture fixture) { _randomizerString = RandomizerFactory.GetRandomizer(new FieldOptionsTextRegex { Pattern = @"^[A-Z]{10}" }); _baseSQSUrl = $"http://{fixture.Hostname}:{fixture.Port}"; }
static void Main(string[] args) { var randomFirstNameGenerator = RandomizerFactory.GetRandomizer(new FieldOptionsFirstName()); var randomLastNameGenerator = RandomizerFactory.GetRandomizer(new FieldOptionsLastName()); var randomDateGenerator = RandomizerFactory.GetRandomizer(new FieldOptionsDateTime()); for (var o = 10; o <= 10000; o *= 10) { var list = new List <Person>(count); var batchCount = count * o; Console.Write($"{batchCount} "); for (var i = 0; i < batchCount; i++) { var offset = (DateTimeOffset)randomDateGenerator.Generate().Value; list.Add(new Person { Birthdate = offset.ToUnixTimeSeconds(), LastName = randomLastNameGenerator.Generate(true), FirstName = randomFirstNameGenerator.Generate(true) }); } var desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); var id = Guid.NewGuid().ToString(); WriteStreams(list, desktopPath, id); ReadStreams(list, desktopPath, id); Console.WriteLine(); } }
public DataGenerator(IOptions <DataGeneratorSettings> options) { _settings = options.Value; _randomizerByte = RandomizerFactory.GetRandomizer(new FieldOptionsByte { Min = 0, Max = 9 }); _randomizerInteger = RandomizerFactory.GetRandomizer(new FieldOptionsInteger { Min = _settings.IntegerMin, Max = _settings.IntegerMax }); _randomizerString = RandomizerFactory.GetRandomizer(new FieldOptionsText { Min = _settings.StringMinLength, Max = _settings.StringMaxLength, UseSpecial = false, }); _randomizerDateTime = RandomizerFactory.GetRandomizer(new FieldOptionsDateTime { From = _settings.DateTimeMin, To = _settings.DateTimeMax, IncludeTime = false }); }
static void Main(string[] args) { var intGenerator = RandomizerFactory.GetRandomizer(new FieldOptionsInteger()); var nameGenerator = RandomizerFactory.GetRandomizer(new FieldOptionsFirstName()); var lastnameGenerator = RandomizerFactory.GetRandomizer(new FieldOptionsLastName()); var random = new Osoba( intGenerator.Generate().Value, nameGenerator.Generate(), lastnameGenerator.Generate()); Console.WriteLine($"{random.ID} {random.imie} {random.nazwisko} "); var list = new List <Osoba>(); for (int i = 0; i < 100; i++) { list.Add(new Osoba( intGenerator.Generate().Value, nameGenerator.Generate(), lastnameGenerator.Generate())); } list = list.OrderBy(x => x.nazwisko).ThenBy(x => x.imie).ToList(); foreach (var item in list) { Console.WriteLine("{0} {1}", item.nazwisko, item.imie); } }
public KafkaExtensionTests(KafkaFixture fixture) { _fixture = fixture; _randomizerString = RandomizerFactory.GetRandomizer(new FieldOptionsTextRegex { Pattern = @"^[A-Z]{10}" }); }
private static void InsertMovies(SqliteConnection con) { IRandomizerDateTime randomizerDate = RandomizerFactory.GetRandomizer(new FieldOptionsDateTime { From = minDT, To = maxDT }); using (SqliteTransaction transaction = con.BeginTransaction()) { string lastWord = ""; string word1 = ""; string word2 = ""; var randomizerWord = RandomizerFactory.GetRandomizer(new FieldOptionsTextWords { Min = 1, Max = 1 }); SqliteCommand addCommand = con.CreateCommand(); for (int i = 0; i <= 1000000; i++) { do { word1 = randomizerWord.Generate(); word2 = randomizerWord.Generate(); } while (word1.Equals(lastWord)); lastWord = word1; addCommand.CommandText = $@" INSERT INTO Elokuvat (nimi, julkaisupv) VALUES ('{word1} {word2}', '{randomizerDate.GenerateAsString()}') "; System.Console.WriteLine($@"{i}. INSERT INTO Elokuvat (nimi, julkaisupv) VALUES ('{word1} {word2}', '{randomizerDate.GenerateAsString()}')"); addCommand.ExecuteNonQuery(); } transaction.Commit(); } }
private static void GetMoviesReleased(SqliteConnection con) { IRandomizerDateTime randomizerDate = RandomizerFactory.GetRandomizer(new FieldOptionsDateTime { From = minDT, To = maxDT }); System.Console.WriteLine("Haetaan elokuvia satunnaisilta vuosilta..."); int lastRandomYear = 0; for (int i = 0; i <= 1000; i++) { int randomYear; do { DateTime randomDate = (DateTime)randomizerDate.Generate(); randomYear = randomDate.Year; } while (randomYear == lastRandomYear); SqliteCommand searchCommand = con.CreateCommand(); searchCommand.CommandText = $@" SELECT COUNT(*) FROM Elokuvat WHERE julkaisupv BETWEEN '{randomYear}-01-01' AND '{randomYear}-12-31' "; using (var reader = searchCommand.ExecuteReader()) { while (reader.Read()) { System.Console.WriteLine($"Julkaistujen elokuvien määrä vuonna {randomYear} on {reader.GetString(0)}"); } } } }
string RandomLastName() { var randomizer = RandomizerFactory.GetRandomizer(new FieldOptionsFirstName()); string result = randomizer.Generate(); return(result); }
string RandomCity() { var randomizerCity = RandomizerFactory.GetRandomizer(new FieldOptionsCity()); string result = randomizerCity.Generate(); return(result); }
string RandomEmail() { var randomizerEmail = RandomizerFactory.GetRandomizer(new FieldOptionsEmailAddress()); string result = randomizerEmail.Generate() + ".xom"; return(result); }
string RandomLipsumString(string inputString) { var paragraphs = CountParagraphs(inputString); var randomizer = RandomizerFactory.GetRandomizer(new FieldOptionsTextLipsum { Paragraphs = 1 }); string result = randomizer.Generate(); return(result); }
string RandomCompanyName(string inputString) { int numberWords = CountWords(inputString); var randomizerTextWords = RandomizerFactory.GetRandomizer(new FieldOptionsTextWords { Min = numberWords, Max = numberWords }); string result = randomizerTextWords.Generate(); return(result); }
public void Generate() { var randomizer = RandomizerFactory.GetRandomizer(new MACAddressFieldOptions()); for (var i = 0; i < 100; i++) { var result = randomizer.Generate(); Output.WriteLine(result); } }
static void Main(string[] args) { /* * List<int> lista = Enumerable.Range(100, 150).ToList(); * List<int> podzielnePrzez3 = * lista.Where(x => (x % 3 == 0)).ToList(); * * int elementyNaStronie = 25; * int numerStrony = 2; * List<int> strona2 = * lista.Skip(elementyNaStronie * (numerStrony - 1)).Take(elementyNaStronie).ToList(); * * * double srednia = lista.Average(); * * Console.WriteLine(srednia); * * foreach (int item in strona2) * Console.WriteLine(item); * * * List<Osoba> osoby = Enumerable.Range(1, 50) * .Select(x => new Osoba() { * id = x, * imie = x.ToString(), * nazwisko = "aaa" * }).ToList(); * * foreach (var item in osoby) * Console.WriteLine($"{item.id}: {item.imie} {item.nazwisko} "); * * IEnumerable<int> ids = osoby.Select(x => x.id); * * foreach (var item in ids) * Console.WriteLine(item); * * osoby.Select(x => x.nazwisko).Distinct().ToList().ForEach(x => Console.WriteLine(x)); * * int pierwszy = lista.FirstOrDefault(x => x % 300 == 0); * * Console.WriteLine(pierwszy); */ var intGenerator = RandomizerFactory.GetRandomizer(new FieldOptionsInteger()); var nameGenerator = RandomizerFactory.GetRandomizer(new FieldOptionsFirstName()); var lastGenerator = RandomizerFactory.GetRandomizer(new FieldOptionsLastName()); //Osoba random = new Osoba(intGenerator.Generate().Value, nameGenerator.Generate(), lastGenerator.Generate()); //Console.WriteLine($"{random.id}: {random.imie} {random.nazwisko} "); List <Osoba> osoby = Enumerable.Range(1, 100) .Select(x => new Osoba(intGenerator.Generate().Value, nameGenerator.Generate(), nameGenerator.Generate())).ToList(); osoby.OrderBy(x => x.nazwisko).ThenBy(x => x.imie).ToList().ForEach(x => Console.WriteLine($"{x.id}: {x.imie} {x.nazwisko}")); }
DateTimeOffset RandomDateInPast() { var from = DateTime.Parse("2001-01-01"); var to = DateTime.Now; var randomizerDate = RandomizerFactory.GetRandomizer(new FieldOptionsDateTime { From = from, To = to, IncludeTime = false }); return(new DateTimeOffset(randomizerDate.Generate().Value)); }
public dynamic Generate() { dynamic randomizer = RandomizerFactory.GetRandomizerAsDynamic(FieldOptions); if (randomizer.GetType().GetMethod("GenerateAsString") != null) { return(randomizer.GenerateAsString()); } return(randomizer.Generate()); }
public void Generate() { var randomizer = RandomizerFactory.GetRandomizer(new ChineseAddressFieldOptions()); for (var i = 0; i < 100; i++) { var result = randomizer.Generate(); var region = randomizer.GenerateRegion(); Output.WriteLine($"{result}/{region}"); } }
public void Generate() { var randomizer = RandomizerFactory.GetRandomizer(new ChineseIdCardFieldOptions()); for (var i = 0; i < 100; i++) { var idcard = randomizer.Generate(); var time = randomizer.GenerateValidPeriod(); var address = randomizer.GenerateIssueOrg(); Output.WriteLine($"{idcard}/{time}/{address}"); } }
public void Generate() { var randomizer = RandomizerFactory.GetRandomizer <int>(new NumberFieldOptions <int>() { Min = 0, Max = 1000 }); for (var i = 0; i < 100; i++) { var result = randomizer.Generate(); Output.WriteLine(result.ToString()); } }
public void Generate() { var randomizer = RandomizerFactory.GetRandomizer(new TimeSpanFieldOptions() { From = DateTime.Now.TimeOfDay, To = DateTime.Now.AddDays(20).TimeOfDay }); for (var i = 0; i < 100; i++) { var result = randomizer.GenerateAsString(); Output.WriteLine(result); } }
public void Generate() { var randomizer = RandomizerFactory.GetRandomizer(new TextRegexFieldOptions() { Pattern = @"^[0-9]{4}[A-Z]{2}" }); for (var i = 0; i < 100; i++) { var result = randomizer.Generate(); Output.WriteLine(result); } }
public User GenerateAndAddGuestUser() { var firstName = RandomizerFactory.GetRandomizer(new FieldOptionsFirstName()).Generate(); var lastName = RandomizerFactory.GetRandomizer(new FieldOptionsLastName()).Generate(); var user = Create(new User() { FirstName = firstName, LastName = lastName }); return(user); }
public void Generate() { var randomizer = RandomizerFactory.GetRandomizer(new TextWordsFieldOptions() { Min = 3, Max = 20 }); for (var i = 0; i < 100; i++) { var result = randomizer.Generate(); Output.WriteLine(result); } }
public void Generate() { var randomizer = RandomizerFactory.GetRandomizer(new TextFieldOptions() { Min = 3, Max = 20, UseLetter = true, UseNumber = true }); for (var i = 0; i < 100; i++) { var result = randomizer.Generate(); Output.WriteLine(result); } }
public SourceService(ILogger <SourceService> logger, TelemetryClient telemetryClient, Config config) { _logger = logger; _telemetryClient = telemetryClient; _config = config; _randomBytes = RandomizerFactory.GetRandomizer(new FieldOptionsBytes() { Min = (int)Math.Pow(2, 20) * _config.MinFileSizeMB, Max = (int)Math.Pow(2, 20) * _config.MaxFileSizeMB }); }
private void PrepareQueues() { var randomizerString = RandomizerFactory.GetRandomizer(new FieldOptionsTextRegex { Pattern = @"^[A-Z]{10}" }); Environment.SetEnvironmentVariable("RabbitMQConsumer__Port", _fixture.Port.ToString()); Environment.SetEnvironmentVariable("RabbitMQConsumer__Host", _fixture.Hostname); Environment.SetEnvironmentVariable("RabbitMQPublisher__Port", _fixture.Port.ToString()); Environment.SetEnvironmentVariable("RabbitMQPublisher__Host", _fixture.Hostname); Environment.SetEnvironmentVariable("RabbitMQConsumer__Queue__Name", randomizerString.Generate()); Environment.SetEnvironmentVariable("RabbitMQPublisher__PublishingTarget__RoutingKey", randomizerString.Generate()); Environment.SetEnvironmentVariable("DestinationQueueName", randomizerString.Generate()); }
public static void CreateContacts(ReservarionSystemDbContext context) { if (!context.ContactTypes.Any()) { CreateContactType(context); } if (context.Contacts.Any()) { return; } var faker = new Faker(); var quantity = faker.Random.Int(min: 10, max: 50); for (var i = 0; i < quantity - 1; i++) { faker = new Faker(); var name = faker.Person.FullName; var randomizerTextRegex = RandomizerFactory .GetRandomizer(new FieldOptionsTextRegex { Pattern = @"^\(999\) 999-\d{4}$" }); var phoneNumber = randomizerTextRegex.Generate().ToUpper(); var birthDate = faker.Person.DateOfBirth; var contactType = faker.PickRandom <ContactType>(context.ContactTypes); var contact = new Contact( name: name, phoneNumber: phoneNumber, birthDate: birthDate, contactType: contactType ); var x = contact.IsValid(); context.Contacts.Add(contact); } context.SaveChanges(); }
static void Main(string[] args) { var idGenerator = RandomizerFactory.GetRandomizer(new FieldOptionsInteger()); var firstNameGenerator = RandomizerFactory.GetRandomizer(new FieldOptionsFirstName()); var lastNameGenerator = RandomizerFactory.GetRandomizer(new FieldOptionsLastName()); var people = Enumerable.Range(1, 30) .Select(x => new Person(idGenerator.Generate().Value, firstNameGenerator.Generate(), lastNameGenerator.Generate())) .ToList(); Console.WriteLine($"Number of people: {people.Count()}\nID's average: {people.Select(x => x.Id).Average()}\n"); people.OrderBy(x => x.Surname).ThenBy(x => x.FirstName).ToList().ForEach(Console.WriteLine); Console.ReadKey(); }
public void Generate() { var randomizer = RandomizerFactory.GetRandomizer(new StringListFieldOptions() { Values = new List <string>() { "张三", "李四", "王五" } }); for (var i = 0; i < 100; i++) { var result = randomizer.Generate(); Output.WriteLine(result); } }