Exemplo n.º 1
0
        public CaseModel Func_GetValue_SetValue()
        {
            return(new CaseModel()
            {
                NameSign = @"获取/设置值",
                ExeEvent = () => {
                    GS answer = new GS()
                    {
                        Age = RandomData.GetInt(),
                        DateOfBirth = RandomData.GetDateTime(),
                        Name = RandomData.GetChineseString(),
                        Price = RandomData.GetDouble(),
                        Sex = RandomData.Item(EnumInfo.GetALLItem <GS.SexEnum>()),
                    };

                    GS result = new GS();

                    ShineUponParser parser = new ShineUponParser(typeof(GS));
                    foreach (ShineUponInfo info in parser.GetDictionary().Values)
                    {
                        KeyString ks = parser.GetValue_KeyString(info, answer);
                        parser.SetValue_Object(info, result, ks.Value);
                    }

                    return true;
                },
            });
        }
 private CaseModel ExeEvent_Random_DateTime_CreateLibray()
 {
     return(new CaseModel()
     {
         NameSign = @"随机时间范围",
         ExeEvent = () => {
             const string timeFormat = @"MM-dd HH:mm";
             const int addDayNum = 2;
             const int year = 2017;
             DateTime min_time = new DateTime(year, 01, 01, 08, 08, 08);
             DateTime max_time = min_time.AddHours(addDayNum);
             List <string> list = new List <string>();
             Print.WriteLine("Init: {0}-{1}", min_time.ToString(timeFormat), max_time.ToString(timeFormat));
             for (int i = 0; i < 20000; i++)
             {
                 DateTime time = RandomData.GetDateTime(min_time, max_time);
                 if (time.Year > year)
                 {
                     break;
                 }
                 list.Add(time.ToString(timeFormat));
                 min_time = time;
                 max_time = time.AddHours(addDayNum);
             }
             SystemLog.Write("NULL", ConvertTool.IListToString(list, "#"));
             Print.WriteLine(list.Count);
         },
     });
 }
Exemplo n.º 3
0
        public void TestMethod()
        {
            DateTime min_time = new DateTime(2018, 3, 1, 0, 0, 0);
            DateTime max_time = new DateTime(2018, 3, 31, 23, 59, 59);

            int[] telsigns = new int[] { 58, 68, 8, 49, 66, 51, 55, 56, 57, 6, 60, 19, 63, 52, 14, 53, 40, 21, 64, 22, 67, 59, 16, 45, 61, 62, 35, 38, 54, 44, 15, 41, 36, 39, 17, 65, 26, 10, 33, 27, 50, 1, 25, 11, 13, 3, 28, 2, 29, 34, 30, 7, 5, 12, 4, 23, 32, 18, 47, 24, 42, 43, 46, 31, 20, 37, 69, 70, 73, 72, 71, 77, 79, 80, 78, 85, 86, 87, 88, 81, 82, 83, 84, 89, 90, 91, 92, 74, 75, 76, 48, 0 };

            int[] managerIDs = new int[] { 1, 10, 15, 16, 17, 18, 20, 22, 26, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99 };

            char[] chars = Get_wechatno_chararray();

            BLLspread_wxUserInfo BLLwxuser = new BLLspread_wxUserInfo();

            for (int i = 0; i < 10000; i++)
            {
                string user_wechatno = RandomData.GetString(chars, RandomData.R.Next(1, 21));

                bool isSuccess = BLLwxuser.Insert(new Modelspread_wxUserInfo()
                {
                    ManagerID       = RandomData.Item(managerIDs),
                    Remark          = string.Empty,
                    TelSign         = RandomData.Item(telsigns),
                    TimeAdd         = RandomData.GetDateTime(min_time, max_time),
                    WeChatNo        = user_wechatno,
                    VoucherPictures = user_wechatno,
                });
                Console.WriteLine("forNo:{0}  recordIDno: {1}", i, isSuccess);
            }
        }
        private CaseModel ExeEvent_Random_DateTime_Region(bool isAsc)
        {
            const string timeFormat = LFKeys.TABLE_DATETIME_FORMAT_MILLISECOND;
            DateTime     min_time   = new DateTime(2018, 04, 19, 06, 40, 0);
            DateTime     max_time   = new DateTime(2020, 01, 5, 18, 10, 0);

            return(new CaseModel()
            {
                NameSign = @"随机时间范围",
                ExeEvent = () => {
                    Print.WriteLine("Init: {0}-{1}", min_time.ToString(timeFormat), max_time.ToString(timeFormat));
                    for (int i = 0; i < 20; i++)
                    {
                        DateTime time = RandomData.GetDateTime(min_time, max_time);
                        string symbol = string.Empty;
                        if (isAsc)
                        {
                            min_time = time;
                            symbol = @"↑";
                        }
                        else
                        {
                            max_time = time;
                            symbol = @"↓";
                        }
                        Print.WriteLine(time.ToString(timeFormat) + symbol);
                        //break;
                    }
                },
            });
        }
