public void Should_Generate_Characters([Range(1, 100)] int charCount)
        {
            string characters = Lorem.Characters(charCount);

            Assert.That(characters, Has.Length.EqualTo(charCount));
        }
Ejemplo n.º 2
0
        public void Should_Return_Word_List()
        {
            var words = Lorem.Words(10);

            Assert.AreEqual(10, words.Count());
        }
Ejemplo n.º 3
0
        public void Should_Generate_Paragraph()
        {
            var para = Lorem.Paragraph();

            Assert.IsTrue(Regex.IsMatch(para, @"([A-Z][a-z ]+\.\s?){3,6}"));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Se crea un cliente con datos aleatorios y se realiza un nuevo pedido.
        /// </summary>
        public static void NuevoPedido()
        {
            Cliente a = new Cliente(Lorem.Words(1, true, false), Lorem.Words(1, true, false) + " " + Lorem.Number(0, 9999).ToString());

            a.RealizarPedido();
        }
 private IEnumerable <Claim> GenerateClaims(int userId)
 {
     return(Range(1, _rnd.Next(1, 7)).Select(i => new Claim(Job.Title, Lorem.Paragraph(), userId)).ToList());
 }
Ejemplo n.º 6
0
        public void Valid_ParseMoneyTest()
        {
            long number = Lorem.Number(1, 2000);

            Assert.AreEqual((decimal)number, TextUtil.ParseMoney(number.ToString()));
        }
Ejemplo n.º 7
0
 public LoremTests()
 {
     lorem = new Lorem();
 }
Ejemplo n.º 8
0
        public static void Seed(ThuVienDb context)
        {
            // Users
            context.Users.Add(new User
            {
                Username = "******",
                Password = "******",
                Email    = "*****@*****.**",
                Fullname = "Ngô Xuân Bách"
            });
            context.Users.Add(new User
            {
                Username = "******",
                Password = "******",
                Email    = "*****@*****.**",
                Fullname = "Đinh Viết Nam"
            });
            // Authors
            context.Authors.AddRange(new[]
            {
                new Author {
                    Name = "Nguyễn Ngọc Ngạn", Description = "Giới thiệu tác giả"
                },
                new Author {
                    Name = "Trần Thu Hương", Description = "Giới thiệu tác giả"
                },
                new Author {
                    Name = "Bùi Quốc Dũng", Description = "Giới thiệu tác giả"
                },
                new Author {
                    Name = "Hoàng Văn Quân", Description = "Giới thiệu tác giả"
                },
                new Author {
                    Name = "Đinh Sơn Nam", Description = "Giới thiệu tác giả"
                },
                new Author {
                    Name = "Ngô Ngọc Thành", Description = "Giới thiệu tác giả"
                },
                new Author {
                    Name = "Bùi Xuân Quyết", Description = "Giới thiệu tác giả"
                }
            });
            // Publisher
            context.Publishers.AddRange(new[]
            {
                new Publisher {
                    Name = "Kim Đồng", Description = "Giới thiệu về nhà xuất bản"
                },
                new Publisher {
                    Name = "Tuổi trẻ", Description = "Giới thiệu về nhà xuất bản"
                },
                new Publisher {
                    Name = "Văn Học", Description = "Giới thiệu về nhà xuất bản"
                },
                new Publisher {
                    Name = "Điện Lực", Description = "Giới thiệu về nhà xuất bản"
                }
            });
            // Category
            context.Categories.AddRange(new[]
            {
                new Category {
                    Name = "Tiểu thuyết"
                },
                new Category {
                    Name = "Sách giáo khoa"
                },
                new Category {
                    Name = "Truyện tiếu lâm"
                },
                new Category {
                    Name = "Truyện thiếu nhi"
                },
                new Category {
                    Name = "Sách văn học"
                },
                new Category {
                    Name = "Sách tham khảo"
                },
                new Category {
                    Name = "Khoa học viễn tưởng"
                },
                new Category {
                    Name = "Truyện tranh"
                },
                new Category {
                    Name = "Sách nông nghiệp"
                }
            });
            // Reader
            var readers = new List <Reader>();

            readers.Add(new Reader
            {
                Username    = "******",
                Password    = "******",
                Fullname    = "Ngô Xuân Bách",
                Address     = Address.StreetAddress(),
                PhoneNumber = "0987654321",
                Email       = "*****@*****.**"
            });
            for (var i = 0; i < 50; i++)
            {
                readers.Add(new Reader
                {
                    Username    = Internet.UserName(),
                    Password    = "******",
                    Fullname    = Name.FullName(),
                    Address     = Address.StreetAddress(),
                    PhoneNumber = "0987654321",
                    Email       = "*****@*****.**"
                });
            }
            context.Readers.AddRange(readers);
            context.SaveChanges();
            // Books
            var authors    = context.Authors.ToList();
            var publishers = context.Publishers.ToList();
            var categories = context.Categories.ToList();
            var books      = BookTitles //Enumerable.Range(0, 200)
                             .Select(x => new Book
            {
                Author       = authors[RandomNumber.Next(authors.Count)],
                Category     = categories[RandomNumber.Next(categories.Count)],
                Publisher    = publishers[RandomNumber.Next(publishers.Count)],
                Count        = RandomNumber.Next(10, 100),
                Description  = Lorem.Paragraph(),
                Name         = x,
                Price        = RandomNumber.Next(10, 100) * 1000,
                NumberOfPage = RandomNumber.Next(40, 345),
                PublishYear  = RandomNumber.Next(2008, 2017),
                ThumbnailUrl = Thumbnails.Random()
            })
                             .ToList();

            context.Books.AddRange(books);
            // Tickets
            var tickets = new List <Ticket>();

            for (var i = 0; i < 30; i++)
            {
                var date = DateTime.Today.Subtract(new TimeSpan(i, 0, 0, 0));
                for (var j = 0; j < RandomNumber.Next(5, 15); j++)
                {
                    var ticket = new Ticket {
                        DateCreated = date, Reader = readers[RandomNumber.Next(readers.Count)]
                    };
                    var tmp = RandomNumber.Next(4) + 2;
                    if (i >= tmp)
                    {
                        ticket.DateReturned = date.Add(new TimeSpan(tmp, 0, 0, 0));
                    }
                    tmp = RandomNumber.Next(3, 6);
                    while (tmp-- >= 0)
                    {
                        ticket.Books.Add(books[RandomNumber.Next(books.Count)]);
                    }
                    tickets.Add(ticket);
                }
            }
            context.Tickets.AddRange(tickets);
            context.SaveChanges();
        }
Ejemplo n.º 9
0
 public LoremTests(ITestOutputHelper console)
 {
     this.console = console;
     lorem        = new Lorem();
 }
 public void Should_Throw_ArgumentOutOfRangeException_If_Sentences_Count_Is_Zero()
 {
     Assert.Throws <ArgumentOutOfRangeException>(() => Lorem.Sentences(0));
 }
 public void Should_Throw_ArgumentOutOfRangeException_If_Words_Count_Below_Zero()
 {
     Assert.Throws <ArgumentOutOfRangeException>(() => Lorem.Words(-1));
 }
 public void Should_Throw_ArgumentOutOfRangeException_If_Sentence_Count_Below_Zero()
 {
     Assert.Throws <ArgumentOutOfRangeException>(() => Lorem.Paragraph(-1));
 }
        public void Should_Generate_Random_Word_Sentence()
        {
            string sentence = Lorem.Sentence();

            Assert.That(sentence, Is.StringMatching(@"^[A-z ]+\.$"));
        }
        public void Should_Generate_Paragraph()
        {
            string para = Lorem.Paragraph();

            Assert.That(para, Is.StringMatching(@"^([A-z ]+\.\s?){3,6}$"));
        }
Ejemplo n.º 15
0
 public void Valid_IsMoneyTest()
 {
     Assert.AreEqual(true, TextUtil.IsMoney(Lorem.Number(1, 2000).ToString()));
 }
Ejemplo n.º 16
0
 public void Foo()
 {
     Config.Locale = "ja";
     const int wordCount = 3;
     var       combined  = wordCount.Times(_ => Lorem.Word()).Concat(wordCount.Times(_ => Lorem.SupplementalWord())).ToArray();
     //result.AddRange(combined.Shuffle().Take(wordCount));
 }
Ejemplo n.º 17
0
 public void InValid_IsMoneyTest()
 {
     Assert.AreEqual(false, TextUtil.IsMoney(Lorem.Words(0, true, true)));
     Assert.AreEqual(false, TextUtil.IsMoney(Lorem.Words(3, true, true)));
     Assert.AreEqual(false, TextUtil.IsMoney(Lorem.Words(3, true, true) + Lorem.Number(1, 2000)));
 }
Ejemplo n.º 18
0
 private string GetFirstDefaultWord()
 {
     return(Lorem.GetFirstWord());
 }
Ejemplo n.º 19
0
 public void InValid_ParseMoneyTest()
 {
     Assert.AreEqual(0, TextUtil.ParseMoney(Lorem.Words(0, true, true)));
     Assert.AreEqual(0, TextUtil.ParseMoney(Lorem.Words(3, true, true)));
 }
Ejemplo n.º 20
0
 public void Valid_IsNullTest()
 {
     Assert.AreEqual(false, TextUtil.IsNull(Lorem.Words(3, true, true)));
     Assert.AreEqual(false, TextUtil.IsNull(Lorem.Number(1, 10000).ToString()));
     Assert.AreEqual(false, TextUtil.IsNull(Lorem.Words(5, true, true)));
 }
Ejemplo n.º 21
0
 private void btnInitillize_Click(object sender, EventArgs e)
 {
     #region Ürünler
     var products = new List <Product>();
     for (int i = 0; i < 100; i++)
     {
         var name = Lorem.Words(1).ElementAt(0);
         var p    = new Product
         {
             Id         = i + 1,
             Name       = name.Substring(0, 1).ToUpper() + name.Substring(1).ToLower(),
             CategoryId = RandomNumber.Next(1, 10),
             SupplierId = RandomNumber.Next(1, 25),
             Stock      = RandomNumber.Next(0, 800),
             Price      = RandomNumber.Next(1, 5600)
         };
         products.Add(p);
     }
     FileManager.SaveProducts(products);
     #endregion
     #region Kategoriler
     var categories = new List <Category>
     {
         new Category {
             Id = 1, Name = "Giyim"
         },
         new Category {
             Id = 2, Name = "Yiyecek"
         },
         new Category {
             Id = 3, Name = "İçecek"
         },
         new Category {
             Id = 4, Name = "Elektronik"
         },
         new Category {
             Id = 5, Name = "Kırtasiye"
         },
         new Category {
             Id = 6, Name = "Züccaciye"
         },
         new Category {
             Id = 7, Name = "Mobilya"
         },
         new Category {
             Id = 8, Name = "Ayakkabı"
         },
         new Category {
             Id = 9, Name = "Takı"
         },
         new Category {
             Id = 10, Name = "Beyaz Eşya"
         }
     };
     FileManager.SaveCategories(categories);
     #endregion
     #region Sağlayıcılar
     var suppliers = new List <Supplier>();
     for (int i = 0; i < 25; i++)
     {
         var s = new Supplier
         {
             Id    = i + 1,
             Name  = Company.Name(),
             Phone = Phone.Number()
         };
         suppliers.Add(s);
     }
     FileManager.SaveSuppliers(suppliers);
     #endregion
 }
Ejemplo n.º 22
0
 public void InValid_IsNullTest()
 {
     Assert.AreEqual(true, TextUtil.IsNull(null));
     Assert.AreEqual(true, TextUtil.IsNull(Lorem.Words(0, true, true)));
 }
Ejemplo n.º 23
0
        public static async Task Initialize(
            ApplicationDbContext dbContext,
            UserManager <ApplicationUser> userManager)
        {
            dbContext.Database.EnsureCreated();

            // Look for any students.
            if (dbContext.KnoledgeEntries.Any())
            {
                return;   // DB has been seeded
            }

            await CreateUserAsync(dbContext, userManager);

            GenFu.GenFu.Configure <Document>()
            .Fill(x => x.Id, 0)
            .Fill(x => x.Type).WithRandom(new[]
            {
                DocumentType.Audio,
                DocumentType.Video,
                DocumentType.Image,
                DocumentType.Document
            });

            GenFu.GenFu.Configure <Link>()
            .Fill(x => x.Id, 0);

            GenFu.GenFu.Configure <KnowledgeEntry>()
            .Fill(x => x.Id, 0)
            .Fill(x => x.Content, () => Lorem.GenerateSentences(GenFu.GenFu.Random.Next(1, 6)))
            .Fill(x => x.Link, () => null)
            .Fill(x => x.Documents, () => null)
            .Fill(x => x.Date, () => new DateTime(
                      GenFu.GenFu.Random.Next(2010, 2016),
                      GenFu.GenFu.Random.Next(1, 12),
                      GenFu.GenFu.Random.Next(1, 29),
                      GenFu.GenFu.Random.Next(0, 23),
                      GenFu.GenFu.Random.Next(0, 59),
                      GenFu.GenFu.Random.Next(0, 59)));


            var entries = A.ListOf <KnowledgeEntry>(300);

            foreach (var entry in entries)
            {
                dbContext.KnoledgeEntries.Add(entry);
                dbContext.SaveChanges();

                var link = A.New <Link>();
                link.KnoledgeEntryId = entry.Id;
                dbContext.Links.Add(link);
                dbContext.SaveChanges();

                var documents = A.ListOf <Document>(GenFu.GenFu.Random.Next(0, 10));
                dbContext.Documents.AddRange(documents.Select(x =>
                {
                    x.KnoledgeEntryId = entry.Id;
                    return(x);
                }));
                dbContext.SaveChanges();
            }
        }
Ejemplo n.º 24
0
 public void Valid_IsDigitTest()
 {
     Assert.AreEqual(true, TextUtil.IsDigit(Lorem.Number(1, 10000).ToString()));
 }
Ejemplo n.º 25
0
 public IEnumerable <string> Paragraphs(Range range)
 => range.Of(() => Lorem.Paragraph(3));
Ejemplo n.º 26
0
 public void Valid_IsEmailTest()
 {
     Assert.AreEqual(true, TextUtil.IsEmail(Lorem.Email()));
 }
Ejemplo n.º 27
0
        public void Should_Generate_Random_Word_Sentence()
        {
            var sentence = Lorem.Sentence();

            Assert.IsTrue(Regex.IsMatch(sentence, @"[A-Z][a-z ]+\."));
        }
Ejemplo n.º 28
0
 public void InValid_IsEmailTest()
 {
     Assert.AreEqual(false, TextUtil.IsEmail(Lorem.Words(1, true, true) + " " + Lorem.Email()));
 }
Ejemplo n.º 29
0
        public void With_Korean_Locale()
        {
            var lorem = new Lorem(locale: "ko");

            Console.WriteLine(lorem.Sentence(5));
        }
Ejemplo n.º 30
0
 public void BeforeEachTest()
 {
     lorem = new Lorem();
 }