当前位置: 首页>>代码示例>>C#>>正文


C# Product.AddSize方法代码示例

本文整理汇总了C#中Product.AddSize方法的典型用法代码示例。如果您正苦于以下问题:C# Product.AddSize方法的具体用法?C# Product.AddSize怎么用?C# Product.AddSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Product的用法示例。


在下文中一共展示了Product.AddSize方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddSize_should_raise_domain_event

        public void AddSize_should_raise_domain_event()
        {
            const int productId = 97;
            const string productName = "Widget";
            const int sizeId = 34;
            const string sizeName = "Small";

            var product = new Product
            {
                Name = productName,
                Id = productId
            };

            var size = new Size
            {
                Id = sizeId,
                Name = "Small"
            };

            IDomainEvent @event = null;
            using(DomainEvent.TestWith(e => { @event = e; }))
            {
                product.AddSize(size);
            }

            var sizeCreatedEvent = @event as SizeCreatedEvent;
            sizeCreatedEvent.ShouldNotBeNull();
            sizeCreatedEvent.ProductName.ShouldEqual(productName);
            sizeCreatedEvent.SizeName.ShouldEqual(sizeName);
        }
开发者ID:somlea-george,项目名称:sutekishop,代码行数:30,代码来源:ProductTests.cs

示例2: SetUp

        public void SetUp()
        {
            var size = new Size
            {
                Name = "Medium",
                IsActive = true,
                IsInStock = true
            };

            var product = new Product
            {
                Name = "Widget",
                Description = "Our best Widget",
                
            };

            using (DomainEvent.TurnOff())
            {
                product.AddSize(size);
            }

            InSession(session => session.Save(product));

            sizeId = size.Id;

            var basket = new Basket();

            InSession(session => session.Save(basket));

            basketId = basket.Id;
        }
开发者ID:somlea-george,项目名称:sutekishop,代码行数:31,代码来源:BasketMapTests.cs

示例3: CopySizes

 static void CopySizes(Product originalProduct, Product copiedProduct)
 {
     foreach (var size in originalProduct.Sizes)
     {
         copiedProduct.AddSize(new Size
         {
             Name = size.Name,
             IsActive = size.IsActive,
             IsInStock = size.IsInStock
         });
     }
 }
开发者ID:mikehadlow,项目名称:sutekishop,代码行数:12,代码来源:ProductCopyService.cs

示例4: Update

        public void Update(Product product)
        {
            if (form == null) throw new ApplicationException("form must be set with 'WithValues' before calling Update");

            if (product.DefaultSizeMissing)
            {
                product.AddDefaultSize();
            }

            var keys = form.AllKeys.Where(key => key.StartsWith("size_") && form[key].Length > 0);
            keys.ForEach(key => product.AddSize(new Size { Name = form[key], IsActive = true, IsInStock = true }));
        }
开发者ID:sthapa123,项目名称:sutekishop,代码行数:12,代码来源:SizeService.cs

示例5: Should_be_able_to_create_a_product

        public void Should_be_able_to_create_a_product()
        {
            var product = new Product
            {
                Name = "Sophie",
                Description = "A nice sloop",
                Price = new Money(86.22M),
                IsActive = true,
                Position = 1
            };

            var size = new Size
            {
                Name = "10cm"
            };

            var image = new Image
            {
                Description = "sophie1.jpg",
                FileName = new Guid("3DF66C48-ED24-4004-A258-8CD9D56A18C6")
            };

            InSession(session =>
            {
                var category = session.Get<Category>(categoryId);
                using (DomainEvent.TurnOff())
                {
                    product.AddSize(size);
                }
                product.AddCategory(category);
                product.AddProductImage(image, 1);
                session.SaveOrUpdate(product);
            });

            // now delete the image
            InSession(session =>
            {
                var sameProduct = session.Get<Product>(product.Id);
                var productImage = sameProduct.ProductImages[0];
                sameProduct.ProductImages.Remove(productImage);
            });
        }
开发者ID:somlea-george,项目名称:sutekishop,代码行数:42,代码来源:ProductMapTests.cs

示例6: CreateProduct

        static Product CreateProduct(Category category)
        {
            var product = new Product
            {
                Id = 144,
                Name = "Super Widget",
                Description = "Some product description",
                Price = new Money(34.56M),
                Position = 6,
                Weight = 345,
                IsActive = true
            };

            product.AddSize(new Size
            {
                Id = 21,
                IsActive = true,
                IsInStock = true,
                Name = "Small"
            });

            product.AddSize(new Size
            {
                Id = 22,
                IsActive = true,
                IsInStock = true,
                Name = "Medium"
            });

            product.AddCategory(category, 0);

            product.AddProductImage(new Image { Id = 3 }, 1);
            return product;
        }
开发者ID:mikehadlow,项目名称:sutekishop,代码行数:34,代码来源:ProductCopyServiceTests.cs

示例7: ProductStockUpdate_should_update_product

        public void ProductStockUpdate_should_update_product()
        {
            using(DomainEvent.TurnOff())
            {
                var product = new Product {Name = "Widget"};
                product.AddSize(new Size {IsInStock = true});
                product.AddSize(new Size {IsInStock = true});
                product.AddSize(new Size {IsInStock = true});

                var form = new FormCollection
                {
                    {"Id", "4"},
                    {"Sizes[0].IsInStock", "false,true"},
                    {"Sizes[1].IsInStock", "false"},
                    {"Sizes[2].IsInStock", "false,true"}
                };

                productRepository.Stub(r => r.GetById(4)).Return(product);

                stockController.ProductStockUpdate(form)
                    .ReturnsRedirectToRouteResult()
                    .ToController("Product")
                    .ToAction("Item")
                    .WithRouteValue("urlName", "Widget");

                product.Sizes[0].IsInStock.ShouldBeTrue();
                product.Sizes[1].IsInStock.ShouldBeFalse();
                product.Sizes[2].IsInStock.ShouldBeTrue();
            }
        }
开发者ID:somlea-george,项目名称:sutekishop,代码行数:30,代码来源:StockControllerTests.cs


注:本文中的Product.AddSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。