public OfferCategory(EOfferWebsite website, int websiteCategoryId, string categoryName) { this.EOfferWebsite = website; this.WebsiteCategoryId = websiteCategoryId; this.CategoryName = categoryName; this.CategoryUrl = "kategoria/" + websiteCategoryId; }
public void CheckCategoryOfferConstructorParametersPass(EOfferWebsite website, int categoryId) { OfferCategory category = new OfferCategory(website, 1); Assert.AreEqual(category.EOfferWebsite, website); Assert.AreEqual(category.CategoryUrl, "kategoria/gadzety-cukierki-260532"); }
public void CheckCategoryOfferConstructorParametersPassWithBaseCategory(EOfferWebsite website, int categoryId) { OfferCategory offerCategoryBase = new OfferCategory(EOfferWebsite.Allegro, 1); Assert.NotNull(offerCategoryBase.EOfferWebsite); Assert.AreEqual(offerCategoryBase.EOfferWebsite, EOfferWebsite.Allegro); }
/// <summary> /// Just for test purposes /// </summary> public OfferCategory(EOfferWebsite eOfferWebsite, string categoryName) { #if RELEASE throw new Exception("Cannot invoke test methods on prod. env."); #endif this.CategoryUrl = categoryName; this.CategoryName = categoryName; this.EOfferWebsite = eOfferWebsite; }
public OfferCategory(EOfferWebsite eOfferWebsite, int categoryId) { using (Dal db = new Dal()) { using (DbDataReader reader = db.ExecuteReader($"SELECT TOP 1 * FROM websiteCategories WITH (NOLOCK) WHERE id = {categoryId}")) { if (!reader.HasRows) { throw new DalException("Category cannot be found: " + categoryId + " website: " + eOfferWebsite + $"\n query: SELECT TOP 1 * FROM websiteCategories WITH (NOLOCK) WHERE id = {categoryId}"); } else { reader.Read(); this.CategoryUrl = reader.GetString(reader.GetOrdinal("routeUrl")); this.CategoryName = reader.GetString(reader.GetOrdinal("name")); this.CategoryId = reader.GetInt32(reader.GetOrdinal("Id")); } } } this.EOfferWebsite = eOfferWebsite; }