public void TestLoadXml() { string template ="<root><text>{0}</text></root>"; string expectedText = "Lorem ipsum dolor sit amet"; string formatted = String.Format(template, expectedText); LipsumGenerator lipsum = new LipsumGenerator(formatted, true); Assert.AreEqual(lipsum.LipsumText.ToString(), expectedText); }
public StoryPostQueryFixture() { Context = TestSpmsContextFactory.Create(); var game = Context.Game.First(); Context.Biography.Add(new Domain.Models.Biography() { Firstname = "Dan", Surname = "Taylor", Player = new Player() { AuthString = "123" }, State = new BiographyState() { Default = false, Name = "State", GameId = game.Id }, Posting = new Posting() { Name = "Starbase Gamma" } }); Context.SaveChanges(); var ipsum = new NLipsum.Core.LipsumGenerator(); var sentences = ipsum.GenerateSentences(3, new Sentence(5, 20)); var episodeEntry = new EpisodeEntry() { Title = sentences[0], Location = sentences[1], Timeline = sentences[2], Content = ipsum.GenerateLipsum(5), EpisodeId = Context.Episode.First().Id, EpisodeEntryTypeId = Context.EpisodeEntryType.First(x => x.Name == StaticValues.Post).Id, EpisodeEntryStatusId = Context.EpisodeEntryStatus.First(x => x.Name == StaticValues.Published).Id }; Context.EpisodeEntry.Add(episodeEntry); Context.SaveChanges(); var configurationProvider = new MapperConfiguration(cfg => { cfg.AddProfile <ApplicationMapper>(); }); Mapper = configurationProvider.CreateMapper(); }
public void TestPrepareWords() { string rawText = "lorem ipsum dolor sit amet consetetur"; string[] expectedArray = new string[] { "lorem", "ipsum", "dolor", "sit", "amet", "consetetur" }; int wordsInRawText = 6; LipsumGenerator lipsum = new LipsumGenerator(rawText, false); string[] wordsPrepared = lipsum.PreparedWords; Assert.AreEqual(wordsInRawText, wordsPrepared.Length); #if PORTABLE CollectionAssert.AreEqual(wordsPrepared, expectedArray); #else CollectionAssert.AreElementsEqual(wordsPrepared, expectedArray); #endif }
public void TestGenerateParagraphs() { string rawText = Lipsums.LoremIpsum; LipsumGenerator lipsum = new LipsumGenerator(rawText, false); int desiredParagraphCount = 5; string[] generatedParagraphs = lipsum. GenerateParagraphs(desiredParagraphCount, Paragraph.Medium); Assert.AreEqual(desiredParagraphCount, generatedParagraphs.Length, "Retrieved sentence count mismatch."); for (int i = 0; i < desiredParagraphCount; i++) { Assert.IsNotNull(generatedParagraphs[i], String.Format("Generated paragraph [{0}] is null.", i)); StringAssert.IsNonEmpty(generatedParagraphs[i]); } }
public void TestGenerateWords() { string rawText = "lorem ipsum dolor sit amet consetetur"; LipsumGenerator lipsum = new LipsumGenerator(rawText, false); int wordCount = 4; string[] generatedWords = lipsum.GenerateWords(wordCount); Assert.AreEqual(wordCount, generatedWords.Length); for (int i = 0; i < wordCount; i++) { #if PORTABLE StringAssert.Contains(generatedWords[i], rawText); #else Assert.Contains(rawText, generatedWords[i]); #endif } }
public void TestGenerateCharacters() { string rawText = "lorem ipsum dolor sit amet consetetur"; int desiredCharacterCount = 10; string expectedText = rawText.Substring(0, desiredCharacterCount); LipsumGenerator lipsum = new LipsumGenerator(rawText, false); string[] charsRetrieved = lipsum.GenerateCharacters(desiredCharacterCount); // This should only retrieve one string Assert.AreEqual(1, charsRetrieved.Length); string generatedString = charsRetrieved[0]; Assert.IsNotNull(generatedString); Assert.IsNotEmpty(generatedString); Assert.AreEqual(expectedText, generatedString); }
public void TestGenerateSentences() { string rawText = Lipsums.LoremIpsum; LipsumGenerator lipsum = new LipsumGenerator(rawText, false); int desiredSentenceCount = 5; string[] generatedSentences = lipsum. GenerateSentences(desiredSentenceCount, Sentence.Medium); Assert.AreEqual(desiredSentenceCount, generatedSentences.Length, "Retrieved sentence count mismatch."); for (int i = 0; i < desiredSentenceCount; i++) { Assert.IsNotNull(generatedSentences[i], String.Format("Generated sentence [{0}] is null.", i)); #if PORTABLE Assert.IsNotEmpty(generatedSentences[i]); #else StringAssert.IsNonEmpty(generatedSentences[i]); #endif } }
public void DefaultConstructorContainsLoremIpsum() { string expected = Lipsums.LoremIpsum; var generator = new LipsumGenerator(); Assert.AreEqual(expected, generator.LipsumText.ToString()); }
public void TestLoadPlainText() { string expectedText = "Lorem ipsum dolor sit amet"; LipsumGenerator lipsum = new LipsumGenerator(expectedText, false); Assert.AreEqual(lipsum.LipsumText.ToString(), expectedText); }
/// <summary> /// Gets a number of lorem ipsum paragraphs with out HTML formating /// </summary> /// <example> /// To create five paragraphs that will NOT be nested in HTML 'p' tags. /// <code> /// @Html.Paragraphs(5) /// </code> /// </example> /// <param name="count">Number of paragraphs to create.</param> /// <returns></returns> public Ipsum Paragraphs(int count) { var paragraphs = new LipsumGenerator().GenerateParagraphs(count); _ipsum.Add(String.Join(" ", paragraphs)); return this; }
public void Test_DefaultConstructor_LoadsLoremIpsum() { var lipsum = new LipsumGenerator(); string x = lipsum.LipsumText.ToString(); string y = Lipsums.LoremIpsum.ToString(); StringAssert.Equals(x, y); }
public void TestSingleSentence_DoesNotThrow_ArgumentOutOfRangeException() { // From reported issue: http://code.google.com/p/nlipsum/issues/detail?id=3 var lipsum = new LipsumGenerator(); bool hasThrownArgException = false; try { lipsum.GenerateSentences(1, Sentence.Short); } catch (ArgumentException ex) { hasThrownArgException = true; } Assert.IsFalse(hasThrownArgException); }
/// <summary> /// Gets a number of lorem ipsum words with out HTML formatting /// </summary> /// <example>To Create: Lorem ipsum dolor sit amet /// <code> /// @Html.Ipsum().Words(5) /// </code> /// </example> /// <param name="count">Number of words to create.</param> /// <returns></returns> public Ipsum Words(int count) { var words = new LipsumGenerator().GenerateWords(count); _ipsum.Add(String.Join(" ", words)); return this; }
private void btnOk_Click(object sender, RoutedEventArgs e) { SaveSelection(); int length; if (int.TryParse(txLength.Text, out length)) { Type type = typeof(Lipsums); string propName = ((string)cbType.SelectedItem).Replace(" ", string.Empty); var prop = type.GetProperty(propName); string vocab = (string)prop.GetValue(null, null); var generator = new LipsumGenerator(vocab, false); string[] words = generator.GenerateWords(length); Text = UppercaseFirst(string.Join(" ", words)); DialogResult = true; } }
public void TestSentenceCapitalizationAndPunctuation() { string rawText = "this"; LipsumGenerator lipsum = new LipsumGenerator(rawText, false); string[] generatedSentences = lipsum.GenerateSentences(1, new Sentence(1, 1)); string desiredSentence = "This."; Assert.AreEqual(desiredSentence, generatedSentences[0]); }
/// <summary> /// Generates 'count' features. /// </summary> /// <param name="count">The number of features desired.</param> /// <param name="feature">The type of feature desired.</param> /// <param name="formatString">The string with which to format the feature.</param> /// <param name="rawText">The text from which to generate the Lipsum.</param> /// <returns></returns> public static string Generate(int count, Features feature, string formatString, string rawText) { LipsumGenerator generator = new LipsumGenerator(rawText, false); return(generator.GenerateLipsum(count, feature, formatString)); }
/// <summary> /// Generates 'count' features. /// </summary> /// <param name="count">The number of features desired.</param> /// <param name="feature">The type of feature desired.</param> /// <param name="formatString">The string with which to format the feature.</param> /// <param name="rawText">The text from which to generate the Lipsum.</param> /// <returns></returns> public static string Generate(int count, Features feature, string formatString, string rawText) { LipsumGenerator generator = new LipsumGenerator(rawText, false); return generator.GenerateLipsum(count, feature, formatString); }