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 TestDonViTinh05_InsertSuccess()
        {
            frmDM_DonViTinh frm = new frmDM_DonViTinh();

            frm.Oid   = 0;
            frm.isAdd = true;
            frmChiTiet_DonViTinh frmChiTietDonViTinh = new frmChiTiet_DonViTinh(frm);

            frmChiTietDonViTinh.SetInput("Don Vi 1", "DV1", "Unit Test ky hieu", 1);
            frmChiTietDonViTinh.TestSave();
            List <DMDonViTinhInfor> list = DmDonViTinhProvider.Instance.Search(new DMDonViTinhInfor {
                KyHieu = "DV1"
            });

            Assert.AreEqual(list.Count, 1);
        }
 public void TestDonViTinh02_MaDonViTinhHasExistedOnInsert()
 {
     try
     {
         frmDM_DonViTinh frm = new frmDM_DonViTinh();
         frm.Oid   = 0;
         frm.isAdd = true;
         frmChiTiet_DonViTinh frmChiTietChucNang = new frmChiTiet_DonViTinh(frm);
         frmChiTietChucNang.SetInput("Don Vi 1", "CHI", "Unit Test ky hieu", 1);
         frmChiTietChucNang.TestSave();
         Assert.AreEqual("Khong chay dong nay", String.Empty);
     }
     catch (Exception ex)
     {
         Assert.AreEqual(ex.Message, "Mã đơn vị tính đã có trong hệ thống!");
     }
 }
 public void TestDonViTinh01_MaDonViTinhIsNotEmpty()
 {
     try
     {
         frmDM_DonViTinh frm = new frmDM_DonViTinh();
         frm.Oid   = 0;
         frm.isAdd = true;
         frmChiTiet_DonViTinh frmChiTietDonViTinh = new frmChiTiet_DonViTinh(frm);
         frmChiTietDonViTinh.SetInput("Don Vi 1", "", "Unit Test ky hieu", 1);
         frmChiTietDonViTinh.TestSave();
         Assert.AreEqual("Khong chay dong nay", String.Empty);
     }
     catch (Exception ex)
     {
         Assert.AreEqual(ex.Message, "Mã không được để trống!");
     }
 }
        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;
                }
            }
        }