Exemplo n.º 5
0
 public static LogEvent Generate(string id = null, string companyId = null, string message = null, DateTime?createdUtc = null)
 {
     return(new LogEvent {
         Id = id,
         Message = message ?? RandomData.GetAlphaString(),
         CompanyId = companyId ?? ObjectId.GenerateNewId().ToString(),
         CreatedUtc = createdUtc ?? RandomData.GetDateTime(SystemClock.UtcNow.StartOfMonth(), SystemClock.UtcNow)
     });
 }
 private CaseModel ExeEvent_Random_DateTime()
 {
     return(new CaseModel()
     {
         NameSign = @"随机时间",
         ExeEvent = () => {
             for (int i = 0; i < 20; i++)
             {
                 Print.WriteLine(RandomData.GetDateTime().ToString(LFKeys.TABLE_DATETIME_FORMAT_MILLISECOND));
             }
         },
     });
 }
Exemplo n.º 7
0
        public void InsertData()
        {
            bool result = bllUser.Insert(new ModelUser()
            {
                Email       = RandomData.GetString(RandomData.GetInt(5, 10)),
                TelePhone   = RandomData.GetString(CommonData.ASCII_Number(), 12),
                MobilePhone = RandomData.GetString(CommonData.ASCII_Number(), 11),
                NickName    = RandomData.GetString(CommonData.ASCII_UpperEnglish(), RandomData.GetInt(5, 16)),
                Password    = RandomData.GetString(30),
                RealName    = RandomData.GetChineseString(RandomData.GetInt(2, 4)),
                Remark      = RandomData.GetString(RandomData.GetInt(10, 81)),
                Sex         = RandomData.Item(ConvertTool.EnumForeachArray <ModelUser.SexEnum>()),
                TimeAdd     = RandomData.GetDateTime(),
            });

            Print.WriteLine(result);
        }
Exemplo n.º 8
0
        public static Employee GenerateRandom(string id = null, string name = null, int?age = null, int?yearsEmployed = null, string companyName = null, string companyId = null, string location = null, DateTime?lastReview = null, DateTimeOffset?nextReview = null, DateTime?createdUtc = null, DateTime?updatedUtc = null)
        {
            var employee = new Employee {
                Id            = id,
                Name          = name ?? RandomData.GetAlphaString(),
                Age           = age ?? RandomData.GetInt(18, 100),
                YearsEmployed = yearsEmployed ?? RandomData.GetInt(0, 40),
                CompanyName   = companyName ?? RandomData.GetAlphaString(),
                CompanyId     = companyId ?? ObjectId.GenerateNewId().ToString(),
                LastReview    = lastReview ?? RandomData.GetDateTime(DateTime.Now.SubtractDays(365), DateTime.Now),
                CreatedUtc    = createdUtc ?? RandomData.GetDateTime(DateTime.Now.SubtractDays(365), DateTime.Now),
                Location      = location ?? RandomData.GetCoordinate()
            };

            employee.NextReview = nextReview ?? RandomData.GetDateTimeOffset(employee.NextReview, DateTime.Now);
            employee.UpdatedUtc = updatedUtc ?? RandomData.GetDateTime(employee.CreatedUtc, DateTime.Now);

            return(employee);
        }
