示例#1
0
        private void SeedTweets(ApplicationDbContext context)
        {
            int tweetsCount = 12;

            if (context.Tweets.Count() >= tweetsCount)
            {
                return;
            }

            IList <Tag>    tags    = context.Tags.ToList();
            IList <string> userIds = context.Users.Select(u => u.Id).ToList();

            for (int i = 0; i < tweetsCount; i++)
            {
                Tweet tweet = new Tweet()
                {
                    Content    = Lorem.Paragraph(100, 5),
                    DatePosted = DateTime.Now,
                    UserId     = userIds[i % userIds.Count],
                    Tags       = new List <Tag>()
                    {
                        tags[i % tags.Count]
                    }
                };

                context.Tweets.AddOrUpdate(c => c.Content, tweet);
            }

            context.SaveChanges();
        }
示例#2
0
        private static List <Theatre> createTheaters()
        {
            var theatres = new List <Theatre>();

            theatres.Add(new Theatre
            {
                Id         = "0",
                Name       = "Theatre of Cosmos!",
                Location   = new Location("St. SIGGROU FIX", 37.962870, 23.725762),
                Directions = $"We are near ST.SIGGROU FIX metro station, just follow kalirois avenue to the National Art Museum!",
                Contact    = "You can contact us at \"+30 210 2340 242\" or at \"[email protected]\"",
                Info       = Lorem.Paragraph(5, 5),
                // Halls
                HallsIds = new List <string>(),
                // Plays
                PlaysIds   = new List <string>(),
                ImagesUrls = new string[]
                {
                    "https://picsum.photos/id/20/1920/1440",
                    "https://picsum.photos/id/21/1920/1440",
                    "https://picsum.photos/id/22/1920/1440",
                    "https://picsum.photos/id/23/1920/1440"
                },
                Published = true
            });

            return(theatres);
        }
示例#3
0
 public IndexingBenchmarks()
 {
     texts = new Dictionary <string, string>
     {
         ["iv"] = Lorem.Paragraph(10, 10)
     };
 }
        public static ISingleObjectBuilder <Product> GetDefaultExtras()
        {
            var mock = Builder <Product>
                       .CreateNew()
                       .With(item => item.Name = Pick <string> .RandomItemFrom(new[]
            {
                "Your Choice Extras",
                "Ultimate Health Extras Cover",
                "Young Singles Saver Ancillary",
                "Young Singles Choice Ancillary",
                "Active Saver Extras",
                "Ultimate Health Extras Cover",
                "Silver Extras",
                "Silver Extras",
                "Gold Extras",
                "Gold Extras",
                "Platinum Extras",
                "Platinum Extras",
                "Choices with 70% back Extras",
                "Choices with 80% back Extras",
                "Choices with 90% back Extras",
                "Bronze Extras",
                "Growing Family Ancillary Cover",
                "Growing Family Ancillary Cover",
                "Budget Family Ancillary Cover",
                "Established Family Ancillary Cover",
                "Live Well Ancillary Cover"
            }))
                       .With(item => item.Description = Lorem.Paragraph(3))
                       .With(c => c.Services          = ProductServicesBuilder.GetDefaultExtrasServices().Build().ToArray())
                       .With(item => item.ProductType = ProductType.Extras);

            return(mock);
        }
 protected void btnFakeWord_Click(object sender, EventArgs e)
 {
     for (int i = 0; i < 10; i++)
     {
         Response.Write((i + 1) + " : " + Lorem.Paragraph() + "<br><br>");
     }
 }
