public void RemoveClassTest_NotFind_ThrowException()
        {
            _dbMock.Setup(db => db.ClassTests.Find()).Returns(value: null);
            var ext = Assert.Throws <Exception>(() => _classTestRepository.RemoveClassTest(111));

            Assert.Contains("查询不到ID为111的考试班级", ext.Message);
        }
예제 #2
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     try
     {
         if (_selectID > 0)
         {
             if (MessageBox.Show("你确定要删除吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
             {
                 if (_classTestRepository.RemoveClassTest(_selectID))
                 {
                     ClearData();
                     dgvData.DataSource = _classTestRepository.GetClassTests();
                 }
                 else
                 {
                     MessageBox.Show("删除失败!");
                 }
             }
         }
         else
         {
             MessageBox.Show("请双击选择!");
         }
     }
     catch (Exception exc)
     {
         MessageBox.Show(exc.Message);
     }
 }