Exemplo n.º 9
0
        public void InsertData()
        {
            int  id     = 0;
            bool result = bllUser.Insert(new ModelUser()
            {
                Email       = RandomData.GetString(10),
                TelePhone   = RandomData.GetString(CommonData.ASCII_Number(), 12),
                MobilePhone = RandomData.GetString(CommonData.ASCII_Number(), 11),
                NickName    = RandomData.GetString(CommonData.ASCII_UpperEnglish(), 30),
                Password    = RandomData.GetString(100),
                RealName    = RandomData.GetString(CommonData.ASCII_UpperEnglish(), 10),
                Remark      = RandomData.GetString(200),
                Sex         = RandomData.Item(ConvertTool.EnumForeachArray <ModelUser.SexEnum>()),
                TimeAdd     = RandomData.GetDateTime(),
            }, out id);

            Print.WriteLine(result);
            Print.WriteLine(id);
        }
Exemplo n.º 10
0
 public TestModel[] GetRandomDatas(int rewrite_sum = 0)
 {
     if (rewrite_sum <= 0)
     {
         rewrite_sum = RandomData.GetInt(30, 81);
     }
     TestModel[] array = new TestModel[rewrite_sum];
     for (int i = 0; i < array.Length; i++)
     {
         string name = string.Format("第{0}条 - ", i);
         array[i] = new TestModel()
         {
             RecordIndex = i,
             Age         = RandomData.GetInt(7828, 546822),
             DateOfBirth = RandomData.GetDateTime(SqlDateTime.MinValue.Value, SqlDateTime.MaxValue.Value),
             Name        = name + RandomData.GetChineseString(RandomData.GetInt(3, 5)),
             Sex         = RandomData.Item(EnumInfo.GetALLItem <TestModel.SexEnum>()),
         };
     }
     return(array);
 }
        public CaseModel Func_Insert()
        {
            return(new CaseModel()
            {
                NameSign = @"插入数据",
                ExeEvent = () => {
                    List <TestModel> model_list = new List <TestModel>();
                    int record_count = RandomData.GetInt(10, 51);
                    record_count = 15;
                    for (int i = 0; i < record_count; i++)
                    {
                        model_list.Add(new TestModel()
                        {
                            IID = i,
                            Name = RandomData.GetChineseString(RandomData.GetInt(3, 5)),
                            Sex = RandomData.Item(EnumInfo.GetALLItem <TestModel.SexEnum>()),
                            TimeRelease = RandomData.GetDateTime(SqlDateTime.MinValue.Value, SqlDateTime.MaxValue.Value),
                        });
                    }

                    Func <TestModel, string> get_formatprint = (model) => {
                        return JSON.Serializer(model);
                    };

                    List <string> lines = new List <string>();
                    foreach (TestModel model in model_list)
                    {
                        string text = get_formatprint(model);
                        lines.Add(text);
                    }
                    string abs_file_path = Get_AbsFilePath();
                    File.Delete(abs_file_path);
                    File.Create(abs_file_path).Close();
                    WriterLine(abs_file_path, lines.ToArray());

                    Func_Select().ExeEvent();
                    return true;
                },
            });
        }
Exemplo n.º 12
0
 public void PrepareSut()
 {
     _utcTime          = RandomData.GetDateTime();
     SystemTime.UtcNow = () => _utcTime;
     _sut = new WeightEntry();
 }