示例#6
0
        public void Paragraph_HappyDays()
        {
            var paragraph = Lorem.Paragraph(/* 3 is default */);

            Assert.AreEqual(3, paragraph.Count(c => c.ToString() == Lorem.PunctuationPeriod()));
            Assert.AreEqual(8, paragraph.Count(c => c.ToString() == Lorem.PunctuationSpace()));
        }
        public static ISingleObjectBuilder <Product> GetDefaultHospital()
        {
            var mock = Builder <Product>
                       .CreateNew()
                       .With(item => item.Name = Pick <string> .RandomItemFrom(new[]
            {
                "Top Hospital Cover",
                "Family Essentials Hospital Cover",
                "Ultimate Health Hospital Cover",
                "Young Singles Choice Hospital",
                "Young Singles Saver Hospital",
                "Active Saver Hospital",
                "Top Hospital Cover with $250 Excess",
                "Top Hospital Cover with $500 Excess",
                "Budget Hospital with $250 Excess",
                "Budget Hospital with $500 Excess",
                "Choices Hospital",
                "Standard Hospital with $250 Excess",
                "Standard Hospital with $500 Excess",
                "Growing Family Hospital Cover with $250 Excess",
                "Growing Family Hospital Cover with $500 Excess",
                "Budget Family Hospital Cover with $250 Excess",
                "Budget Family Hospital Cover with $500 Excess",
                "Established Family Hospital Cover with $250 Excess",
                "Established Family Hospital Cover with $500 Excess",
                "Live Well Nil Excess Hospital",
                "Live Well $250 Hospital",
                "Live Well $500 Hospital"
            }))
                       .With(item => item.Description = Lorem.Paragraph(3))
                       .With(c => c.Services          = ProductServicesBuilder.GetDefaultHospitalServices().Build().ToArray())
                       .With(item => item.ProductType = ProductType.Hospital);

            return(mock);
        }
示例#8
0
        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);
        }
        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);
        }
示例#10
0
        public static IListBuilder <ProductService> GetDefaultExtrasServices()
        {
            var generator = new UniqueRandomGenerator();
            var mock      = Builder <ProductService>
                            .CreateListOfSize(10)
                            .All()
                            .With(item => item.Description           = Lorem.Paragraph(1))
                            .With(item => item.WaitingPeriodInMonths = generator.Next(1, 12))
                            .With(item => item.Name = Pick <string> .RandomItemFrom(new[]
            {
                "General Dental",
                "Major dental",
                "Orthodontics",
                "Optical",
                "Physiotherapy",
                "Chiropractic and osteopathy",
                "Antenatal and postnatal",
                "Natural Therapies",
                "Living Well Programs",
                "Pharmacy",
                "Dietary",
                "Psychology",
                "Podiatry",
                "Speech Therapy",
                "Eye Therapy",
                "Occupational Therapy",
                "Home Nursing",
                "Health aids and appliances",
                "Travel and accommodation expenses",
                "Emergency Ambulance Services",
                "Top Up Bonus",
                "Travel Well Benefits"
            }))
                            .With(
                item =>
                item.CoverType =
                    Pick <ProductServiceCoverType> .RandomItemFrom(new[]
            {
                ProductServiceCoverType.CoveredWithCondition,
                ProductServiceCoverType.FullyCovered,
                ProductServiceCoverType.MinimumBenefit,
                ProductServiceCoverType.NotCovered,
            }))
                            .With(
                item =>
                item.ProviderType =
                    Pick <ProductServiceProviderType> .RandomItemFrom(new[]
            {
                ProductServiceProviderType.AllProviders,
                ProductServiceProviderType.MemberFirst,
                ProductServiceProviderType.NonMembersFirst
            }))
                            .With(
                item =>
                item.Type = ProductServiceType.Extras)
                            .With(item => item.Limit = LimitBuilder.GetDefault().Build());

            return(mock);
        }
示例#11
0
        public void ParagraphTest()
        {
            int    sentenceCount = 5;
            string actual;

            actual = Lorem.Paragraph(sentenceCount);
            Assert.IsTrue(actual.Split(' ').Length >= sentenceCount);
        }
示例#12
0
        public void ParagraphTest1()
        {
            int    expected = 3;
            string actual;

            actual = Lorem.Paragraph();
            Assert.IsTrue(expected <= actual.Split(' ').Length);
        }
示例#13
0
 public static Product BuildAProduct(int id)
 {
     return(new Product()
     {
         Id = id.ToString(),
         Name = Lorem.Sentence(3),
         Intro = Lorem.Paragraph(2),
         Price = RandomNumber.Next(10, 1000)
     });
 }
        private Comment CreateComment()
        {
            var result = new Comment();

            result.Body     = Lorem.Paragraph();
            result.Info     = CreateInfo();
            result.IsHidden = Convert.ToBoolean(RandomNumber.Next(0, 1));

            return(result);
        }
