Esempio n. 1
0
        public void TestUpdateInterviewList()
        {
            Tools.UserCaseHandle userCaseHandle = new Tools.UserCaseHandle(@"C:\Users\Mr.Feng\Desktop\软工\测试用例\Update_InterviewList.xls");
            IEnumerable          InterviewList  = userCaseHandle.GetUserCases();
            List <string>        errorList      = new List <string>();

            foreach (var i in InterviewList)
            {
                Assert.AreEqual(false, interviewBll.UpdateInterviewList((InterviewList)i, ref errorList));
            }
            int maxId = -1;

            foreach (AcceptanceList i in interviewBll.GetAllInterviewListArray())
            {
                if (i.Id > maxId)
                {
                    maxId = i.Id;
                }
            }
            if (maxId != -1)
            {
                InterviewList list = new InterviewList()
                {
                    Id                = 1,
                    Author            = "测试师",
                    ISBN              = "1234567890",
                    PublishingHouseId = 1,
                    Price             = 50,
                    CurrencyType      = "美元$",
                    SubscriptionNum   = 1,
                    DocumentType      = "期刊",
                    OrderStatus       = "采访",
                    BookName          = "单元测试"
                };
                Assert.AreEqual(true, interviewBll.UpdateInterviewList(list, ref errorList));
            }
        }
 /// <summary>
 /// 保存记录
 /// </summary>
 private void SaveLog_Click(object sender, EventArgs e)
 {
     try
     {
         List <string> errorList = new List <string>(); //创建一个错误列表
         //获取根据当前页面内容生成的清单(若有错误会被添加到错误列表中)
         string interviewId = InterviewIdTextBox.Text;  //获取清单号
         int    id;
         if (!int.TryParse(interviewId, out id))        //将其转换为数字失败
         {
             MessageBox.Show("清单号错误");
             return;
         }
         InterviewList list = GetInterviewList(ref errorList);
         list.Id = id;//设置清单号
         //判断是否添加清单成功
         if (interviewBll.UpdateInterviewList(list, ref errorList))
         {
             MessageBox.Show("修改成功");
         }
         else
         {
             MessageBox.Show("修改失败");
             foreach (var i in errorList)
             {
                 MessageBox.Show(i);//逐条显示错误信息
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     DataBind();                 //数据绑定
     ChangeControlEnableState(); //改变菜单按钮启用状态
 }