예제 #1
0
            public CaseModel Func_Update()
            {
                TestModel[] array = GetRandomDatas();
                return(new CaseModel()
                {
                    NameSign = string.Format("更改 数据总数: {0}", array.Length),
                    ExeEvent = () => {
                        iDAL.Delete(null);
                        iDAL.Insert((M[])array);

                        double runtime = RunHelp.GetRunTime(() => {
                            iDAL.Update(update_content_dal, w_dal);
                        });
                        Console.WriteLine("Update run time: {0}", runtime);

                        TestModel[] answer_array = ConvertTool.ListConvertType <TestModel, TestModel>(array, model => {
                            if (w_model(model))
                            {
                                return update_content_model(model);
                            }
                            return model;
                        }, null);

                        TestModel[] query_result = iDAL.Select(0, null, sorts);
                        return new VerifyIList <TestModel, TestModel>(CalcWayEnum.Random)
                        {
                            Answer = answer_array,
                            Source = query_result,
                            Func_isEquals = TestModelIsEqual,
                        }.Calc();
                    },
                });
            }
예제 #2
0
        /// <summary>
        /// 单个解析测试实例
        /// </summary>
        /// <param name="method">执行方法</param>
        /// <param name="name">执行名称</param>
        /// <returns>是否成功</returns>
        private static bool AnalyticCaseModelOneItem(Func <bool> method, string name)
        {
            bool   isby     = false;
            double exe_time = RunHelp.GetRunTime(() => {
                isby = method();
            });

            if (isby)
            {
                Console.WriteLine("[+] Name: [{0}] 成功 Success Time: {1}s", name, exe_time);
                return(true);
            }
            else
            {
                Console.WriteLine("[-] Name: [{0}] 失败 Error Time: {1}s", name, exe_time);
                return(false);
            }
        }
예제 #3
0
        public CaseModel Error_DateTimeType()
        {
            return(new CaseModel()
            {
                NameSign = @"时间类型",
                ExeEvent = () => {
                    DAL_MSSQLServer <TestModel> dal = new DAL_MSSQLServer <TestModel>();
                    TestModel[] array = new TestModel[999];
                    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 = new DateTime(2018, 10, 30, 14, 42, 33, i),
                            Name = name + RandomData.GetChineseString(RandomData.GetInt(3, 5)),
                            Sex = RandomData.Item(EnumInfo.GetALLItem <TestModel.SexEnum>()),
                        };
                    }

                    Console.WriteLine("dal.Delete(null): {0}s", RunHelp.GetRunTime(() => {
                        dal.Delete(null);
                    }));

                    string[] sqls = null;

                    Console.WriteLine("sqls create: {0}s", RunHelp.GetRunTime(() => {
                        sqls = ConvertTool.ListConvertType(array, (model) => dal.SQLInsert(model, false));
                    }));

                    Console.WriteLine("dal.Transaction(sqls): {0}s", RunHelp.GetRunTime(() => {
                        dal.Transaction(sqls);
                    }));

                    //dal.Insert(array);

                    DataTable dt = dal.QueryRecords(0, null, "RecordIndex asc").Tables[0];

                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        TestModel a = array[i];
                        DataRow dr = dt.Rows[i];
                        TestModel s = dal.DataRowToModel(dr);

                        if (a.DateOfBirth != s.DateOfBirth)
                        {
                            throw new Exception("错误");
                        }
                    }



                    /*
                     * TestModel[] result = dal.Select(0, null, new KeyBoolean[] {
                     *  new KeyBoolean("RecordIndex", true),
                     * });
                     * VerifyIList<TestModel, TestModel> verify = new VerifyIList<TestModel, TestModel>(CalcWayEnum.SingleCycle) {
                     *  Answer = array,
                     *  Source = result,
                     *  Func_isEquals = (a, s) => {
                     *      if (a.RecordIndex != s.RecordIndex) {
                     *          return false;
                     *      }
                     *      if (a.Age != s.Age) {
                     *          return false;
                     *      }
                     *      if (a.Name != s.Name) {
                     *          return false;
                     *      }
                     *      if (a.Sex != s.Sex) {
                     *          return false;
                     *      }
                     *
                     *      if (a.DateOfBirth != s.DateOfBirth) {
                     *          string a_dt = a.DateOfBirth.ToString(Format.DATETIME_SECOND);
                     *          string s_dt = s.DateOfBirth.ToString(Format.DATETIME_SECOND);
                     *          Console.WriteLine("时间不一致!  a:{0}  s:{1}", a, s);
                     *          throw new Exception("错误");
                     *          return false;
                     *      }
                     *      return true;
                     *  },
                     * };
                     *
                     * bool isby = verify.Calc();
                     * if (!isby) {
                     *  return false;
                     * }
                     */
                    return true;
                },
            });
        }