コード例 #1
0
        public static int CreateBrand(String BrandName, ref List <string> errors)
        {
            if (BrandName == null)
            {
                errors.Add("Brand name cannot be null");

                return(-1);
            }
            List <BrandInfo> pi = DALBrand.ReadBrandList(ref errors);

            for (int i = 0; i < pi.Count; i++)
            {
                if (BrandName.ToLower() == pi[i].brand_name.ToLower())
                {
                    errors.Add("Brand name already exists");
                }
            }

            if (errors.Count > 0)
            {
                return(-1);
            }

            return(DALBrand.CreateBrand(BrandName, ref errors));
        }
コード例 #2
0
ファイル: DALBrandTest.cs プロジェクト: louis1204/cs136_hw4
        public void CreateBrandTest()
        {
            Random        rand           = new Random();
            string        Brand_name     = "Hello Kitty" + rand.Next(10000); // TODO: Initialize to an appropriate value
            List <string> errors         = new List <string>();              // TODO: Initialize to an appropriate value
            List <string> errorsExpected = new List <string>();              // TODO: Initialize to an appropriate value

            int actual;

            actual = DALBrand.CreateBrand(Brand_name, ref errors);
            BrandInfo pi = DALBrand.ReadBrandDetail(actual, ref errors);

            Assert.AreEqual(pi.brand_name, Brand_name);
            Assert.AreEqual(pi.brand_id, actual);
        }