Exemplo n.º 13
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        private MarCard CreateMarCard()
        {
            MarCard entity = new MarCard()
            {
                CustId                 = RandomData.GetInt(),                           //商户Id
                CardId                 = Guid.NewGuid().ToString("N"),                  //卡券ID代表一类卡券
                LogoUrl                = RandomData.GetString(maxLength: 200),          //卡券的商户logo,建议像素为300*300。
                CardType               = RandomData.GetString(maxLength: 20),           //卡券类型(CASH:代金券,DISCOUNT:折扣券,GIFT:兑换券,GROUPON:团购券)
                CodeType               = RandomData.GetString(maxLength: 20),           //核销码类型(CODE_TYPE_TEXT文 本 ; "CODE_TYPE_BARCODE"一维码 "CODE_TYPE_QRCODE"二维码 "CODE_TYPE_ONLY_QRCODE",二维码无code显示; "CODE_TYPE_ONLY_BARCODE",一维码无code显示;CODE_TYPE_NONE, 不显示code和条形码类型)
                Title                  = RandomData.GetString(maxLength: 30),           //卡券名,字数上限为9个汉字。(建议涵盖卡券属性、服务及金额)。
                SubTitle               = RandomData.GetString(maxLength: 30),           //显示在入口下方的提示语 ,仅在卡券状态正常(可以核销)时显示。
                Color                  = RandomData.GetString(maxLength: 16),           //券颜色。按色彩规范标注填写Color010-Color100。
                Notice                 = RandomData.GetString(maxLength: 50),           //卡券使用提醒,字数上限为16个汉字。
                Description            = RandomData.GetString(maxLength: 1024),         //卡券使用说明,字数上限为1024个汉字。
                Quantity               = RandomData.GetInt(),                           //卡券库存的数量,上限为100000000。
                DateType               = RandomData.GetString(maxLength: 20),           //有效期类型(DATE_TYPE_FIX _TIME_RANGE 表示固定日期区间,DATE_TYPE_FIX_TERM表示 X天后生效,X天内有效)
                DateBeginTime          = RandomData.GetDateTime(),                      //DateType为DATE_TYPE_FIX_TIME_RANGE时专用,表示起用时间
                DateEndTime            = RandomData.GetDateTime(),                      //DateType为DATE_TYPE_FIX_TIME_RANGE时专用,表示结束时间 , 建议设置为截止日期的23:59:59过期
                DateFixedTerm          = RandomData.GetInt(),                           //DateType为DATE_TYPE_FIX_TERM时专用,表示自领取后多少天内有效,不支持填写0。
                DateFixedBeginTerm     = RandomData.GetInt(),                           //DateType为DATE_TYPE_FIX_TERM时专用,表示自领取后多少天开始生效,领取后当天生效填写0。(单位为天)
                BindOpenid             = RandomData.GetBool(),                          //是否指定用户领取,填写true或false 。默认为false。通常指定特殊用户群体 投放卡券或防止刷券时选择指定用户领取。
                ServicePhone           = RandomData.GetString(maxLength: 20),           //客服电话。
                GetLimit               = RandomData.GetInt(),                           //每人可领券的数量限制,不填写默认为50。
                UseLimit               = RandomData.GetInt(),                           //每人可核销的数量限制,不填写默认为50。
                CanShare               = RandomData.GetBool(),                          //卡券领取页面是否可分享。
                CanGiveFriend          = RandomData.GetBool(),                          //卡券是否可转赠
                AcceptCategory         = RandomData.GetString(),                        //指定可用的商品类目
                RejectCategory         = RandomData.GetString(),                        //指定不可用的商品类目,仅用于代金券类型 ,填入后将在券面拼写不适用于xxxx
                AcceptProduct          = RandomData.GetString(),                        //指定可用的商品
                RejecProduct           = RandomData.GetString(),                        //指定不可用的商品
                ReduceCost             = RandomData.GetDecimal(0, (int)Math.Pow(2, 6)), //代金券专用,表示减免金额
                LeastCost              = RandomData.GetDecimal(0, (int)Math.Pow(2, 6)), //满减门槛字段,可用于兑换券和代金券 ,填入后将在全面拼写消费满xx元可用。
                Discount               = RandomData.GetDecimal(0, (int)Math.Pow(2, 6)), //折扣券专用,表示打折额度(百分比)
                CanUseWithOtheDiscount = RandomData.GetBool(),                          //不可以与其他类型共享门槛 ,填写false时系统将在使用须知里 拼写“不可与其他优惠共享”, 填写true时系统将在使用须知里 拼写“可与其他优惠共享”, 默认为true
                BusinessService        = RandomData.GetString(maxLength: 200),          //Arry类型 商家服务类型: BIZ_SERVICE_DELIVER 外卖服务; BIZ_SERVICE_FREE_PARK 停车位; BIZ_SERVICE_WITH_PET 可带宠物; BIZ_SERVICE_FREE_WIFI 免费wifi, 可多选

                /*
                 * {
                 *  type    否   string(24 )	限制类型枚举值:支持填入 MONDAY 周一 TUESDAY 周二 WEDNESDAY 周三 THURSDAY 周四 FRIDAY 周五 SATURDAY 周六 SUNDAY 周日 此处只控制显示, 不控制实际使用逻辑,不填默认不显示
                 *  begin_hour   否   int 当前type类型下的起始时间(小时) ,如当前结构体内填写了MONDAY, 此处填写了10,则此处表示周一 10:00可用
                 *  begin_minute 否   int 当前type类型下的起始时间(分钟) ,如当前结构体内填写了MONDAY, begin_hour填写10,此处填写了59, 则此处表示周一 10:59可用
                 *  end_hour 否   int 当前type类型下的结束时间(小时) ,如当前结构体内填写了MONDAY, 此处填写了20, 则此处表示周一 10:00 - 20:00可用
                 *      end_minute   否   int 当前type类型下的结束时间(分钟) ,如当前结构体内填写了MONDAY, begin_hour填写10,此处填写了59, 则此处表示周一 10:59 - 00:59可用
                 * }
                 */
                TimeLimit               = @"[{""type"": ""MONDAY"", ""begin_hour"": 0,""end_hour"": 10,""begin_minute"": 10,""end_minute"": 59 }]", //JSON结构	使用时段限制,包含以下字段
                AbstractIntro           = RandomData.GetString(maxLength: 24),                                                                      //封面摘要简介
                AbstractIconUrlList     = RandomData.GetString(maxLength: 200),                                                                     //封面图片列表,仅支持填入一 个封面图片链接, 上传图片接口 上传获取图片获得链接,填写 非CDN链接会报错,并在此填入。 建议图片尺寸像素850*350
                ConsumeType             = default(byte?),                                                                                           //核销方式(1:自助买单,2:自助核销,3:用扫码核销--二维码_条形码_仅卡券号)
                ConsumeNeedVerifyCode   = RandomData.GetBool(),                                                                                     //自助核销是否启用验证码(消费者持券到店,须输入验证码才能核销卡券)
                ConsumeVerifyCode       = RandomData.GetString(maxLength: 3),                                                                       //自助核销验证码(消费者持券到店,须输入验证码才能核销卡券)
                ConsumeNeedRemarkAmount = RandomData.GetBool(),                                                                                     //自助核销是否启用备注交易金额(商户选择备注交易金额后,用户持券到店,须备注本次交易的金额才能成功销券,用于对账。)
                BranchNo                       = RandomData.GetString(),                                                                            //适应的门店编号如:1234,5678
                Status                         = default(byte),                                                                                     //卡券状态(0:待审核,1:审核中,2:审核通过(待投放),3:审核未通过,4:已投放,5:下架)
                SendNum                        = RandomData.GetInt(),                                                                               //投放数量
                UseNum                         = RandomData.GetInt(),                                                                               //核销数量
                QuantityThreshold              = RandomData.GetInt(),                                                                               //库存阈值(当库存少于X提醒)
                QuantityThresholdNotificCount  = RandomData.GetInt(),                                                                               //库存阈值提醒次数
                QuantityThresholdNotificStatus = default(byte),                                                                                     //库存阈值提醒状态(0:禁用,1:启用)
                CreateTime                     = DateTime.Now,                                                                                      //创建时间
                CreateUser                     = RandomData.GetInt(),                                                                               //创建用户
                UpdateTime                     = RandomData.GetDateTime(),                                                                          //修改时间
                UpdateUser                     = RandomData.GetInt(),                                                                               //修改用户
                DeleteFlag                     = false,                                                                                             //删除标志 1删除
                DeleteUser                     = RandomData.GetInt(),                                                                               //删除用户
                DeleteTime                     = RandomData.GetDateTime(),                                                                          //删除时间
            };

            return(entity);
        }