示例#15
0
        private ArticleModel CreateArticle()
        {
            var result = new ArticleModel();

            result.Body        = Lorem.Paragraph();
            result.Description = string.Join(" ", Lorem.Paragraphs(RandomNumber.Next(1, 3)));
            result.Info        = CreateInfo();
            result.IsHidden    = Convert.ToBoolean(RandomNumber.Next(0, 1));
            result.Title       = Faker.Lorem.Sentence();
            result.Comments    = CreateComments();

            return(result);
        }
        private Article CreateFakeArticle()
        {
            var result = new Article();

            result._Id      = Guid.NewGuid().ToString();
            result.Body     = Lorem.Paragraph();
            result.Info     = CreateInfo();
            result.IsHidden = Convert.ToBoolean(RandomNumber.Next(0, 1));
            result.Title    = Lorem.Sentence();
            result.ThreadId = Guid.NewGuid().ToString();

            return(result);
        }
示例#17
0
        public void AESEncryptionProvider_Should_Encrypt_Decrypt_Correctly()
        {
            IEncryptionProvider enc = new AESEncryptionProvider();

            for (int i = 0; i < 100; i++)
            {
                string plainText     = Lorem.Paragraph(120);
                string key           = enc.GenerateKey();
                string cipherText    = enc.Encrypt(plainText, key);
                string decryptedText = enc.Decrypt(cipherText, key);

                Assert.Equal(plainText, decryptedText);
            }
        }
        private string GetHtml()
        {
            var sb = new StringBuilder();

            sb.AppendLine("<html>");
            for (var i = 0; i < 100; i++)
            {
                sb.AppendLine("<p>");
                sb.AppendLine(Lorem.Paragraph(10, 10));
                sb.AppendLine("</p>");
            }
            sb.AppendLine("</html>");
            return(sb.ToString());
        }
示例#19
0
        public void EditPackTest()
        {
            var pack           = _packService.GetPackById(Id);
            var newName        = Name.First();
            var newDescription = Lorem.Paragraph(1);

            _packService.EditPack(Id, newName, newDescription);

            var newPack = _packService.GetPackById(Id);

            Assert.That(newPack.Name, Is.EqualTo(newName));
            Assert.That(newPack.Description, Is.EqualTo(newDescription));
            CollectionAssert.AreEqual(pack.Phrases.Select(p => p.Phrase), newPack.Phrases.Select(p => p.Phrase));

            _packService.EditPack(Id, pack.Name, pack.Description);
        }
示例#20
0
 /// <summary>
 /// Fills whole form
 /// </summary>
 public void FillForm()
 {
     FillFirstName();
     FillLastName();
     this.MaritalStatus.ClickRandomElement();
     FillHobby();
     this.Month.SelectRandomElement();
     this.Day.SelectRandomElement();
     this.Year.SelectRandomElement();
     FillPhone();
     FillUsername();
     FillEmail();
     this.ProfilePicture.EnterFile(@"Data\profile-image.png");
     this.Description.EnterFile(Lorem.Paragraph(3));
     FillPasswords("asd123456");
 }
示例#21
0
        public void Paragraph_Use_Supplementary_List()
        {
            var paragraph  = Lorem.Paragraph(supplemental: true);
            var checkCount = 0;

            foreach (var word in paragraph.ToWordList())
            {
                checkCount++;
                if (!JointWords.Contains(word) &&
                    SupplementalWordList.Contains(word))
                {
                    return;
                }
            }
            Assert.AreEqual(checkCount, paragraph.ToWordList().Count());
            Assert.Fail("Paragraph() does not consider supplementary list.");
        }
示例#22
0
        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);
        }
示例#23
0
        static LaunchingService()
        {
            //launching complete fake data
            LaunchingCompleted = Builder <LaunchingCompleted>
                                 .CreateListOfSize(100)
                                 .All()
                                 .With(q => q.ClientName  = Name.FullName(NameFormats.Standard))
                                 .With(q => q.QuoteNumber = QuoteNumberGenerator.Generate()).Build();


            // launching Incompleted fake data
            LaunchingInComplete = Builder <LaunchingIncomplete>
                                  .CreateListOfSize(100)
                                  .All()
                                  .With(q => q.ClientName  = Name.FullName(NameFormats.Standard))
                                  .With(q => q.QuoteNumber = QuoteNumberGenerator.Generate())
                                  .With(q => q.Comments    = Lorem.Paragraph(10))
                                  .Build();
        }
示例#24
0
        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);
        }
