public void TestDuAn01_MaDuAnIsNotEmpty()
 {
     try
     {
         frmDM_DuAn frm = new frmDM_DuAn();
         frm.Oid   = 0;
         frm.isAdd = true;
         frmChiTiet_DuAn frmChiTietDuAn = new frmChiTiet_DuAn(frm);
         frmChiTietDuAn.SetInput("Test1", "", "Unit test ma du an", 1);
         frmChiTietDuAn.TestSave();
         Assert.AreEqual("Khong chay dong nay", String.Empty);
     }
     catch (Exception ex)
     {
         Assert.AreEqual(ex.Message, "Mã không được để trống!");
     }
 }
 public void TestDuAn02_MaDuAnHasExistedOnInsert()
 {
     try
     {
         frmDM_DuAn frm = new frmDM_DuAn();
         frm.Oid   = 0;
         frm.isAdd = true;
         frmChiTiet_DuAn frmChiTietDuAn = new frmChiTiet_DuAn(frm);
         frmChiTietDuAn.SetInput("Test1", "03", "Unit test ma du an", 1);
         frmChiTietDuAn.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 TestDuAn05_InsertSuccess()
        {
            frmDM_DuAn frm = new frmDM_DuAn();

            frm.Oid   = 0;
            frm.isAdd = true;
            frmChiTiet_DuAn frmChiTietDuAn = new frmChiTiet_DuAn(frm);

            frmChiTietDuAn.SetInput("Test1", "13", "Unit test ma du an", 1);
            frmChiTietDuAn.TestSave();
            //List<DMDuAnInfor> list = DMDuAnDataProvider.Instance.Search(new DMDuAnInfor { MaDuAn = "13" });
            //Assert.AreEqual(list.Count, 1);
            Assert.AreEqual(true, DMDuAnDataProvider.Instance.IsExisted(new DMDuAnInfor()
            {
                MaDuAn = "13"
            }));
        }
        public void TestDuAn03_MaDuAnHasExistedOnUpdate()
        {
            try
            {
                TestDuAn05_InsertSuccess();
                List <DMDuAnInfor> list  = DMDuAnDataProvider.Instance.GetListDuAnInfo();
                DMDuAnInfor        infor = list.Find(delegate(DMDuAnInfor match)
                {
                    return(match.MaDuAn == "13");
                });

                frmDM_DuAn frm = new frmDM_DuAn();
                frm.isAdd = false;
                frm.Oid   = infor.IdDuAn;
                frmChiTiet_DuAn frmChiTietDuAn = new frmChiTiet_DuAn(frm);
                frmChiTietDuAn.SetInput("Test1", "03", "Unit test ma du an", 1);
                frmChiTietDuAn.TestSave();
                list = DMDuAnDataProvider.Instance.GetListDuAnInfo();
                List <DMDuAnInfor> listDuplicate = list.FindAll(delegate(DMDuAnInfor match)
                {
                    return(match.MaDuAn == "03");
                });
                frmChiTietDuAn.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;
                }
            }
        }