public void TestPhongBan05_InsertSuccess() { frmDM_PhongBan frm = new frmDM_PhongBan(); frm.Oid = 0; frm.isAdd = true; frmChiTiet_PhongBan frmChiTietPhongBan = new frmChiTiet_PhongBan(frm); frmChiTietPhongBan.SetInput("Phong Ban 1", "PB1", "Unit test ma phong ban", 1); frmChiTietPhongBan.TestSave(); List <DMPhongBanInfor> list = DMPhongBanDataProvider.Instance.Search(new DMPhongBanInfor { MaPhongBan = "PB1" }); Assert.AreEqual(list.Count, 1); }
public void TestPhongBan02_MaPhongBanHasExistedOnInsert() { try { frmDM_PhongBan frm = new frmDM_PhongBan(); frm.Oid = 0; frm.isAdd = true; frmChiTiet_PhongBan frmChiTietPhongBan = new frmChiTiet_PhongBan(frm); frmChiTietPhongBan.SetInput("Phong Ban 1", "BGD", "Unit test ma phong ban", 1); frmChiTietPhongBan.TestSave(); Assert.AreEqual("Khong chay dong nay", String.Empty); } catch (Exception ex) { Assert.AreEqual(ex.Message, "Mã đã tồn tại trong hệ thống!"); } }
public void TestPhongBan01_MaPhongBanIsNotEmpty() { try { frmDM_PhongBan frm = new frmDM_PhongBan(); frm.Oid = 0; frm.isAdd = true; frmChiTiet_PhongBan frmChiTietPhongBan = new frmChiTiet_PhongBan(frm); frmChiTietPhongBan.SetInput("Phong Ban 1", "", "Unit test ma phong ban", 1); frmChiTietPhongBan.TestSave(); Assert.AreEqual("Khong chay dong nay", String.Empty); } catch (Exception ex) { Assert.AreEqual(ex.Message, "Mã không được để trống!"); } }
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; } } }