Пример #1
0
		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);
		}
Пример #2
0
        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();
        }
Пример #3
0
		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

		}
Пример #4
0
        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]);
            }
        }
Пример #5
0
		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
			}
		}
Пример #6
0
        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);
        }
Пример #7
0
		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
			}
		}
Пример #8
0
	    public void DefaultConstructorContainsLoremIpsum()
	    {
	        string expected = Lipsums.LoremIpsum;
	        var generator = new LipsumGenerator();
	        Assert.AreEqual(expected, generator.LipsumText.ToString());
	    }
Пример #9
0
		public void TestLoadPlainText() {
			string expectedText = "Lorem ipsum dolor sit amet";
			
			LipsumGenerator lipsum = new LipsumGenerator(expectedText, false);
			Assert.AreEqual(lipsum.LipsumText.ToString(), expectedText);
		}
Пример #10
0
 /// <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;
 }
Пример #11
0
 public void Test_DefaultConstructor_LoadsLoremIpsum()
 {
     var lipsum = new LipsumGenerator();
     string x = lipsum.LipsumText.ToString();
     string y = Lipsums.LoremIpsum.ToString();
     StringAssert.Equals(x, y);
 }
Пример #12
0
 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);
 }
Пример #13
0
 /// <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;
            }
        }
Пример #15
0
		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]);
		}
Пример #16
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));
        }
Пример #17
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);			
		}