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


C# Generator.Next方法代码示例

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


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

示例1: Continue_WithNestedProperty_SetsField

 public void Continue_WithNestedProperty_SetsField()
 {
     using (var gen = new Generator(WithNestedProperty))
     {
         gen.Send("tim");
         Assert.AreEqual("tim", gen.Next<string>());
     }
 }
开发者ID:nemec,项目名称:generator,代码行数:8,代码来源:UnitTest1.cs

示例2: Amount

 public void Amount()
 {
     var f1 = new FieldNumber("Min amount", "Minimum amount", 0d, true);
     var f2 = new FieldNumber("Max amount", "Maximum amount", 100d, true);
     var f3 = new FieldCheckBox("Generate unique values", "", false);
     new InputBox(_excelapp, "Random amount generation", f1, f2, f3, _fnb).Show(delegate {
         var min = f1.Value ?? 0;
         var gap = (f2.Value ?? 0) - min;
         var random = new Random();
         string format = Utils.GetCurrencyFormat(_culture.LCID, _culture.NumberFormat.CurrencySymbol, _culture.NumberFormat.CurrencyPositivePattern);
         var gen = new Generator(f3.Value, () => Math.Round(random.NextDouble() * gap + min, 2));
         if (_singlesel)
             CellsOperator.AddDataToRange(_range, (int)_fnb.Value, format, (ref object value) => { value = gen.Next(); });
         else
             new CellsOperator(_range, true).ForEachValue(format, (ref object value) => { value = gen.Next(); });
     });
 }
开发者ID:alnemer,项目名称:excel-qa-tools,代码行数:17,代码来源:Gen.cs

示例3: GetIds

        private IList<string> GetIds(short machineId, int number)
        {
            var generator = new Generator(machineId, DateTime.Today);
            var ids = new List<string>(number);

            for (int i = 0; i < number; i++)
            {
                ids.Add(generator.Next());
            }

            return ids;
        }
开发者ID:faint32,项目名称:UniqueIdGenerator,代码行数:12,代码来源:GeneratorTests.cs

示例4: Coordinates

 public void Coordinates()
 {
     var f1 = new FieldNumber("Latitude min", "Minimum latitude", -90d, -90d, 90d, true);
     var f2 = new FieldNumber("Latitude max", "Maximum latitude", 90d, -90d, 90d, true);
     var f3 = new FieldNumber("Longitude min", "Maximum longitude", -180d, -180d, 180d, true);
     var f4 = new FieldNumber("Longitude max", "Minimum longitude", 180d, -180d, 180d, true);
     var f5 = new FieldCheckBox("Generate unique values", "", false, true);
     new InputBox(_excelapp, "Generate GPS coordinates", f1, f2, f3, f4, f5, _fnb).Show(delegate {
         var precision = 6;
         double minLat = f1.Value ?? 0;
         double gapLat = (f2.Value ?? 0) - minLat;
         double minLon = f3.Value ?? 0;
         double gapLon = (f4.Value ?? 0) - minLon;
         var unique = f5.Value;
         var random = new Random();
         string format = "@";
         var genLat = new Generator(unique, () => Math.Round(random.NextDouble() * gapLat + minLat, precision));
         var genLon = new Generator(unique, () => Math.Round(random.NextDouble() * gapLon + minLon, precision));
         if (_singlesel)
             CellsOperator.AddDataToRange(_range, (int)_fnb.Value, format, (ref object value) => { value = "'" + genLat.Next().ToString() + " " + genLon.Next().ToString(); });
         else
             new CellsOperator(_range, true).ForEachValue(format, (ref object value) => { value = "'" + genLat.Next().ToString() + " " + genLon.Next().ToString(); });
     });
 }
开发者ID:alnemer,项目名称:excel-qa-tools,代码行数:24,代码来源:Gen.cs

示例5: Time

 public void Time()
 {
     var f1 = new FieldTime("Min time", "Minimum time", new System.DateTime(1899, 12, 30), true);
     var f2 = new FieldTime("Max time", "Maximum time", new System.DateTime(1899, 12, 30).AddSeconds(86399), true);
     var f3 = new FieldCheckBox("Generate unique values", "", false, true);
     new InputBox(_excelapp, "Random time generation", f1, f2, f3, _fnb).Show(delegate {
         System.DateTime minTime = f1.Value, maxTime = f2.Value;
         var maxSeconds = (int)(maxTime - minTime).TotalSeconds + 1;
         var random = new Random();
         string format = "[$-F400]h:mm:ss AM/PM";
         var gen = new Generator(f3.Value, () => minTime.AddSeconds(random.Next(maxSeconds)));
         if (_singlesel)
             CellsOperator.AddDataToRange(_range, (int)_fnb.Value, format, (ref object value) => { value = gen.Next(); });
         else
             new CellsOperator(_range, true).ForEachValue(format, (ref object value) => { value = gen.Next(); });
     });
 }
开发者ID:alnemer,项目名称:excel-qa-tools,代码行数:17,代码来源:Gen.cs

