本文整理汇总了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);
}
示例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();
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}