本文整理汇总了C#中RandomGenerator.Int方法的典型用法代码示例。如果您正苦于以下问题:C# RandomGenerator.Int方法的具体用法?C# RandomGenerator.Int怎么用?C# RandomGenerator.Int使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RandomGenerator
的用法示例。
在下文中一共展示了RandomGenerator.Int方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: RandomGenerator_SeedInitialization_ShouldAllowRandomValuesToBeRepeatable
public void RandomGenerator_SeedInitialization_ShouldAllowRandomValuesToBeRepeatable()
{
const int seed = 5;
IRandomGenerator seededRandomGenerator1 = new RandomGenerator(seed);
IRandomGenerator seededRandomGenerator2 = new RandomGenerator(seed);
Assert.That(seededRandomGenerator1.Int(), Is.EqualTo(seededRandomGenerator2.Int()));
Assert.That(seededRandomGenerator1.Int(), Is.EqualTo(seededRandomGenerator2.Int()));
Assert.That(seededRandomGenerator1.Int(), Is.EqualTo(seededRandomGenerator2.Int()));
Assert.That(seededRandomGenerator1.Int(), Is.EqualTo(seededRandomGenerator2.Int()));
}