public void TestPhongBan07_DeleteSuccess() { TestPhongBan05_InsertSuccess(); List <DMPhongBanInfor> list = DMPhongBanDataProvider.Instance.GetListPhongBanInfor(); DMPhongBanInfor infor = list.Find(delegate(DMPhongBanInfor match) { return(match.MaPhongBan == "PB1"); }); frmDM_PhongBan frm = new frmDM_PhongBan(); frm.isAdd = false; frm.Oid = infor.IdPhongBan; frmChiTiet_PhongBan frmChiTietPhongBan = new frmChiTiet_PhongBan(frm); frmChiTietPhongBan.TestDelete(); list = DMPhongBanDataProvider.Instance.GetListPhongBanInfor(); infor = list.Find(delegate(DMPhongBanInfor match) { return(match.MaPhongBan == "PB1"); }); Assert.AreEqual(infor, null); }
public void TestPhongBan06_DeleteFailure() { try { frmDM_PhongBan frm = new frmDM_PhongBan(); frm.Oid = 0; frm.isAdd = true; frmChiTiet_PhongBan frmChiTietPhongBan = new frmChiTiet_PhongBan(frm); frmChiTietPhongBan.TestDelete(); Assert.AreEqual("Khong chay dong nay", String.Empty); } catch (Exception ex) { Assert.AreEqual(ex.Message, "Bạn không thể xóa khi đang thêm mới!"); } }
public void TestPhongBan03_MaPhongBanHasExistedOnUpdate() { try { TestPhongBan05_InsertSuccess(); List <DMPhongBanInfor> list = DMPhongBanDataProvider.Instance.GetListPhongBanInfor(); DMPhongBanInfor infor = list.Find(delegate(DMPhongBanInfor match) { return(match.MaPhongBan == "PB1"); }); frmDM_PhongBan frm = new frmDM_PhongBan(); frm.isAdd = false; frm.Oid = infor.IdPhongBan; frmChiTiet_PhongBan frmChiTietPhongBan = new frmChiTiet_PhongBan(frm); frmChiTietPhongBan.SetInput("Phong Ban 1", "BGD", "Unit test ma phong ban", 1); frmChiTietPhongBan.TestSave(); list = DMPhongBanDataProvider.Instance.GetListPhongBanInfor(); List <DMPhongBanInfor> listDuplicate = list.FindAll(delegate(DMPhongBanInfor match) { return(match.MaPhongBan == "BGD"); }); frmChiTietPhongBan.TestDelete(); Assert.AreEqual(1, listDuplicate.Count); } catch (Exception ex) { if (ex.GetType() != typeof(AssertFailedException)) { Assert.AreEqual(ex.Message, "Mã đã tồn tại trong hệ thống!"); } else { throw; } } }