public void TestDonViTinh07_DeleteSuccess()
        {
            TestDonViTinh05_InsertSuccess();
            List <DMDonViTinhInfor> list  = DmDonViTinhProvider.Instance.GetListDonViTinhInfo();
            DMDonViTinhInfor        infor = list.Find(delegate(DMDonViTinhInfor match)
            {
                return(match.KyHieu == "DV1");
            });

            frmDM_DonViTinh frm = new frmDM_DonViTinh();

            frm.isAdd = false;
            frm.Oid   = infor.IdDonViTinh;

            frmChiTiet_DonViTinh frmChiTietDonViTinh = new frmChiTiet_DonViTinh(frm);

            frmChiTietDonViTinh.TestDelete();
            list  = DmDonViTinhProvider.Instance.GetListDonViTinhInfo();
            infor = list.Find(delegate(DMDonViTinhInfor match)
            {
                return(match.KyHieu == "DV1");
            });

            Assert.AreEqual(infor, null);
        }
 public void TestDonViTinh06_DeleteFailure()
 {
     try
     {
         frmDM_DonViTinh frm = new frmDM_DonViTinh();
         frm.Oid   = 0;
         frm.isAdd = true;
         frmChiTiet_DonViTinh frmChiTietDonViTinh = new frmChiTiet_DonViTinh(frm);
         frmChiTietDonViTinh.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 TestDonViTinh03_MaDonViTinhHasExistedOnUpdate()
        {
            try
            {
                TestDonViTinh05_InsertSuccess();
                List <DMDonViTinhInfor> list  = DmDonViTinhProvider.Instance.GetListDonViTinhInfo();
                DMDonViTinhInfor        infor = list.Find(delegate(DMDonViTinhInfor match)
                {
                    return(match.KyHieu == "DV1");
                });

                frmDM_DonViTinh frm = new frmDM_DonViTinh();
                frm.isAdd = false;
                frm.Oid   = infor.IdDonViTinh;
                frmChiTiet_DonViTinh frmChiTietDonViTinh = new frmChiTiet_DonViTinh(frm);
                frmChiTietDonViTinh.SetInput("Don Vi 1", "CHI", "Unit Test ky hieu", 1);
                frmChiTietDonViTinh.TestSave();
                list = DmDonViTinhProvider.Instance.GetListDonViTinhInfo();
                List <DMDonViTinhInfor> listDuplicate = list.FindAll(delegate(DMDonViTinhInfor match)
                {
                    return(match.KyHieu == "CHI");
                });
                frmChiTietDonViTinh.TestDelete();
                Assert.AreEqual(1, listDuplicate.Count);
            }
            catch (Exception ex)
            {
                if (ex.GetType() != typeof(AssertFailedException))
                {
                    Assert.AreEqual(ex.Message, "Mã đơn vị tính đã có trong hệ thống!");
                }
                else
                {
                    throw;
                }
            }
        }