Exemplo n.º 14
0
    public void PopulateEvent(Event ev, bool setUserIdentity = true)
    {
        if (MinDate.HasValue || MaxDate.HasValue)
        {
            ev.Date = RandomData.GetDateTime(MinDate ?? DateTime.MinValue, MaxDate ?? DateTime.MaxValue);
        }

        ev.Type = new[] { Event.KnownTypes.Error, Event.KnownTypes.FeatureUsage, Event.KnownTypes.Log, Event.KnownTypes.NotFound }.Random();
        if (ev.Type == Event.KnownTypes.FeatureUsage)
        {
            ev.Source = FeatureNames.Random();
        }
        else if (ev.Type == Event.KnownTypes.NotFound)
        {
            ev.Source = PageNames.Random();
        }
        else if (ev.Type == Event.KnownTypes.Log)
        {
            ev.Source  = LogSources.Random();
            ev.Message = RandomData.GetString();

            string level = LogLevels.Random();
            if (!String.IsNullOrEmpty(level))
            {
                ev.Data[Event.KnownDataKeys.Level] = level;
            }
        }

        if (RandomData.GetBool(80))
        {
            ev.Geo = RandomData.GetCoordinate();
        }

        if (RandomData.GetBool(20))
        {
            ev.Value = RandomData.GetInt(0, 10000);
        }

        if (setUserIdentity)
        {
            ev.SetUserIdentity(Identities.Random());
        }

        ev.SetVersion(RandomData.GetVersion("2.0", "4.0"));

        ev.AddRequestInfo(new RequestInfo {
            //ClientIpAddress = ClientIpAddresses.Random(),
            Path = PageNames.Random()
        });

        ev.Data.Add(Event.KnownDataKeys.EnvironmentInfo, new EnvironmentInfo {
            IpAddress   = MachineIpAddresses.Random() + ", " + MachineIpAddresses.Random(),
            MachineName = MachineNames.Random()
        });

        for (int i = 0; i < RandomData.GetInt(1, 3); i++)
        {
            string key = RandomData.GetWord();
            while (ev.Data.ContainsKey(key) || key == Event.KnownDataKeys.Error)
            {
                key = RandomData.GetWord();
            }

            ev.Data.Add(key, RandomData.GetString());
        }

        int tagCount = RandomData.GetInt(1, 3);

        for (int i = 0; i < tagCount; i++)
        {
            string tag = EventTags.Random();
            if (!ev.Tags.Contains(tag))
            {
                ev.Tags.Add(tag);
            }
        }

        if (ev.Type == Event.KnownTypes.Error)
        {
            if (RandomData.GetBool())
            {
                // limit error variation so that stacking will occur
                if (_randomErrors == null)
                {
                    _randomErrors = new List <Error>(Enumerable.Range(1, 25).Select(i => GenerateError()));
                }

                ev.Data[Event.KnownDataKeys.Error] = _randomErrors.Random();
            }
            else
            {
                // limit error variation so that stacking will occur
                if (_randomSimpleErrors == null)
                {
                    _randomSimpleErrors = new List <SimpleError>(Enumerable.Range(1, 25).Select(i => GenerateSimpleError()));
                }

                ev.Data[Event.KnownDataKeys.SimpleError] = _randomSimpleErrors.Random();
            }
        }
    }