Exemplo n.º 1
0
        public void VaccineUpdateSuccessFive()
        {
            IVaccineStorage vaccineStorage = new VaccineStorage();
            Vaccine         myVaccine      = CreateVaccineForTest(
                "狂犬疫苗1",
                "处方1",
                getManufacturersIDtwo(),
                "68.00",
                "45");

            Vaccine createdVaccine =
                vaccineStorage.CreateVaccine(myVaccine);

            Assert.AreNotEqual(
                0,
                createdVaccine.VaccineID,
                string.Format("Could not create Vaccine:{0}",
                              createdVaccine.VaccineID));

            myVaccine.VaccineQuantity = Convert.ToInt32("60");

            vaccineStorage.UpdateVaccine(myVaccine);

            Vaccine updatedVaccine = vaccineStorage.ReadVaccine(
                createdVaccine.VaccineID);

            AssertVaccineItemEqual(myVaccine, updatedVaccine);
        }
        public static int getVaccineID()
        {
            IManufacturersStorage pManufacturersStorage = new ManufacturersStorage();
            Manufacturers         myManufacturers       = CreateManufacturersForTest(
                "供应商",
                "浙江温州",
                "17733117779",
                "2013-06-30",
                "2016-06-30");

            Manufacturers createdManufacturers =
                pManufacturersStorage.CreateManufacturers(myManufacturers);


            IVaccineStorage pVaccineStorage = new VaccineStorage();
            Vaccine         myVaccine       = CreateVaccineForTest(
                "狂犬疫苗",
                "处方",
                createdManufacturers.ManufacturersID,
                "68.00",
                "45");

            Vaccine createdVaccine =
                pVaccineStorage.CreateVaccine(myVaccine);

            return(createdVaccine.VaccineID);
        }
Exemplo n.º 3
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            IVaccineStorage vaccineStorage = new VaccineStorage();
            Vaccine         vaccine        = new Vaccine();

            if (textVaccineName.Text.Trim() == "" || textVaccineSort.Text.Trim() == "" ||
                cmbManufacturersName.Text.Trim() == "" || textVaccinePrice.Text.Trim() == "" ||
                textVaccineQuantity.Text.Trim() == "")
            {
                MessageBox.Show("请输入全部信息,不要有遗漏。");
            }
            else
            {
                vaccine.VaccineName     = textVaccineName.Text.Trim();
                vaccine.VaccineSort     = textVaccineSort.Text.Trim();
                vaccine.ManufacturersID = Convert.ToInt32(cmbManufacturersName.SelectedValue.ToString());    //SelectedValue取后台的ID
                vaccine.VaccinePrice    = Convert.ToDecimal(textVaccinePrice.Text.Trim());
                vaccine.VaccineQuantity = Convert.ToInt32(textVaccineQuantity.Text.Trim());

                vaccineStorage.CreateVaccine(vaccine);

                MessageBox.Show("增加成功!");

                textVaccineName.Text      = "";
                textVaccineSort.Text      = "";
                cmbManufacturersName.Text = "";
                textVaccinePrice.Text     = "";
                textVaccineQuantity.Text  = "";
            }
        }
Exemplo n.º 4
0
        public void VaccineCreateFailureManufacturersIDArgumentException()
        {
            IVaccineStorage vaccineStorage = new VaccineStorage();
            Vaccine         myVaccine      = CreateVaccineForTest(
                "狂犬疫苗",
                "处方",
                -1,
                "68.00",
                "45");

            vaccineStorage.CreateVaccine(myVaccine);
        }
Exemplo n.º 5
0
        public void VaccineCreateFailureVaccineNameArgumentNullException()
        {
            IVaccineStorage vaccineStorage = new VaccineStorage();
            Vaccine         myVaccine      = CreateVaccineForTest(
                null,
                "处方",
                getManufacturersID(),
                "68.00",
                "45");

            vaccineStorage.CreateVaccine(myVaccine);
        }
Exemplo n.º 6
0
        public void VaccineUpdateFailureVaccineIdArgumentException()
        {
            IVaccineStorage vaccineStorage = new VaccineStorage();
            Vaccine         myVaccine      = CreateVaccineForTest(
                "狂犬疫苗1",
                "处方1",
                getManufacturersIDtwo(),
                "68.00",
                "45");

            vaccineStorage.CreateVaccine(myVaccine);

            myVaccine.VaccineID = int.MaxValue;

            vaccineStorage.UpdateVaccine(myVaccine);
        }
Exemplo n.º 7
0
        public void VaccineCreateSuccess()
        {
            IVaccineStorage vaccineStorage = new VaccineStorage();
            Vaccine         myVaccine      = CreateVaccineForTest(
                "狂犬疫苗",
                "处方",
                getManufacturersID(),
                "68.00",
                "45");

            Vaccine createdVaccine =
                vaccineStorage.CreateVaccine(myVaccine);

            Assert.AreNotEqual(
                0,
                createdVaccine.VaccineID,
                string.Format("Could not create Vaccine:{0}",
                              createdVaccine.VaccineID));

            AssertVaccineItemEqual(myVaccine, createdVaccine);
        }
