当前位置: 首页>>代码示例>>C#>>正文


C# RandomGenerator.Phrase方法代码示例

本文整理汇总了C#中RandomGenerator.Phrase方法的典型用法代码示例。如果您正苦于以下问题:C# RandomGenerator.Phrase方法的具体用法?C# RandomGenerator.Phrase怎么用?C# RandomGenerator.Phrase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RandomGenerator的用法示例。


在下文中一共展示了RandomGenerator.Phrase方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetUpClass

        public static void SetUpClass(TestContext context)
        {
            var seq = new SequentialGenerator<int> { Direction = GeneratorDirection.Ascending };
            var gen = new RandomGenerator();

            data_users = Builder<User>
                .CreateListOfSize(10)
                .All()
                    .With(u => u.DisplayName = gen.Phrase(15))
                    .Build();

            data_channels = Builder<Channel>
                .CreateListOfSize(20)
                .All()
                    .With(m => m.Id = seq.Generate())
                    .And(x => x.Name = gen.Phrase(15))
                    .And(x => x.AuthorId = gen.Phrase(10))
                    .And(x => x.Author = data_users.First())
                    .And(x => x.Loops = gen.Boolean())
                    .And(x => x.DateCreated = gen.DateTime())
                    .And(x => x.DateUpdated = x.DateCreated + new TimeSpan(3, 0, 0))
                .Random(10)
                    .With(x => x.DateDeactivated = x.DateUpdated + new TimeSpan(3, 0, 0))
                .Build();

            data_musics = Builder<Music>
                .CreateListOfSize(50)
                .All()
                    .With(m => m.Id = seq.Generate())
                    .And(m => m.LengthInMilliseconds = gen.Int())
                    .And(m => m.SizeInBytes = gen.Int())
                    .And(m => m.DateCreated = gen.DateTime())
                    .And(m => m.DateUpdated = m.DateCreated + new TimeSpan(3, 0, 0))
                .Build();

            channels = new Mock<ChannelService>(null);
            musics = new Mock<MusicService>(null);

            channels
                .Setup(x => x.All())
                .ReturnsAsync(data_channels);

            channels
                .Setup(x => x.Paginate(0, 10))
                .ReturnsAsync(data_channels.Take(10).ToList());

            channels
                .Setup(x => x.ActiveChannels(0, 4))
                .ReturnsAsync(data_channels.Take(4).ToList());

            channels
                .Setup(c => c.Deactivate(It.IsAny<Channel>()))
                .ReturnsAsync(1);
        }
开发者ID:uheerme,项目名称:core,代码行数:54,代码来源:ChannelsControllerTest.cs

示例2: EventWebServicesTests

        protected EventWebServicesTests(string baseUri)
        {
            if (string.IsNullOrWhiteSpace(baseUri)) throw new ArgumentNullException(nameof(baseUri));
            if (!Uri.IsWellFormedUriString(baseUri, UriKind.RelativeOrAbsolute)) throw new FormatException("baseUri");

            var rndGenerator = new RandomGenerator();
            GuidKeyGenerator = new SequentialGuidKeyGenerator();
            var fpiKeyGenerator = new FpiKeyGenerator(
                new ContentGenerator<ApprovalStatus>(() => Pick<ApprovalStatus>.RandomItemFrom(new[]
                {
                    ApprovalStatus.Informal, 
                    ApprovalStatus.None
                })),
                new ContentGenerator<string>(() => Pick<string>.RandomItemFrom(new[]
                {
                    "RXJG",
                    "GOGL",
                    "MSFT",
                    "YHOO"
                })),

                new ContentGenerator<string>(() => Pick<string>.RandomItemFrom(new[]
                {
                    "DTD",
                    "XSL",
                    "XML",
                    "JSON"
                })), 
                
                new ContentGenerator<string>(() => rndGenerator.Phrase(10)),
                new ContentGenerator<string>(() => Pick<string>.RandomItemFrom(new[]
                {
                    "EN",
                    "FR",
                    "DE",
                    "ES",
                    "IT",
                    "PL",
                    "RO"
                })));

            var valuesFactory = new ValuesFactory(GuidKeyGenerator);
            var parametersFactory = new ParametersFactory(valuesFactory);
            PropertiesFactory = new PropertiesFactory(GuidKeyGenerator, valuesFactory, parametersFactory);
            AlarmFactory = new AlarmFactory(GuidKeyGenerator, PropertiesFactory, valuesFactory);

            EventFactory = new EventFactory(GuidKeyGenerator, AlarmFactory, PropertiesFactory, valuesFactory);
            CalendarFactory = new CalendarFactory(GuidKeyGenerator, fpiKeyGenerator);

            ServiceClientFactory = new ServiceClientFactory();
            ServiceClientFactory.Register(() => new JsonServiceClient(baseUri));
            ServiceClientFactory.Register(() => new JsvServiceClient(baseUri));
            ServiceClientFactory.Register(() => new XmlServiceClient(baseUri));

            TestService = new EventTestService();
        }
