public void DsBanYeuCau_TimTheoDungSucChua()
        {
            Ban b0 = new Ban(0, 0);
            Ban b1 = new Ban(111, 10, true);
            Ban b2 = new Ban(112, 15, false);
            Ban b3 = new Ban(113, 10, true);
            Ban b4 = new Ban(114, 6, false);

            DSBan dsB = new DSBan();

            dsB.ThemBan(b0);
            dsB.ThemBan(b1);
            dsB.ThemBan(b2);
            dsB.ThemBan(b3);
            dsB.ThemBan(b4);

            DSBan dsA      = dsB.DsBanYeuCau("10");
            bool  excepted = true;
            bool  actual   = false;

            foreach (Ban b in dsA.DsBan)
            {
                if (b.SucChua != 10)
                {
                    actual = false;
                    break;
                }
                actual = true;
            }

            Assert.AreEqual(excepted, actual);
        }
        public void DsBanDat_LayDungDSBanDat()
        {
            Ban b0 = new Ban(0, 0);
            Ban b1 = new Ban(111, 10, true);
            Ban b2 = new Ban(112, 15, false);
            Ban b3 = new Ban(113, 16, true);
            Ban b4 = new Ban(114, 6, false);

            DSBan dsB = new DSBan();

            dsB.ThemBan(b0);
            dsB.ThemBan(b1);
            dsB.ThemBan(b2);
            dsB.ThemBan(b3);
            dsB.ThemBan(b4);

            bool excepted = true;
            bool actual   = true;

            foreach (Ban b in dsB.DsBanDat().DsBan)
            {
                if (b.TinhTrang == true)
                {
                    actual = false;
                    break;
                }
            }

            Assert.AreEqual(excepted, actual);
        }
        public void TimBan_NhapMaBanAm()
        {
            Ban b1 = new Ban(111, 15);
            Ban b2 = new Ban(112, 15);
            Ban b3 = new Ban(113, 15);

            DSBan dsB = new DSBan();

            dsB.ThemBan(b1);
            dsB.ThemBan(b2);
            dsB.ThemBan(b3);

            Ban excepted = null;
            Ban actual   = dsB.TimBan(-113);

            Assert.AreEqual(excepted, actual);
        }
        public void TimBan_Thay()
        {
            Ban b1 = new Ban(111, 15);
            Ban b2 = new Ban(112, 15);
            Ban b3 = new Ban(113, 15);

            DSBan dsB = new DSBan();

            dsB.ThemBan(b1);
            dsB.ThemBan(b2);
            dsB.ThemBan(b3);

            Ban excepted = b1;
            Ban actual   = dsB.TimBan(b1.MaBan);

            Assert.AreEqual(excepted, actual);
        }
        public void ThemBan_NhapQuaGioiHanSucChua21()
        {
            Ban b0 = new Ban(0, 0);
            Ban b1 = new Ban(111, 10);
            Ban b2 = new Ban(112, 15);
            Ban b3 = new Ban(113, 11);

            DSBan dsB = new DSBan();

            dsB.ThemBan(b0);
            dsB.ThemBan(b1);
            dsB.ThemBan(b2);
            dsB.ThemBan(b3);

            int excepted = 0;
            int actual   = dsB.ThemBan(21);

            Assert.AreEqual(excepted, actual);
        }
        public void ThemBan_NhapDungSucChua()
        {
            Ban b0 = new Ban(0, 0);
            Ban b1 = new Ban(111, 10);
            Ban b2 = new Ban(112, 15);

            DSBan dsB = new DSBan();

            dsB.ThemBan(b0);
            dsB.ThemBan(b1);
            dsB.ThemBan(b2);

            dsB.ThemBan(4);

            Ban excepted = new Ban(113, 4);
            Ban actual   = dsB.DsBan[3];

            Assert.AreEqual(excepted.SucChua, actual.SucChua);
        }
        public void KiemTraTinhTrangBan_MaBanKhongCo()
        {
            Ban b0 = new Ban(0, 0);
            Ban b1 = new Ban(111, 10, true);
            Ban b2 = new Ban(112, 15, false);
            Ban b3 = new Ban(113, 16);

            DSBan dsB = new DSBan();

            dsB.ThemBan(b0);
            dsB.ThemBan(b1);
            dsB.ThemBan(b2);
            dsB.ThemBan(b3);

            dsB.ThemBan(4);
            dsB.SapXep();

            bool excepted = false;
            bool actual   = dsB.KiemTraTinhTrangBan(112);

            Assert.AreEqual(excepted, actual);
        }
        public void ThemBan_MaBanChenCuoi()
        {
            Ban b0 = new Ban(0, 0);
            Ban b1 = new Ban(111, 10);
            Ban b2 = new Ban(112, 15);
            Ban b3 = new Ban(113, 16);

            DSBan dsB = new DSBan();

            dsB.ThemBan(b0);
            dsB.ThemBan(b1);
            dsB.ThemBan(b2);
            dsB.ThemBan(b3);

            dsB.ThemBan(4);
            dsB.SapXep();

            Ban excepted = new Ban(114, 4);
            Ban actual   = dsB.DsBan[4];

            Assert.AreEqual(excepted.MaBan, actual.MaBan);
        }
示例#9
0
 private void btnThemBan_Click(object sender, EventArgs e)
 {
     dsBan.ThemBan(int.Parse(txtSucChua.Text));
     dsBan.SapXep();
     RefreshData();
 }