Exemplo n.º 8
0
        public void VaccineListSuccess()
        {
            List <Vaccine> vaccineList = new List <Vaccine>();

            IVaccineStorage vaccineStorage = new VaccineStorage();

            Vaccine myVaccine = CreateVaccineForTest(
                "狂犬疫苗11",
                "处方11",
                getManufacturersID(),
                "68.00",
                "45");

            Vaccine createdVaccine =
                vaccineStorage.CreateVaccine(myVaccine);

            vaccineList.Add(createdVaccine);

            myVaccine = CreateVaccineForTest(
                "狂犬疫苗12",
                "处方11",
                createdVaccine.ManufacturersID,
                "68.00",
                "45");

            createdVaccine =
                vaccineStorage.CreateVaccine(myVaccine);

            vaccineList.Add(createdVaccine);

            myVaccine = CreateVaccineForTest(
                "狂犬疫苗12",
                "处方12",
                createdVaccine.ManufacturersID,
                "68.00",
                "45");

            createdVaccine =
                vaccineStorage.CreateVaccine(myVaccine);

            vaccineList.Add(createdVaccine);

            myVaccine = CreateVaccineForTest(
                "狂犬疫苗12",
                "处方12",
                getManufacturersIDtwo(),
                "68.00",
                "45");

            createdVaccine =
                vaccineStorage.CreateVaccine(myVaccine);

            vaccineList.Add(createdVaccine);

            myVaccine = CreateVaccineForTest(
                "狂犬疫苗12",
                "处方12",
                createdVaccine.ManufacturersID,
                "72.80",
                "45");

            createdVaccine =
                vaccineStorage.CreateVaccine(myVaccine);

            vaccineList.Add(createdVaccine);

            myVaccine = CreateVaccineForTest(
                "狂犬疫苗12",
                "处方12",
                createdVaccine.ManufacturersID,
                "72.80",
                "60");

            createdVaccine =
                vaccineStorage.CreateVaccine(myVaccine);

            vaccineList.Add(createdVaccine);

            QueryVaccine queryVaccine = new QueryVaccine();

            queryVaccine.VaccineID       = null;
            queryVaccine.VaccineName     = null;
            queryVaccine.VaccineSort     = null;
            queryVaccine.ManufacturersID = null;
            queryVaccine.VaccinePrice    = null;
            queryVaccine.VaccineQuantity = null;

            IList <Vaccine> readedVaccineList =
                vaccineStorage.ListVaccine(queryVaccine);

            AssertVaccineListsEqual(vaccineList, readedVaccineList);

            vaccineList.RemoveAt(0);

            queryVaccine = new QueryVaccine();

            queryVaccine.VaccineID       = null;
            queryVaccine.VaccineName     = "狂犬疫苗12";
            queryVaccine.VaccineSort     = null;
            queryVaccine.ManufacturersID = null;
            queryVaccine.VaccinePrice    = null;
            queryVaccine.VaccineQuantity = null;

            readedVaccineList =
                vaccineStorage.ListVaccine(queryVaccine);

            AssertVaccineListsEqual(vaccineList, readedVaccineList);

            vaccineList.RemoveAt(0);

            queryVaccine = new QueryVaccine();

            queryVaccine.VaccineID       = null;
            queryVaccine.VaccineName     = null;
            queryVaccine.VaccineSort     = "处方12";
            queryVaccine.ManufacturersID = null;
            queryVaccine.VaccinePrice    = null;
            queryVaccine.VaccineQuantity = null;

            readedVaccineList =
                vaccineStorage.ListVaccine(queryVaccine);

            AssertVaccineListsEqual(vaccineList, readedVaccineList);

            vaccineList.RemoveAt(0);

            queryVaccine = new QueryVaccine();

            queryVaccine.VaccineID       = null;
            queryVaccine.VaccineName     = null;
            queryVaccine.VaccineSort     = null;
            queryVaccine.ManufacturersID = createdVaccine.ManufacturersID;
            queryVaccine.VaccinePrice    = null;
            queryVaccine.VaccineQuantity = null;

            readedVaccineList =
                vaccineStorage.ListVaccine(queryVaccine);

            AssertVaccineListsEqual(vaccineList, readedVaccineList);

            vaccineList.RemoveAt(0);

            queryVaccine = new QueryVaccine();

            queryVaccine.VaccineID       = null;
            queryVaccine.VaccineName     = null;
            queryVaccine.VaccineSort     = null;
            queryVaccine.ManufacturersID = null;
            queryVaccine.VaccinePrice    = Convert.ToDecimal("72.80");
            queryVaccine.VaccineQuantity = null;

            readedVaccineList =
                vaccineStorage.ListVaccine(queryVaccine);

            AssertVaccineListsEqual(vaccineList, readedVaccineList);

            vaccineList.RemoveAt(0);

            queryVaccine = new QueryVaccine();

            queryVaccine.VaccineID       = null;
            queryVaccine.VaccineName     = null;
            queryVaccine.VaccineSort     = null;
            queryVaccine.ManufacturersID = null;
            queryVaccine.VaccinePrice    = null;
            queryVaccine.VaccineQuantity = Convert.ToInt32("60");

            readedVaccineList =
                vaccineStorage.ListVaccine(queryVaccine);

            AssertVaccineListsEqual(vaccineList, readedVaccineList);
        }
Exemplo n.º 9
0
        //这个属性其实非常有用处,它表明这个函数会抛出一个预期的异常。
        public void VaccineCreateFailureVaccineArgumentNullException()
        {
            IVaccineStorage vaccineStorage = new VaccineStorage();

            vaccineStorage.CreateVaccine(null);
        }