Beispiel #1
0
        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);
        }
Beispiel #2
0
 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!");
     }
 }
Beispiel #3
0
        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);
        }
Beispiel #4
0
 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!");
     }
 }
Beispiel #5
0
 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!");
     }
 }
Beispiel #6
0
        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;
                }
            }
        }