示例#25
0
 private static void SetupSubscriptionFakers(Lorem lorem)
 {
     _sourceSubscriptionFaker = new Faker <SourceSubscription>()
                                .RuleFor(s => s.Id, f => 0)
                                .RuleFor(s => s.Name, f => lorem.Word())
                                .RuleFor(s => s.CreatedDate, f => DateTimeOffset.Now)
                                .RuleFor(s => s.UpdateDate, f => DateTimeOffset.Now)
                                .RuleFor(s => s.Parameters, f => "{}");
     _sourceSubscriptionCreateDtoFaker = new Faker <SubscriptionCreateDto>()
                                         .RuleFor(s => s.Name, f => lorem.Word())
                                         .RuleFor(s => s.Parameters, f => "{}")
                                         .RuleFor(s => s.SourceTypeId, f => 1);
     _subscriptionVacancyFaker = new Faker <SubscriptionVacancy>()
                                 .RuleFor(s => s.Id, f => 0)
                                 .RuleFor(s => s.Comment, f => lorem.Paragraph())
                                 .RuleFor(s => s.Rating, f => f.Random.Int(0, 5))
                                 .RuleFor(s => s.IsHidden, f => f.Random.Bool())
                                 .RuleFor(s => s.Vacancy, f => _vacancyFaker.Generate());
 }
示例#26
0
        public void Paragraph_NonDefault_Value()
        {
            const int sentenceCount = 42;
            var       paragraph     = Lorem.Paragraph(sentenceCount);

            Assert.GreaterOrEqual(paragraph.Count(c => c.ToString() == Lorem.PunctuationPeriod()), sentenceCount);
            var wordListLower = WordList.Select(w => w.ToLower());

            foreach (var word in paragraph.ToWordList())
            {
                if (paragraph.ToLower().Contains(word + Lorem.PunctuationPeriod()))
                {
                    // Last word in sentence might be truncated or padded.
                    continue;
                }
                Assert.IsTrue(wordListLower.Contains(word.ToLower()),
                              $"Locale is '{Locale}'. Missing word is '{word}'. Paragraph is '{paragraph}'"
                              );
            }
        }
示例#27
0
        private static void AddNewArticle(int blogNumber = 0)
        {
            Name  nameGenerator = new Name();
            Lorem textGenerator = new Lorem();

            string name       = textGenerator.Sentence();
            string text       = textGenerator.Paragraph(45);
            int    tagsAmount = new Random().Next(5, 15);
            var    tags       = textGenerator.Words(tagsAmount);

            var r     = new Random();
            int likes = r.Next(100, 10000);
            int views = r.Next(10000, 100000);

            var comments = Enumerable.Range(0, r.Next(5, 50)).Select(i => GetNewRandomComment());

            AddArticleModel addArticleModel = new AddArticleModel(name, text, tags, UserToSeed, blogNumber, views, likes, comments);

            var controller = factory.CreateArticlesController();

            controller.Add(addArticleModel);
        }
示例#28
0
        private static Comment GetNewRandomComment()
        {
            var users = factory.UsersRepository.GetAll().ToArray();

            var random    = new Random();
            var userIndex = random.Next(0, 3);
            var likes     = random.Next(10, 100);

            Lorem textGenerator = new Lorem();
            Date  date          = new Date();
            var   text          = textGenerator.Paragraph(random.Next(0, 5));

            var lastModified = new Date().Between(DateTime.Now.AddDays(-360), DateTime.Now.AddDays(-360));

            List <Comment> replies = new List <Comment>();

            while (random.Next(0, 3) == 1)
            {
                replies.Add(GetNewRandomComment());
            }

            return(new Comment(users[userIndex].Name, likes, lastModified, text, replies.ToArray()));
        }
示例#29
0
        public async Task <HttpResponseMessage> LoadAllAsync()
        {
            var database           = _mongoClient.GetDatabase("PerformanceSandbox");
            var productsCollection = database.GetCollection <Product>("Products");

            var count = await productsCollection.AsQueryable().CountAsync();

            if (count <= 30)
            {
                for (var i = 0; i < 30; i++)
                {
                    var product = new Product(Company.Name())
                    {
                        Description       = Lorem.Paragraph(),
                        QuantityAvailable = 10
                    };
                    await productsCollection.InsertOneAsync(product);
                }
            }

            var products = await productsCollection.AsQueryable().ToListAsync();

            return(Request.CreateResponse(products));
        }
 public IEnumerable <string> Paragraphs(Range range)
 => range.Of(() => Lorem.Paragraph(3));