public void can_get_3_words() { var test = lorem.Words(); test.Dump(); test.Should() .HaveCount(3); test.Should().Equal("id", "aut", "vel"); //test.ForEach(w => w.Should().NotBeNullOrWhiteSpace()); }
private async Task CreateBlogPagesAsync(IServiceProvider serviceProvider, SeederContext context, NodeId parentId) { // Create Blog overview var blogContent = EmbeddedContent.New(ContentTypeDefinition.Lookup <SimplePage>()); this.AddContentValue(blogContent, nameof(ContentPage.NavigationTitle), "Blog", "Blog"); context.BlogParentId = await this.CreatePageAsync(serviceProvider, context, parentId, blogContent, "Blog", "Blog", 4, "BlogOverview"); var articleDate = DateTime.Today.AddDays(-_rnd.Next(0, 7)); var imageFiles = Directory.GetFiles(Path.Combine(Directory.GetCurrentDirectory(), $"../seed-assets/blog".ToSafeFilePath())); var sortIndex = 0; foreach (var imageFile in imageFiles) { var imageId = await CreateImageAsync(serviceProvider, context, imageFile, $"Blog Article Image {articleDate.ToShortDateString()}"); var categories = Path.GetFileNameWithoutExtension(imageFile).Split('-').Skip(1); var content = EmbeddedContent.New(ContentTypeDefinition.Lookup <BlogArticle>()); this.AddContentValue(content, nameof(BlogArticle.Image), NodeReference.New(imageId)); this.AddContentValues(content, nameof(BlogArticle.Categories), categories); this.AddContentValue(content, nameof(BlogArticle.PublicationDate), articleDate); this.AddContentValue(content, nameof(BlogArticle.Author), Lorem.Words(2, 3)); this.AddContentValue(content, nameof(BlogArticle.ListDescription), Lorem.Sentence(8, 14), Lorem.Sentence(8, 14)); this.AddContentValue(content, nameof(BlogArticle.Body), "<p>" + string.Join("</p><p>", Lorem.Paragraphs(6, 16, 5, 10, 3)) + "</p>", "<p>" + string.Join("</p><p>", Lorem.Paragraphs(6, 16, 5, 10, 3)) + "</p>"); await this.CreatePageAsync(serviceProvider, context, context.BlogParentId, content, Lorem.Words(4, 8), Lorem.Words(4, 8), sortIndex ++); articleDate = articleDate.AddDays(-_rnd.Next(0, 7)); } }
private async Task <NodeId> CreatePageAsync(IServiceProvider serviceProvider, SeederContext context, NodeId parentId, ILocalizableContentModel content, string englishName, string dutchName, int sortOrder, string viewName = null) { var commandBus = serviceProvider.GetRequiredService <ICommandBus>(); var contentService = serviceProvider.GetRequiredService <IContentService>(); this.AddContentValue(content, nameof(PageBase.PageTitle), englishName, dutchName); if (typeof(SimplePage).IsAssignableFrom(content.ContentType.ViewModelType)) { this.AddContentValue(content, nameof(ContentPage.HeadingIntro), Lorem.Paragraph(8, 16, 3, 5), Lorem.Paragraph(8, 16, 3, 5)); this.AddContentValue(content, nameof(ContentPage.HeadingCaption), Lorem.Words(3, 6), Lorem.Words(3, 6)); } // Events var nodeId = NodeId.New; var versionId = NodeVersionId.New; var contentId = await contentService.CreateContentAsync(content.ContentType, content).NoSync(); await commandBus.PublishAsync(new Redakt.ContentManagement.Nodes.Commands.CreateNode(nodeId, content.ContentType, englishName, parentId, sortOrder)); await commandBus.PublishAsync(new Redakt.ContentManagement.Nodes.Commands.SetNodeView(nodeId, viewName ?? content.ContentType.AllowedViewNames.First())); await commandBus.PublishAsync(new Redakt.ContentManagement.Nodes.Commands.AddNodeVersion(nodeId, versionId, contentId, "Version 1", NodeVersionStateKey.New)); await commandBus.PublishAsync(new Redakt.ContentManagement.Nodes.Commands.PublishNode(nodeId, _englishCulture, versionId, englishName.UrlFriendly())); await commandBus.PublishAsync(new Redakt.ContentManagement.Nodes.Commands.PublishNode(nodeId, _dutchCulture, versionId, dutchName.UrlFriendly())); return(nodeId); }
private static List <Play> createPlays(Theatre theatre, int num) { var plays = new List <Play>(); int imageSeed = 160; for (int i = 0; i < num; i++) { string id = ((i + 7) ^ 7).ToString(); plays.Add(new Play { Id = id, Name = Lorem.Words(1, 4), Description = Lorem.Paragraph(2, 4), Duration = new Random().Next(1, 3), ImagesUrls = GetImages(imageSeed, 4), TheatreId = theatre.Id, //PlayDateTimes PlayDateTimesIds = new List <string>(), Published = true }); theatre.PlaysIds.Add(id); imageSeed += 20; } return(plays); }
public void Words_HappyDays() { var words = Lorem.Words(); Assert.AreEqual(3, words.Count()); Assert.AreEqual(0, words.Count(x => string.IsNullOrWhiteSpace(x))); }
public BlogTest(ITestOutputHelper outputHelper) { //for consistency: //gcloud beta emulators firestore start --host-port=localhost:8888 -- Environment.SetEnvironmentVariable("FIRESTORE_EMULATOR_HOST", "localhost:8888"); Environment.SetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS", "/raid/repos/epsweb-firestore/EPSWeb.Common.Firestore/epsweb-217515-5631b4260996.json"); //Environment.SetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS","/your/credential/key.json"); output = outputHelper; log = output.BuildLoggerFor <BlogRepo>(); blog = new BlogRepo(new FirestoreConfig { Root = "blogtest", Emulator = true, EmulatorUrl = "http://localhost:8888", EmulatorPort = 8888, ProjectId = "epsweb-217515" }, log); posts = new List <BlogPost>(); for (int i = 0; i < 20; i++) { posts.Add(new BlogPost { body = Lorem.Paragraphs(500, 250, 3).ToCombinedString(), overview = Lorem.Sentence(10), tags = Lorem.Words(5).Split(',').ToCombinedString(), title = $"blog post {i}", slug = $"blog-post-{i}" }); } }
public void Words_With_Invalid_WordCount() { const int invalidWordCount = -1; var ex = Assert.Throws <ArgumentOutOfRangeException>(() => Lorem.Words(invalidWordCount)); Assert.AreEqual("Must be equal to or greater than zero. (Parameter 'wordCount')", ex.Message); }
/// <summary> /// Write sample orders /// </summary> /// <param name="numOrders">[Optional] No. of orders to write. Defaults to 50</param> public void WriteSampleOrders(int numOrders = 50) { Random rand = new Random(DateTime.Now.Millisecond); IEnumerable <Order> orders = Enumerable.Range(1, numOrders).Select(i => { DateTime dt = DateTime.Now.AddDays(-rand.Next(0, 90)); return(new Order { OrderId = i, OrderDate = dt, ProgramName = string.Join(" ", Lorem.Words(2)), FirstName = Name.First(), LastName = Name.Last(), TelNo = Phone.Number(), MobileNo = Phone.Number(), Email1 = Internet.Email(), Email2 = Internet.Email(), PaymentDate = dt, Quantity = 2, TotalAmount = 50, TicketType = rand.Next() % 2 == 0 ? "Adult" : "Child", PaymentMode = rand.Next() % 3 == 0 ? "Credit card" : "Bank transfer", OrderStatus = rand.Next() % 3 == 0 ? "wc-complete" : "wc-processing" }); }); const string header = "OrderId|OrderDate|ProgramName|FirstName|LastName|TelNo|MobileNo|Email1|Email2|PaymentDate|Quantity|TotalAmount|TicketType|PaymentMode|OrderStatus"; IEnumerable <string> lines = new[] { header }.Concat(orders.Select(f => f.ToPsvRow())); File.WriteAllLines(Path.Combine(Constants.Paths.CacheDirectory, Constants.SampleOrdersDataFileName), lines); }
public void Words_With_Supplemental() { const int defaultWordCount = 3; var words = Lorem.Words(supplemental: true); Assert.AreEqual(defaultWordCount, words.Count()); }
/// <summary> /// Write sample memberships file /// </summary> /// <param name="numMembers">[Optional] No. of members to write. Defaults to 50</param> public void WriteSampleMemberships(int numMembers = 50) { Random rand = new Random(DateTime.Now.Millisecond); IEnumerable <Membership> orders = Enumerable.Range(1, numMembers).Select(i => { DateTime dt = DateTime.Now.AddDays(-rand.Next(0, 90)); return(new Membership { OrderId = i, OrderDate = dt, ProgramName = string.Join(" ", Lorem.Words(2)), FirstName = Name.First(), LastName = Name.Last(), SpouseName = Name.First(), Children = Enumerable.Range(0, rand.Next(0, 3)).Select(j => Name.First()).ToArray(), Address = Address.StreetAddress(), Suburb = "Melbourne", State = Address.UsState(), PostCode = rand.Next(3000, 3800), TelNo = Phone.Number(), MobileNo = Phone.Number(), Email1 = Internet.Email(), Email2 = Internet.Email(), PaymentDate = dt, OrderStatus = rand.Next() % 3 == 0 ? "wc-complete" : "wc-processing" }); }); const string header = "OrderId|ProgramName|OrderDate|LastName|FirstName|SpouseName|Children|Address|Suburb|State|PostCode|TelNo|MobileNo|Email1|Email2|PaymentMode|OrderStatus"; IEnumerable <string> lines = new[] { header }.Concat(orders.Select(f => f.ToPsvRow())); File.WriteAllLines(Path.Combine(Constants.Paths.CacheDirectory, Constants.SampleMembershipDataFileName), lines); }
public void Words_Twice_Are_Different() { var words1 = Lorem.Words(); var words2 = Lorem.Words(); Assert.AreNotEqual(words1, words2); }
public void Valid_PasswordManagerTest() { string val = Lorem.Words(1, false, false); Assert.AreEqual(val, TextUtil.PasswordFieldManager(val)); Assert.AreEqual("password", TextUtil.PasswordFieldManager(Lorem.Words(0, true, true))); }
public void Words_WithSupplementalWords_Twice_Are_Different() { var words1 = Lorem.Words(supplemental: true); var words2 = Lorem.Words(supplemental: true); Assert.AreNotEqual(words1, words2); }
public static void GenerateProjects(this ApplicationDbContext context, bool force) { if (context.Projects.Any() && !force) { return; } var customers = context.Customers.ToList(); var projects = new Project[customers.Count]; for (var i = 0; i < customers.Count; i++) { var customer = customers[i]; var project = new Project { Name = string.Join(" ", Lorem.Words(2)), Description = string.Join(" ", Lorem.Words(4)), Customer = customer, }; projects[i] = project; } context.Projects.AddRange(projects); context.SaveChanges(); }
public void Should_Return_Word_List([Range(10, 100)] int length) { string possibleWords = Resources.Lorem.Words.ToFormat(); IEnumerable <string> words = Lorem.Words(length); Assert.That(words.Count(), Is.EqualTo(length)); Assert.That(words, Has.All.Match("^" + possibleWords + "$")); }
/// <summary> /// Se crea un empleado, si la cola de pedidos en cola es mayor a 0 empieza a cocinar. /// </summary> public static void Cocinar() { Empleado a = new Empleado(Lorem.Words(1, true, false)); if (Local.pedidosEnCola.Count > 0) { a.prepararProximoPedido(); Cocinar(); } }
public void Words_Uses_Words_From_Basic_List_Only() { var words = Lorem.Words(WordList.Length, supplemental: false); foreach (var word in words) { Assert.IsTrue(WordList.Contains(word), $"Locale '{Locale}'. Word missing from word list '{word}'" ); } }
public FlatFileFixture(int lineCount, Func <int> columnCount, Encoding encoding, string header = null, string separator = null, bool persistent = false) : base(persistent) { encoding ??= Encoding.UTF8; var separated = !string.IsNullOrWhiteSpace(separator); byte[] buffer; if (!string.IsNullOrWhiteSpace(header)) { buffer = encoding.GetBytes(header + Environment.NewLine); FileStream.Write(buffer, 0, buffer.Length); } if (separated) { for (var i = 0; i < lineCount; i++) { var line = Pooling.StringBuilderPool.Scoped(sb => { var words = Lorem.Words(columnCount()); for (var j = 0; j < words.Length; j++) { sb.Append(words[j]); if (j < words.Length - 1) { sb.Append(separator); } } }); buffer = encoding.GetBytes(line + Environment.NewLine); FileStream.Write(buffer, 0, buffer.Length); } } else { for (var i = 0; i < lineCount; i++) { buffer = encoding.GetBytes(Lorem.Sentence() + Environment.NewLine); FileStream.Write(buffer, 0, buffer.Length); } } FileStream.Flush(); if (persistent) { FileStream.Close(); } else { FileStream.Seek(0, SeekOrigin.Begin); } }
public override string Next() { var chars = rand.Next(0, maxChars); var sb = new StringBuilder(); do { sb.Append(Lorem.Words(1)); sb.Append(" "); } while (sb.Length < chars); return(sb.ToString()); }
public void Words_Uses_Words_From_Supplementary_List() { var words = Lorem.Words(42, supplemental: true); foreach (var word in words) { if (SupplementalWordList.Contains(word) || !JointWords.Contains(word)) { return; } } Assert.Fail("Words() does not consider supplementary words."); }
public static void AddSampleData(this IServiceProvider services) { ISyncLocalStorageService localStorage = services.GetService <ISyncLocalStorageService>(); if (localStorage.HasDemoDataKey()) { return; } ServiceProvider = services; ShowAlert(); ConsoleLog("- Starting to generate demo data! -"); List <Theatre> theatres = createTheaters(); List <Hall> halls = new List <Hall>(); List <Play> plays = new List <Play>(); List <PlayDateTime> playDateTimes; List <Ticket> tickets; List <User> users = new List <User>(); ConsoleLog("Generated Theatres:", theatres); foreach (var theatre in theatres) { halls.AddRange(createHalls(theatre, 4)); plays.AddRange(createPlays(theatre, 4)); } ConsoleLog("Generated Halls:", halls); ConsoleLog("Generated Plays:", plays); playDateTimes = createPlayDateTimes(halls, plays); ConsoleLog("Generated PlayDateTimes:", playDateTimes); tickets = createTickets(playDateTimes, halls); ConsoleLog("Generated Tickets:", tickets); users.Add(createUser(Lorem.Words(2), Lorem.Email(), UserType.user)); ConsoleLog("Generated Users:", users); ConsoleLog("Writting to DB!"); WriteToDb(theatres, halls, plays, playDateTimes, tickets, users); localStorage.AddDemoDataKey(); ConsoleLog("- Finished!! -"); }
public void Lorem_Methods() { Func <object>[] actions = new[] { new Func <object>(() => Lorem.Character()), new Func <object>(() => Lorem.Characters()), new Func <object>(() => Lorem.Multibyte()), new Func <object>(() => Lorem.Paragraph()), new Func <object>(() => Lorem.ParagraphByChars()), new Func <object>(() => Lorem.Paragraphs()), new Func <object>(() => Lorem.Question()), new Func <object>(() => Lorem.Questions()), new Func <object>(() => Lorem.Sentence()), new Func <object>(() => Lorem.Sentences()), new Func <object>(() => Lorem.Word()), new Func <object>(() => Lorem.Words()), }; bool success = true; int totalExecutions = 0; int successExecutions = 0; int failedExecutions = 0; foreach (Func <object> action in actions) { foreach (string loc in _localizations) { ++totalExecutions; if (!TryCatch(action, loc)) { success = false; ++failedExecutions; } else { ++successExecutions; } } } Console.WriteLine($"{failedExecutions} of {totalExecutions} executions failed"); Assert.IsTrue(success); Assert.AreEqual(totalExecutions, successExecutions); }
public static void GenerateCustomers(this ApplicationDbContext context, bool force) { if (context.Customers.Any() && !force) { return; } var customers = new Customer[5]; foreach (var customer in customers) { customer.Name = string.Join(" ", Lorem.Words(2)); } context.Customers.AddRange(customers); context.SaveChanges(); }
public void populateThreads() { var threads = new List <Thread>(); var rnd = new Random(); foreach (var i in Enumerable.Range(0, 40)) { var test = Sections.ToList().Random(); var user = GetRandomUser(); AddToPostCountOfUser(user.Username); threads.Add(new Thread { author = user, name = Lorem.Words(2, 5), post = LoremNET.Lorem.Paragraph(4, 20, 3, 10), section = test }); } Threads.AddRange(threads); SaveChanges(); }
private async Task <EmbeddedContent> CreateOffersModuleAsync(IServiceProvider serviceProvider, SeederContext context) { var content = EmbeddedContent.New(ContentTypeDefinition.Lookup <OffersMosaic>()); foreach (var imageFile in Directory.GetFiles(Path.Combine(Directory.GetCurrentDirectory(), $"../seed-assets/offers".ToSafeFilePath()))) { var imageId = await CreateImageAsync(serviceProvider, context, imageFile, "Offer"); var offer = EmbeddedContent.New(ContentTypeDefinition.Lookup <OfferItem>()); this.AddContentValue(offer, nameof(OfferItem.Image), NodeReference.New(imageId)); this.AddContentValue(offer, nameof(OfferItem.Title), Lorem.Words(3, 6), Lorem.Words(3, 6)); this.AddContentValue(offer, nameof(OfferItem.Text), Lorem.Paragraph(5, 8, 2, 4), Lorem.Paragraph(5, 8, 2, 4)); this.AddContentValue(content, nameof(OffersMosaic.Offers), offer); } return(content); }
public void Words_With_WordCount() { const int wordCount = 42; var words = Lorem.Words(wordCount); Assert.AreEqual(wordCount, words.Count()); Assert.AreEqual(0, words.Count(x => string.IsNullOrWhiteSpace(x))); foreach (var word in words) { if (JointWords.Contains(word)) { continue; } Assert.True(WordList.Contains(word), $"Locale '{Locale}'. Word missing from word list '{word}'" ); Assert.False(SupplementalWordList.Contains(word)); } }
/// <summary> /// Gets a random RoboHash.org image URL. /// </summary> /// <returns>The random image URL.</returns> /// <exception cref="ArgumentNullException"><paramref name="set" /> is <see langword="null" />.</exception> /// <exception cref="ArgumentException">Size should be specified in format 300x300</exception> public static string Image(string slug = null, string size = "300x300", RoboHashImageFormat format = RoboHashImageFormat.png, string set = "set1") { if (set == null) { throw new ArgumentNullException("set"); } if (!Regex.IsMatch(size, @"^[0-9]+x[0-9]+$")) { throw new ArgumentException("Size should be specified in format 300x300", "size"); } slug = slug ?? string.Join(string.Empty, Lorem.Words(3)); return("http://robohash.org/{0}.{2}?size={1}&set={3}" .FormatCulture(slug, size, format, set)); }
private String CreateString(int length) { //Console.Out.WriteLine("Generating sample data"); var loremText = Lorem.Words(1000); //Console.Out.WriteLine("Done"); var sb = new StringBuilder(loremText); //Double to size while (sb.Length < length) { // Console.Out.WriteLine(" SB " + sb.Length() + " of " + length); sb.Append(sb.ToString()); } //Trim to fit String rs = sb.ToString().Substring(0, length); return(rs); }
public void GenerarLlamada() { while (true) { int nro = aleatorio.Next(0, 6); int aleatorioDuracion = aleatorio.Next(1, 5); float duracion = (float)(aleatorioDuracion / aleatorio.NextDouble()); float costo = (float)(nro * aleatorio.NextDouble()); if (nro <= 3) { string origen = Lorem.Words(1, true); string destino = Lorem.Words(1, true); Local llamadaLocal = new Local(origen, duracion, destino, costo); c += llamadaLocal; } else { Provincial.Franja franja; string origen = Lorem.Words(1, true); string destino = Lorem.Words(1, true); int nroFranja = aleatorio.Next(0, 9); if (nro < 3) { franja = Provincial.Franja.Franja_1; } else if (nro > 3 && nro < 6) { franja = Provincial.Franja.Franja_2; } else { franja = Provincial.Franja.Franja_3; } Provincial llamadaProvincial = new Provincial(origen, franja, duracion, destino); c += llamadaProvincial; } Thread.Sleep(aleatorio.Next(500, 3000)); } }
public void populateUsers() { var demousers = new List <User>(); var rank = GetRankByName("User"); foreach (var i in Enumerable.Range(0, 20)) { var username = Lorem.Words(1, false) + Lorem.Number(0, 10000); var email = Lorem.Email(); demousers.Add(new User { Username = username, Password = "", Email = email, Rank = rank }); } Users.AddRange(demousers); SaveChanges(); CreateUser("user", "user", "*****@*****.**"); CreateMod("Mod1", "mod", "*****@*****.**"); CreateMod("Mod2", "mod", "*****@*****.**"); CreateAdmin("admin", "admin", "*****@*****.**"); // Default admin account }