开发者ID:reexjungle,项目名称:xcal,代码行数:56,代码来源:event.web.service.tests.cs

示例3: Comments

        private static List<Comment> Comments(User user, string thingId, int max, RandomGenerator randomGenerator)
        {
            var list = new List<Comment>();
            for (var i = 0; i < max; i++)
            {
                list.Add(new Comment()
                    {
                        ThingId = thingId,
                        UserId = user.Id,
                        Username = user.Username,
                        Email = user.Email,
                        Description = randomGenerator.Phrase(200),
                        CreationDate = randomGenerator.Next(DateTime.UtcNow.AddDays(-30), DateTime.UtcNow)
                    });
            }

            return list;
        }
开发者ID:benpowell,项目名称:RavenLocal,代码行数:18,代码来源:FakeThings.cs

示例4: Fake

        /// <summary>
        /// Fakes the specified number of items.
        /// </summary>
        /// <param name="users">The users.</param>
        /// <param name="numberOfItems">The number of items.</param>
        /// <returns>
        /// A list.
        /// </returns>
        public static IList<Thing> Fake(ICollection<User> users, int numberOfItems)
        {
            var randomGenerator = new RandomGenerator();
            var things = Builder<Thing>
                .CreateListOfSize(numberOfItems)
                .All()
                .With(x => x.Id = string.Format("Thing-{0}", x.Id))
                .With(x => x.UserId = Pick<User>.RandomItemFrom((IList<User>)users).Id)
                .With(x => x.Latitude = users.Where(u => u.Id == x.UserId).FirstOrDefault().Latitude)
                .With(x => x.Longitude = users.Where(u => u.Id == x.UserId).FirstOrDefault().Longitude)
                .With(x => x.Description = randomGenerator.Phrase(500))
                .With(x => x.ImageUrls = ImageUrls(randomGenerator.Next(1, 5), randomGenerator))
                .Build();

            foreach (var thing in things)
            {
                thing.Comments = Comments(Pick<User>.RandomItemFrom((IList<User>)users), thing.Id, 5, randomGenerator);
                thing.Offers = Offers(Pick<User>.RandomItemFrom((IList<User>)users), thing.Id, 5, randomGenerator);
            }

            return things;
        }
开发者ID:benpowell,项目名称:RavenLocal,代码行数:30,代码来源:FakeThings.cs

示例5: TestPutChannel

        public async Task TestPutChannel()
        {
            var gen = new RandomGenerator();
            var anyChannel = data_channels.First();

            var model = new ChannelUpdateViewModel
            {
                Id = anyChannel.Id,
                Name = gen.Phrase(10),
                Loops = gen.Boolean(),
            };

            var result = await controller.PutChannel(model);
            var response = await result.ExecuteAsync(CancellationToken.None);

            Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
        }
开发者ID:uheerme,项目名称:core,代码行数:17,代码来源:ChannelsControllerTest.cs

示例6: TestPostChannel

        public async Task TestPostChannel()
        {
            var gen = new RandomGenerator();
            
            var model = new ChannelCreateViewModel
            {
                Name = gen.Phrase(10),
                Owner = gen.Phrase(10),
                HostIpAddress = "127.0.0.1",
                HostMacAddress = "23:3c:30:e4"
            };

            var result = (CreatedAtRouteNegotiatedContentResult<ChannelResultViewModel>)await controller.PostChannel(model);

            Assert.IsNotNull(result);
            Assert.IsNotNull(result.Content);
            Assert.IsTrue(result.Content.Id > 0);
        }
开发者ID:uheerme,项目名称:core,代码行数:18,代码来源:ChannelsControllerTest.cs


注:本文中的RandomGenerator.Phrase方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。