public void DeleteUnitCost_Test_회사정보만_입력시_예상되는_쿼리_반환하는지(bool useLike) { string exQuery = string.Format("Delete from UnitCost where CompanyIDX in (select CompanyPK as CompanyIDX from Companies where CompanyName='testCompany')"); if (useLike) { exQuery = string.Format("Delete from UnitCost where CompanyIDX in (select CompanyPK as CompanyIDX from Companies where CompanyName like '%testCompany%')"); } Companies c = new Companies(); c.CompanyName = "testCompany"; string query = new SQLDataQueryRepository().DeleteUnitCost(null, c, useLike); Assert.AreEqual(exQuery, query); }
public void DeleteUnitCost_Test_제품정보와_업체정보_입력시_예상되는_쿼리_반환하는지(bool useLike) { string exQuery = string.Format("Delete from UnitCost where GoodIDX in (select GoodPK as GoodIDX from Goods where GoodName='testGood') and CompanyIDX in (select CompanyPK as CompanyIDX from Companies where CompanyName='testCompany')"); if (useLike) { exQuery = string.Format("Delete from UnitCost where GoodIDX in (select GoodPK as GoodIDX from Goods where GoodName like '%testGood%') and CompanyIDX in (select CompanyPK as CompanyIDX from Companies where CompanyName like '%testCompany%')"); } Companies c = new Companies(); c.CompanyName = "testCompany"; Goods g = new Goods(); g.GoodName = "testGood"; string query = new SQLDataQueryRepository().DeleteUnitCost(g, c, useLike); Assert.AreEqual(exQuery, query); }
public void DeleteSeller_Test_업체관련정보와_상품정보_입력시_예상되는_값이_반환되는가(bool useLike) { string exQuery = string.Format("Delete from GoodSeller where GoodIDX in (select GoodPK as GoodIDX from Goods where GoodName='testGood') and SellerIDX in (select CompanyPK as SellerIDX from Companies where CompanyName='testCompany')"); if (useLike) { exQuery = string.Format("Delete from GoodSeller where GoodIDX in (select GoodPK as GoodIDX from Goods where GoodName like '%testGood%') and SellerIDX in (select CompanyPK as SellerIDX from Companies where CompanyName like '%testCompany%')"); } Companies c = new Companies(); c.CompanyName = "testCompany"; Goods g = new Goods(); g.GoodName = "testGood"; string query = new SQLDataQueryRepository().DeleteSeller(g, c, useLike); Assert.AreEqual(exQuery, query); }
public void DeleteSeller_Test_업체관련정보_입력시_예상되는_값이_반환되는가(bool useLike) { string exQuery = string.Format("Delete from GoodSeller where SellerIDX in (select CompanyPK as SellerIDX from Companies where CompanyName='test')"); if (useLike) { exQuery = string.Format("Delete from GoodSeller where SellerIDX in (select CompanyPK as SellerIDX from Companies where CompanyName like '%test%')"); } Companies c = new Companies(); c.CompanyName = "test"; string query = new SQLDataQueryRepository().DeleteSeller(null, c, useLike); Assert.AreEqual(exQuery, query); }
public string DeleteUnitCost(Goods goodInfo, Companies companyInfo, bool useLike) { IDictionary<string, string> goodDic = new Dictionary<string, string>(); if (goodInfo!=null) { foreach (var prop in typeof(Goods).GetProperties()) { if (goodInfo[prop.Name] == null || goodInfo[prop.Name].ToString() == string.Empty) { continue; } goodDic.Add(prop.Name, goodInfo[prop.Name].ToString()); } } IDictionary<string, string> companyDic = new Dictionary<string, string>(); if (companyInfo!=null) { foreach (var prop in typeof(Companies).GetProperties()) { if (companyInfo[prop.Name] == null || companyInfo[prop.Name].ToString() == string.Empty) { continue; } companyDic.Add(prop.Name, companyInfo[prop.Name].ToString()); } } StringBuilder sbWhere = new StringBuilder(); if (goodDic.Count>0) { sbWhere.Append(" where GoodIDX in ("); sbWhere.AppendFormat("select GoodPK as GoodIDX from Goods{0}", MakeWhereBlock(typeof(Goods), goodDic, useLike)); sbWhere.Append(")"); } if (companyDic.Count>0) { if (goodDic.Count>0) { sbWhere.Append(" and "); } else { sbWhere.Append(" where "); } sbWhere.Append("CompanyIDX in ("); sbWhere.AppendFormat("select CompanyPK as CompanyIDX from Companies{0}", MakeWhereBlock(typeof(Companies), companyDic, useLike)); sbWhere.Append(")"); } StringBuilder sbQuery = new StringBuilder(); sbQuery.AppendFormat("Delete from UnitCost{0}",sbWhere.ToString()); return sbQuery.ToString(); }
public string DeleteSeller(Goods goodInfo, Companies companyInfo,bool useLike) { //[1] 이너뷰 작성 string goodsWhere = string.Empty; string companyWhere = string.Empty; if (goodInfo!=null) { IDictionary<string, string> goodDic = new Dictionary<string, string>(); foreach (var prop in typeof(Goods).GetProperties()) { if (prop.Name.ToLower() == "item" || prop.Name == "RowCount" || prop.Name == "Page") { continue; } if (goodInfo[prop.Name] == null) { continue; } goodDic.Add(prop.Name, goodInfo[prop.Name].ToString()); } goodsWhere = string.Format("select GoodPK as GoodIDX from Goods{0}", MakeWhereBlock(typeof(Goods), goodDic, useLike)); } if (companyInfo!=null) { IDictionary<string, string> comDic = new Dictionary<string, string>(); foreach (var prop in typeof(Companies).GetProperties()) { if (prop.Name.ToLower() == "item" || prop.Name == "RowCount" || prop.Name == "Page") { continue; } if (companyInfo[prop.Name] == null || companyInfo[prop.Name].Replace(" ","") == string.Empty) { continue; } comDic.Add(prop.Name, companyInfo[prop.Name].ToString()); } companyWhere = string.Format("select CompanyPK as SellerIDX from Companies{0}", MakeWhereBlock(typeof(Companies), comDic, useLike)); } //[2] 이너뷰 이용한 where정 작성 StringBuilder sbWhere = new StringBuilder(); if (goodsWhere!=string.Empty) { sbWhere.Append(" where "); sbWhere.AppendFormat("GoodIDX in ({0})",goodsWhere); if (companyWhere!=string.Empty) { sbWhere.Append(" and "); } } if (companyWhere != string.Empty) { if (goodsWhere==string.Empty) { sbWhere.Append(" where "); } sbWhere.AppendFormat("SellerIDX in ({0})", companyWhere); } //[3] 쿼리작성 StringBuilder sbQuery = new StringBuilder(); sbQuery.Append("Delete from GoodSeller"); sbQuery.Append(sbWhere.ToString()); return sbQuery.ToString(); }