public void UpsertAttribute_InsertSecond()
        {
            Mock<IProductRepository> productRepo = new Mock<IProductRepository>();
            Mock<IImageResizer> imageResizer = new Mock<IImageResizer>();
            ProductService service = new ProductService(productRepo.Object, imageResizer.Object, ServiceBuilder.Saver.Object);
            Product oneAtt = new Product();
            MetaAttribute cost = new MetaAttribute();
            cost.Id = 3;
            cost.DataTypeEnum = MetaAttribute.MetaAttributeDataType.CURRENCY;

            MetaAttribute height = new MetaAttribute();
            height.Id = 6;
            height.DataTypeEnum = MetaAttribute.MetaAttributeDataType.INTEGER;

            ProductAttribute costAtt = new ProductAttribute();
            costAtt.Id = 2;
            costAtt.MetaAttribute = cost;
            oneAtt.ProductAttributes.Add(costAtt);

            ProductAttribute heightAtt = new ProductAttribute();
            heightAtt.Id = 8;
            heightAtt.MetaAttribute = height;

            productRepo.Expect(repo => repo.CreateProductAttribute(height)).Returns(heightAtt);
            service.UpsertAttribute(oneAtt, height, "69");

            Assert.AreEqual(2, oneAtt.ProductAttributes.Count);
        }
Exemple #2
0
        private static string SelectableAttribute(HtmlHelper helper, MetaAttribute ma, ProductAttribute attribute)
        {
            SelectList listData = (attribute != null)
                        ? new SelectList(SelectHelper.DropDownRecordsFromValueSet(ma.ChoicesCollection), "Value", "Text", (object)attribute.RawValue)
                        : new SelectList(SelectHelper.DropDownRecordsFromValueSet(ma.ChoicesCollection), "Value", "Text");

            return helper.DropDownList(ma.ProductAttributeHtmlControlName, listData, OPTION_LABEL);
        }
Exemple #3
0
        /// <summary>Generate a control for displaying an attribute.</summary>
        /// <param name="helper"></param><param name="ma"></param><param name="attribute"></param>
        /// <returns></returns>
        public static string AttributeControl(HtmlHelper helper, MetaAttribute ma, ProductAttribute attribute)
        {
            string result = (ma.DataTypeEnum == MetaAttribute.MetaAttributeDataType.CURRENCY) ? "$" : "&nbsp;";

            return (ma.HasChoices)
                ? result + SelectableAttribute(helper, ma, attribute)
                : result + NonSelectableAttribute(helper, ma, attribute);
        }
        public void UpsertAttribute_Clear()
        {
            ProductService service = SetupProductService();
            Product oneAtt = new Product();
            MetaAttribute cost = new MetaAttribute();
            cost.Id = 3;
            cost.DataTypeEnum = MetaAttribute.MetaAttributeDataType.CURRENCY;
            ProductAttribute costAtt = new ProductAttribute();
            costAtt.Id = 2;
            costAtt.MetaAttribute = cost;
            oneAtt.ProductAttributes.Add(costAtt);

            service.UpsertAttribute(oneAtt, cost, "");
            Assert.AreEqual(1, oneAtt.ProductAttributes.Count);
        }
        public void UpsertAttribute_Insert()
        {
            Mock<IProductRepository> productRepo = new Mock<IProductRepository>();
            ProductService service = SetupProductService();
            Product noAtts = new Product();
            MetaAttribute metaAttribute = new MetaAttribute();
            metaAttribute.Id = 5;
            metaAttribute.DataTypeEnum = MetaAttribute.MetaAttributeDataType.STRING;

            service.UpsertAttribute(noAtts, metaAttribute, "");
            Assert.IsTrue(noAtts.ProductAttributes.Count == 0);

            ProductAttribute catAtt = new ProductAttribute();
            catAtt.Id = 1;
            catAtt.MetaAttribute = metaAttribute;
            catAtt.Product = noAtts;

            productRepo.Expect(repo => repo.CreateProductAttribute(metaAttribute)).Returns(catAtt);

            service.UpsertAttribute(noAtts, metaAttribute, "cat");
            Assert.AreEqual(1, noAtts.ProductAttributes.Count);
        }
Exemple #6
0
 private static string NonSelectableAttribute(HtmlHelper helper, MetaAttribute ma, ProductAttribute attribute)
 {
     return (attribute != null)
                 ? helper.TextBox(ma.ProductAttributeHtmlControlName, attribute.ControlFormattedValue)
                 : helper.TextBox(ma.ProductAttributeHtmlControlName);
 }
 partial void DeleteProductAttribute(ProductAttribute instance);
 partial void UpdateProductAttribute(ProductAttribute instance);
 partial void InsertProductAttribute(ProductAttribute instance);
		private void detach_ProductAttributes(ProductAttribute entity)
		{
			this.SendPropertyChanging();
			entity.MetaAttribute = null;
		}
		private void attach_ProductAttributes(ProductAttribute entity)
		{
			this.SendPropertyChanging();
			entity.Product = this;
		}