示例6: Number

 public void Number()
 {
     var f1 = new FieldNumber("Min number", "Minimum number", 0d, true);
     var f2 = new FieldNumber("Max number", "Maximum number", 1000d, true);
     var f3 = new FieldNumber("Precision", "Precision for floating numbers", 0d, 0d, 15, true);
     var f4 = new FieldCheckBox("Generate unique values", "", false, true);
     new InputBox(_excelapp, "Random number generation", f1, f2, f3, f4, _fnb).Show(delegate {
         var min = f1.Value ?? 0;
         var gap = f2.Value ?? double.MaxValue - min;
         var precision = (int)(f3.Value ?? 0);
         var unique = f4.Value;
         var random = new Random();
         string format = null;
         var gen = new Generator(f4.Value, () => Math.Round(random.NextDouble() * gap + min, precision));
         if (_singlesel)
             CellsOperator.AddDataToRange(_range, (int)_fnb.Value, format, (ref object value) => { value = gen.Next(); });
         else
             new CellsOperator(_range, true).ForEachValue(format, (ref object value) => { value = gen.Next(); });
     });
 }
开发者ID:alnemer,项目名称:excel-qa-tools,代码行数:20,代码来源:Gen.cs

示例7: DateTime

 public void DateTime()
 {
     var f1 = new FieldDate("Min date", "Minimum date", System.DateTime.Now.Date, true);
     var f2 = new FieldDate("Max date", "Maximum date", System.DateTime.Now.AddMonths(1).Date, true);
     var f3 = new FieldTime("Min time", "Minimum time", new System.DateTime(1899, 12, 30), true);
     var f4 = new FieldTime("Max time", "Maximum time", new System.DateTime(1899, 12, 30).AddSeconds(86399), true);
     var f5 = new FieldCheckBox("Generate unique values", "", false, true);
     new InputBox(_excelapp, "Random date-time generation", f1, f2, f3, f4, f5, _fnb).Show(delegate {
         System.DateTime minDate = f1.Value, maxDate = f2.Value;
         System.DateTime minTime = f3.Value, maxTime = f4.Value;
         var maxDays = (int)(maxDate - minDate).TotalDays + 1;
         var maxSeconds = (int)(maxTime - minTime).TotalSeconds + 1;
         var random = new Random();
         string format = _culture.DateTimeFormat.ShortDatePattern + " HH:mm";
         var gen = new Generator(f5.Value, () => minDate.AddDays(random.Next(maxDays)).AddSeconds(random.Next(maxSeconds)));
         if (_singlesel)
             CellsOperator.AddDataToRange(_range, (int)_fnb.Value, format, (ref object value) => { value = gen.Next(); });
         else
             new CellsOperator(_range, true).ForEachValue(format, (ref object value) => { value = gen.Next(); });
     });
 }
开发者ID:alnemer,项目名称:excel-qa-tools,代码行数:21,代码来源:Gen.cs

示例8: Date

 public void Date()
 {
     var f1 = new FieldDate("Min date", "Minimum date", System.DateTime.Now.Date, true);
     var f2 = new FieldDate("Max date", "Maximum date", System.DateTime.Now.AddYears(1).Date, true);
     var f3 = new FieldCheckBox("Generate unique values", "", false, true);
     new InputBox(_excelapp, "Random time generation", f1, f2, f3, _fnb).Show(delegate {
         var minDate = f1.Value;
         var maxDate = f2.Value;
         int maxDays = (int)(maxDate - minDate).TotalDays + 1;
         var unique = f3.Value;
         string format = "m/d/yyyy";
         var random = new Random();
         var gen = new Generator(f3.Value, () => minDate.AddDays(random.Next(maxDays)));
         if (_singlesel)
             CellsOperator.AddDataToRange(_range, (int)_fnb.Value, format, (ref object value) => { value = gen.Next(); });
         else
             new CellsOperator(_range, true).ForEachValue(format, (ref object value) => { value = gen.Next(); });
     });
 }
开发者ID:alnemer,项目名称:excel-qa-tools,代码行数:19,代码来源:Gen.cs

示例9: Yield_WithIndexer_SetsParameter

 public void Yield_WithIndexer_SetsParameter()
 {
     using (var gen = new Generator(WithIndexer))
     {
         gen.Send("tim");
         Assert.AreEqual("tim", gen.Next<string>());
     }
 }
开发者ID:nemec,项目名称:generator,代码行数:8,代码来源:UnitTest1.cs

示例10: Continue_WithParameterProperty_SetsParameter

 public void Continue_WithParameterProperty_SetsParameter()
 {
     using (var gen = new Generator<SomeClass>(WithParameterProperty, new SomeClass()))
     {
         gen.Send("tim");
         Assert.AreEqual("tim", gen.Next<string>());
     }
 }
开发者ID:nemec,项目名称:generator,代码行数:8,代码来源:UnitTest1.cs

示例11: Yield_WithValueInFirstYield_ReturnsValue

 public void Yield_WithValueInFirstYield_ReturnsValue()
 {
     using (var gen = new Generator(WithValueInFirstYield))
     {
         Assert.AreEqual("response", gen.Next<string>());
     }
 }
开发者ID:nemec,项目名称:generator,代码行数:7,代码来源:UnitTest1.cs

示例12: Yield_WithWellDefinedTypes_SetsValue

 public void Yield_WithWellDefinedTypes_SetsValue()
 {
     using (var gen = new Generator<int, string>(WithWellDefinedTypes))
     {
         gen.Send(3);
         Assert.AreEqual("3", gen.Next());
     }
 }
开发者ID:nemec,项目名称:generator,代码行数:8,代码来源:UnitTest1.cs

示例13: Yield_WithStaticProperty_SetsValue

 public void Yield_WithStaticProperty_SetsValue()
 {
     using (var gen = new Generator(WithStaticProperty))
     {
         gen.Send("tim");
         Assert.AreEqual("tim", gen.Next<string>());
     }
 }
开发者ID:nemec,项目名称:generator,代码行数:8,代码来源:UnitTest1.cs


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