static TestUtilities() { _rnd = new System.Random(); LoremIpsumWords = LoremIpsum.Split(" ".ToCharArray(), System.StringSplitOptions.RemoveEmptyEntries); cdir = Directory.GetCurrentDirectory(); rootDirectory = FileSystem.Current.LocalStorage.Path; }
public bool TryEvaluate(object sender, VariableEvaluationEventArg e) { Match loremIspumVariableEvalMatch = loremIspumVariableEvalRegex.Match(e.Name); if (loremIspumVariableEvalMatch.Success) { LoremIpsum li = new LoremIpsum(); if (loremIspumVariableEvalMatch.Groups["language"].Success) { li.CurrentLanguage = loremIspumVariableEvalMatch.Groups["language"].Value.ToLower(); } int wordPerLine = loremIspumVariableEvalMatch.Groups["wordsPerLine"].Success ? int.Parse(loremIspumVariableEvalMatch.Groups["wordsPerLine"].Value, CultureInfo.InvariantCulture) : 10; if (loremIspumVariableEvalMatch.Groups["words"].Success) { e.Value = li.GetWords(int.Parse(loremIspumVariableEvalMatch.Groups["words"].Value, CultureInfo.InvariantCulture), wordPerLine); } else { e.Value = loremIspumVariableEvalMatch.Groups["lines"].Success ? li.GetLines(int.Parse(loremIspumVariableEvalMatch.Groups["lines"].Value, CultureInfo.InvariantCulture), wordPerLine) : li.GetWords(100, wordPerLine); } return(true); } else { return(false); } }
// Separate steps to select / generate with or without, error on the side of no conditionals in test code public void GenerateWithStartingText(LoremIpsum loremIpsum) { Amount.Clear(); Amount.SendKeys(loremIpsum.Amount); GenerationType(loremIpsum.TextGenerationType.ToString().ToLowerInvariant()).Click(); GenerateLoremIpsum.Click(); }
public void TestMethod1() { IWebDriver driver = new ChromeDriver(); LoremIpsum loremIpsum = new LoremIpsum(driver); PageFactory.InitElements(driver, loremIpsum); loremIpsum.GetLoremIpsumString("140"); }
// separate asserts for different expectations, both using LoremIpsum model public void AssertParagraphsGeneration(LoremIpsum loremIpsum) { var generatedText = GeneratedLoremIpsum.Text; var generatedTextStartsWithDefault = generatedText.StartsWith(loremIpsum.DefaultText); var generatedParagraphs = GeneratedLoremIpsum.FindElements(By.CssSelector("p")).Count.ToString(); generatedParagraphs.Should().Be(loremIpsum.Amount); generatedTextStartsWithDefault.Should().Be(loremIpsum.StartWithDefaultText); }
// separate asserts for different expectations, both using LoremIpsum model public void AssertWordsGeneration(LoremIpsum loremIpsum) { var generatedText = GeneratedLoremIpsum.Text; var generatedTextStartsWithDefault = generatedText.StartsWith(loremIpsum.DefaultText); var generatedWords = generatedText.Split().Length.ToString(); generatedWords.Should().Be(loremIpsum.Amount); generatedTextStartsWithDefault.Should().Be(loremIpsum.StartWithDefaultText); }
public void Should_generate_text() { for (var i = 0; i < 5000; i++) { var result = LoremIpsum.Text(i, false); Assert.NotNull(result); } }
public PersonDetail() { InitializeComponent(); quote.Text = LoremIpsum.GetParagraph(4) + System.Environment.NewLine + System.Environment.NewLine + LoremIpsum.GetParagraph(8) + System.Environment.NewLine + System.Environment.NewLine + LoremIpsum.GetParagraph(6); }
public void Translate_FormatsItsContents() { var fileContent = LoremIpsum; var acknowledgmentBuilder = new AcknowledgmentBuilder(); var acknowledgment = acknowledgmentBuilder.WithFileContent(fileContent).Build(); var result = acknowledgment.Translate(); var formattedContent = new String(LoremIpsum.Take(100).ToArray()); Mock.Get(acknowledgmentBuilder.nativeFormat).Verify(x => x.LoadContentFrom(formattedContent), Times.Once); }
static void DoBenchmarkBatchedLoremIpsum(EventLog benchLog, long batchSize, long totalSteps, long loremIpsumLength) { Stopwatch sw = new Stopwatch(); sw.Start(); // loremIpsumLength should be less equal than 65535. loremIpsumLength = loremIpsumLength > 65535 ? 65535 : loremIpsumLength; Console.WriteLine("events\tWorking Set(MB)\tPrivate Memory(MB)\tPage File(MB)\tTotal CPU Usage\tDisk Time"); TotalCPUCounter cpuCounter = new TotalCPUCounter(); var text = LoremIpsum.ASCIIText(); Encoding e = System.Text.Encoding.GetEncoding("UTF-8"); string result = new String(text.TakeWhile((c, i) => e.GetByteCount(text.Substring(0, i + 1)) <= loremIpsumLength).ToArray()); DiskUsageCounter diskCounter = new DiskUsageCounter(); MonitorProcesses monitor = new MonitorProcesses(cpuCounter, diskCounter); long batchNum = batchSize / BINNUM; long residualNUM = batchSize % BINNUM; for (int i = 0; i < totalSteps; i++) { DateTime targetTime = DateTime.Now; long currentTime = GetUnixTime(targetTime); Console.Write(String.Format("{0, 8}", i * batchSize)); Task.Run(() => monitor.Run()); for (int j = 0; j < BINNUM; j++) { for (int k = 0; k < batchNum; k++) { // Write an informational entry to the event log. benchLog.WriteEntry(result); } //Thread.Sleep(10); } for (int j = 0; j < residualNUM; j++) { benchLog.WriteEntry(result); } while (GetUnixTime(DateTime.Now) <= currentTime) { Thread.Sleep(1); } } sw.Stop(); Console.Write(String.Format("{0, 8}", totalSteps * batchSize)); monitor.Run(); Console.WriteLine(String.Format("Flow rate: {0} events per second.", (totalSteps * batchSize) / (float)(sw.ElapsedMilliseconds / 1000.0))); Console.WriteLine("Message written to event log."); }
private static IReadOnlyCollection <Tag> CreateTags(int count) { var tags = new List <Tag>(); string[] tagNames = CreateUniqueStringSet(count, () => LoremIpsum.NextWord(minLength: 7)); foreach (string name in tagNames) { Tag tag = CreateTag(name); tags.Add(tag); } return(tags); }
public void Setup() { _email = new Regex(@"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,12}|[0-9]{1,3})(\]?)$", Options); _date = new Regex(@"\b\d{1,2}\/\d{1,2}\/\d{2,4}\b", Options); _ip = new Regex(@"(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9])", Options); _uri = new Regex(@"[\w]+://[^/\s?#]+[^\s?#]+(?:\?[^\s#]*)?(?:#[^\s]*)?", Options); _searchWord = new Regex(@"tempus", Options); _searchWords = new Regex(@"tempus|magna|semper", Options); _searchSet = new Regex(@"\w{10,}", Options); _searchBoundary = new Regex(@"\b\w{10,}\b", Options); _loremIpsum = LoremIpsum.ToString(); }
private static Headline CreateHeadline(HeadlineInfo headline) { return(new Headline { Slug = headline.Title.Slugify(), Title = headline.Title, Lead = LoremIpsum.NextParagraph(minSentenceCount: 1, maxSentenceCount: 2), Text = LoremIpsum.NextParagraph(minSentenceCount: 2, maxSentenceCount: 4), ReleaseDate = ActinUraniumInfo.NextDate(), Author = headline.Author, Tag = headline.Tag, HeadlineImages = headline.Images }); }
private static Creation CreateCreation(string title, Customer customer, List <CreationImage> images) { return(new Creation { Slug = title.Slugify(), Title = title, ReleaseDate = ActinUraniumInfo.NextDate(), Mission = LoremIpsum.NextParagraph(minSentenceCount: 2, maxSentenceCount: 3), Strategy = LoremIpsum.NextParagraph(minSentenceCount: 1, maxSentenceCount: 3), Execution = LoremIpsum.NextParagraph(minSentenceCount: 1, maxSentenceCount: 3), Customer = customer, CreationImages = images }); }
private IEnumerable <HeadlineInfo> GetHeadlineInfos() { var headlineInfos = new List <HeadlineInfo>(); Author author = CreateAuthor(); DirectoryInfo[] imageDirectories = GetDirectories("img/headlines"); int illustratedHeadlineCount = imageDirectories.Length; int nonIllustratedHeadlineCount = illustratedHeadlineCount / 2; int totalHeadlineCount = illustratedHeadlineCount + nonIllustratedHeadlineCount; IReadOnlyCollection <Tag> tags = CreateTags(count: 2); WeightedLottery <Tag> tagLottery = CreateTagLottery(tags, totalWeight: illustratedHeadlineCount); string[] titles = CreateUniqueStringSet( totalHeadlineCount, () => LoremIpsum.NextHeading(minWordCount: 2, maxWordCount: 8)); for (int headlineIndex = 0; headlineIndex < illustratedHeadlineCount; headlineIndex++) { DirectoryInfo directory = imageDirectories[headlineIndex]; var headlineInfo = new HeadlineInfo { Images = GetHeadlineImages(directory), Tag = tagLottery.Pull(), Title = titles[headlineIndex], Author = author }; headlineInfos.Add(headlineInfo); } tagLottery = CreateTagLottery(tags, totalWeight: nonIllustratedHeadlineCount); for (int headlineIndex = illustratedHeadlineCount; headlineIndex < totalHeadlineCount; headlineIndex++) { var headlineInfo = new HeadlineInfo { Images = new List <HeadlineImage>(), Tag = tagLottery.Pull(), Title = titles[headlineIndex], Author = author }; headlineInfos.Add(headlineInfo); } return(headlineInfos); }
static void DoBenchmarkLoremIpsum(EventLog benchLog, int waitMSec, long totalEvents, long loremIpsumLength) { Stopwatch sw = new Stopwatch(); sw.Start(); // loremIpsumLength should be less equal than 65535. loremIpsumLength = loremIpsumLength > 65535 ? 65535 : loremIpsumLength; Console.WriteLine("events\tWorking Set(MB)\tPrivate Memory(MB)\tPage File(MB)\tTotal CPU Usage\tDisk Time"); TotalCPUCounter cpuCounter = new TotalCPUCounter(); var text = LoremIpsum.ASCIIText(); Encoding e = System.Text.Encoding.GetEncoding("UTF-8"); string result = new String(text.TakeWhile((c, i) => e.GetByteCount(text.Substring(0, i + 1)) <= loremIpsumLength).ToArray()); DiskUsageCounter diskCounter = new DiskUsageCounter(); MonitorProcesses monitor = new MonitorProcesses(cpuCounter, diskCounter); for (int i = 0; i < totalEvents / 10; i++) { if (i % 10 == 0) { Console.Write(String.Format("{0, 8}", i * 10)); Task.Run(() => monitor.Run()); } // Write an informational entry to the event log. benchLog.WriteEntry(result); benchLog.WriteEntry(result); benchLog.WriteEntry(result); benchLog.WriteEntry(result); benchLog.WriteEntry(result); benchLog.WriteEntry(result); benchLog.WriteEntry(result); benchLog.WriteEntry(result); benchLog.WriteEntry(result); benchLog.WriteEntry(result); Thread.Sleep(waitMSec); } sw.Stop(); Console.Write(String.Format("{0, 8}", totalEvents)); monitor.Run(); Console.WriteLine(String.Format("Flow rate: {0} events per second.", totalEvents / (float)(sw.ElapsedMilliseconds / 1000.0))); Console.WriteLine("Message written to event log."); }
private void AddDesignTimeItems() { if (IsInDesignMode) { var mockVerseText = LoremIpsum.GetSomeMockVerses(); for (int n = 0; n < mockVerseText.Length; ++n) { var item = new EditVerseTextViewModel { BookName = @"Book", BookNumber = 1, Chapter = 1, Verse = n + 1, OriginalVerseText = mockVerseText[n], ModifiedVerseText = mockVerseText[n] }; Verses.Add(item); } } }
private void SeedCreations() { Lottery <Customer> customerLottery = GetCustomerLottery(); DirectoryInfo[] imageDirectories = GetDirectories("img/creations"); int creationCount = imageDirectories.Length; string[] creationTitles = CreateUniqueStringSet( creationCount, () => LoremIpsum.NextHeading(minWordCount: 2, maxWordCount: 3)); for (int creationIndex = 0; creationIndex < creationCount; creationIndex++) { string title = creationTitles[creationIndex]; Customer customer = customerLottery.Next(); DirectoryInfo imageDirectory = imageDirectories[creationIndex]; List <CreationImage> images = GetCreationImages(imageDirectory); Creation creation = CreateCreation(title, customer, images); _dbContext.Creations.Add(creation); } _dbContext.SaveChanges(); }
/// <inheritdoc /> public Task <object> GenerateValueAsync() { return(Task.FromResult <object>(LoremIpsum.Generate(_count, _unit))); }
static TestUtilities() { _rnd = new System.Random(); LoremIpsumWords = LoremIpsum.Split(" ".ToCharArray(), System.StringSplitOptions.RemoveEmptyEntries); }
protected string GetRandomString(int wordCount) { LoremIpsum lipsum = new LoremIpsum(); return(lipsum.GetWords(wordCount, true)); }
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------- /// <summary> /// Inserts the lorem ipsum. /// </summary> /// <param name="tec">The tec.</param> public static void InsertLoremIpsum(this TextEditorControl tec) { tec.ActiveTextAreaControl.TextArea.InsertString(LoremIpsum.GetLoremIpsum()); }
private void InjectSampleData() { textBlock1.Text = LoremIpsum.GetParagraph(10); }
public async Task TestCreateValidator() { await using var context = DatabaseHelper.CreateInMemoryDatabaseContext(nameof(TestCreateValidator)); // setup var logType = ValidObjectHelper.ValidPlantLogType(); var plantSpecies = ValidObjectHelper.ValidPlantSpecies(); var plant = ValidObjectHelper.ValidPlant(plantSpecies); await context.AddRangeAsync(logType, plantSpecies, plant); await context.SaveChangesAsync(); var validator = new CreatePlantLogForPlantCommandValidator(context); var createValidCmd = new CreatePlantLogForPlantCommand { Id = Guid.NewGuid(), PlantId = plant.Id, PlantLogTypeId = logType.Id, DateTime = DateTime.Now, Log = LoremIpsum.Words(2), }; validator.ShouldNotHaveValidationErrorFor(plantLogCmd => plantLogCmd.Id, createValidCmd); validator.ShouldNotHaveValidationErrorFor(plantLogCmd => plantLogCmd.PlantId, createValidCmd); validator.ShouldNotHaveValidationErrorFor(plantLogCmd => plantLogCmd.PlantLogTypeId, createValidCmd); validator.ShouldNotHaveValidationErrorFor(plantLogCmd => plantLogCmd.DateTime, createValidCmd); validator.ShouldNotHaveValidationErrorFor(plantLogCmd => plantLogCmd.Log, createValidCmd); //invalid plant log type var createInvalidLogTypeCmd = new CreatePlantLogForPlantCommand { Id = Guid.NewGuid(), PlantId = plant.Id, PlantLogTypeId = Guid.NewGuid(), DateTime = DateTime.Now, Log = LoremIpsum.Words(2), }; validator.ShouldNotHaveValidationErrorFor(plantLogCmd => plantLogCmd.Id, createInvalidLogTypeCmd); validator.ShouldNotHaveValidationErrorFor(plantLogCmd => plantLogCmd.PlantId, createInvalidLogTypeCmd); validator.ShouldHaveValidationErrorFor(plantLogCmd => plantLogCmd.PlantLogTypeId, createInvalidLogTypeCmd); validator.ShouldNotHaveValidationErrorFor(plantLogCmd => plantLogCmd.DateTime, createInvalidLogTypeCmd); validator.ShouldNotHaveValidationErrorFor(plantLogCmd => plantLogCmd.Log, createInvalidLogTypeCmd); //invalid plant log type var createInvalidPlantCmd = new CreatePlantLogForPlantCommand { Id = Guid.NewGuid(), PlantId = Guid.NewGuid(), PlantLogTypeId = logType.Id, DateTime = DateTime.Now, Log = LoremIpsum.Words(2), }; validator.ShouldNotHaveValidationErrorFor(plantLogCmd => plantLogCmd.Id, createInvalidPlantCmd); validator.ShouldHaveValidationErrorFor(plantLogCmd => plantLogCmd.PlantId, createInvalidPlantCmd); validator.ShouldNotHaveValidationErrorFor(plantLogCmd => plantLogCmd.PlantLogTypeId, createInvalidPlantCmd); validator.ShouldNotHaveValidationErrorFor(plantLogCmd => plantLogCmd.DateTime, createInvalidPlantCmd); validator.ShouldNotHaveValidationErrorFor(plantLogCmd => plantLogCmd.Log, createInvalidPlantCmd); //invalid id var createInvalidIdCmd = new CreatePlantLogForPlantCommand { Id = Guid.Empty, PlantId = plant.Id, PlantLogTypeId = logType.Id, DateTime = DateTime.Now, Log = LoremIpsum.Words(2), }; validator.ShouldHaveValidationErrorFor(plantLogCmd => plantLogCmd.Id, createInvalidIdCmd); validator.ShouldNotHaveValidationErrorFor(plantLogCmd => plantLogCmd.PlantId, createInvalidIdCmd); validator.ShouldNotHaveValidationErrorFor(plantLogCmd => plantLogCmd.PlantLogTypeId, createInvalidIdCmd); validator.ShouldNotHaveValidationErrorFor(plantLogCmd => plantLogCmd.DateTime, createInvalidIdCmd); validator.ShouldNotHaveValidationErrorFor(plantLogCmd => plantLogCmd.Log, createInvalidIdCmd); }
public async Task TestUpdateForPlantValidator() { await using var context = DatabaseHelper.CreateInMemoryDatabaseContext(nameof(TestUpdateForPlantValidator)); // setup var logType = ValidObjectHelper.ValidPlantLogType(); var plantSpecies = ValidObjectHelper.ValidPlantSpecies(); var plant1 = ValidObjectHelper.ValidPlant(plantSpecies); var plant2 = ValidObjectHelper.ValidPlant(plantSpecies); var logPlant1 = ValidObjectHelper.ValidPlantLog(plant1, logType); var logPlant2 = ValidObjectHelper.ValidPlantLog(plant2, logType); await context.AddRangeAsync(logType, plantSpecies, plant1, plant2, logPlant1, logPlant2); await context.SaveChangesAsync(); var validator = new UpdatePlantLogForPlantCommandValidator(context); var updateValid = new UpdatePlantLogForPlantCommand { Id = logPlant1.Id, PlantId = plant1.Id, PlantLogTypeId = logType.Id, DateTime = DateTime.Now, Log = LoremIpsum.Words(2) }; validator.ShouldNotHaveValidationErrorFor(updatePlantLogForPlantCommand => updatePlantLogForPlantCommand.Id, updateValid); validator.ShouldNotHaveValidationErrorFor(updatePlantLogForPlantCommand => updatePlantLogForPlantCommand.PlantId, updateValid); validator.ShouldNotHaveValidationErrorFor(updatePlantLogForPlantCommand => updatePlantLogForPlantCommand.PlantLogTypeId, updateValid); validator.ShouldNotHaveValidationErrorFor(updatePlantLogForPlantCommand => updatePlantLogForPlantCommand.DateTime, updateValid); validator.ShouldNotHaveValidationErrorFor(updatePlantLogForPlantCommand => updatePlantLogForPlantCommand.Log, updateValid); // wrong plant id var updateInvalidPlantId = new UpdatePlantLogForPlantCommand { Id = logPlant1.Id, PlantId = plant2.Id, PlantLogTypeId = logType.Id, DateTime = DateTime.Now, Log = LoremIpsum.Words(2) }; validator.ShouldNotHaveValidationErrorFor(updatePlantLogForPlantCommand => updatePlantLogForPlantCommand.Id, updateInvalidPlantId); validator.ShouldHaveValidationErrorFor(updatePlantLogForPlantCommand => updatePlantLogForPlantCommand.PlantId, updateInvalidPlantId); validator.ShouldNotHaveValidationErrorFor(updatePlantLogForPlantCommand => updatePlantLogForPlantCommand.PlantLogTypeId, updateInvalidPlantId); validator.ShouldNotHaveValidationErrorFor(updatePlantLogForPlantCommand => updatePlantLogForPlantCommand.DateTime, updateInvalidPlantId); validator.ShouldNotHaveValidationErrorFor(updatePlantLogForPlantCommand => updatePlantLogForPlantCommand.Log, updateInvalidPlantId); // wrong log type id var updateInvalidLogType = new UpdatePlantLogForPlantCommand { Id = logPlant1.Id, PlantId = plant1.Id, PlantLogTypeId = Guid.NewGuid(), DateTime = DateTime.Now, Log = LoremIpsum.Words(2) }; validator.ShouldNotHaveValidationErrorFor(updatePlantLogForPlantCommand => updatePlantLogForPlantCommand.Id, updateInvalidLogType); validator.ShouldNotHaveValidationErrorFor(updatePlantLogForPlantCommand => updatePlantLogForPlantCommand.PlantId, updateInvalidLogType); validator.ShouldHaveValidationErrorFor(updatePlantLogForPlantCommand => updatePlantLogForPlantCommand.PlantLogTypeId, updateInvalidLogType); validator.ShouldNotHaveValidationErrorFor(updatePlantLogForPlantCommand => updatePlantLogForPlantCommand.DateTime, updateInvalidLogType); validator.ShouldNotHaveValidationErrorFor(updatePlantLogForPlantCommand => updatePlantLogForPlantCommand.Log, updateInvalidLogType); }
/// <summary> /// Creates the HTML from markdown. /// </summary> /// <param name="hp">The hp.</param> /// <returns></returns> private string CreateHTMLFromMarkdown(HelpPage hp) { string strMarkdownFilename = $"{Path}\\{hp.Document}"; string strMarkdownContent = File.Exists(strMarkdownFilename) ? File.ReadAllText(strMarkdownFilename, Encoding.Default) : LoremIpsum.GetLoremIpsum(); return(Markdown.ToHtml(strMarkdownContent, MAPI)); }
public void Should_generate_single_character() { var result = LoremIpsum.Text(1, false); Assert.Equal("l", result); }
protected void Page_Load(object sender, EventArgs e) { LoremIpsum text = new LoremIpsum(); litoutput.Text = WSOL.Messaging.Message(text.GetLoremIpsum(5, true), System.Diagnostics.EventLogEntryType.SuccessAudit); }
public void ShouldHandleFacade() { LoremIpsum.GetParagraph().Length.ShouldBeGreaterThan(20); }
public void Generate_Returns_String() { var data = LoremIpsum.Generate(5); Assert.IsInstanceOfType(data, typeof(String)); }