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


C# RandomGenerator.DateTime方法代码示例

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


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


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