예제 #1
0
        public void Is_Updating_Sync_Called_Test()
        {
            using (var ts = new TestListScope <UpdatingItem>("Is_Updating_Sync_Called_Test", true))
            {
                ts.List.AddEventReceiver <UpdatingReceiver>();
                var entity = FillCusomItem(ts);
                ts.List.Add(entity);

                var origCopy = new UpdatingItem(entity);

                entity = ts.List.ById(entity.Id);
                ModifyCustomItem(entity);
                ts.List.Update(entity, true);

                Assert.True(UpdatingItem.IsUpdateCalled, "Not fired updating receiver!");

                if (UpdatingItem.Exception != null)
                {
                    throw UpdatingItem.Exception;
                }

                ValidateCustomItem(UpdatingItem.ReceivedOrig, origCopy);
                ValidateCustomItem(UpdatingItem.ReceivedChanged, entity, true);
            }
        }
예제 #2
0
        /// <summary>
        /// Updates price
        /// </summary>
        /// <param name="sku"></param>
        /// <param name="price"></param>
        public void UpdatePrice(string sku, decimal price)
        {
            if (!_itemCache.Items.Contains(sku))
            {
                return;
            }

            UpdatingItem.RaiseEvent(new UpdateItemEventArgs <ILineItem>(_itemCache.Items[sku]), this);

            _itemCache.Items[sku].Price = price;

            UpdatedItem.RaiseEvent(new UpdateItemEventArgs <ILineItem>(_itemCache.Items[sku]), this);
        }
        /// <summary>
        /// Updates a customer item cache item's quantity
        /// </summary>
        /// <param name="sku">
        /// The SKU.
        /// </param>
        /// <param name="quantity">
        /// The quantity.
        /// </param>
        public void UpdateQuantity(string sku, int quantity)
        {
            if (!_itemCache.Items.Contains(sku))
            {
                return;
            }

            if (quantity <= 0)
            {
                RemoveItem(sku);
                return;
            }

            UpdatingItem.RaiseEvent(new UpdateItemEventArgs <ILineItem>(_itemCache.Items[sku]), this);

            _itemCache.Items[sku].Quantity = quantity;

            UpdatedItem.RaiseEvent(new UpdateItemEventArgs <ILineItem>(_itemCache.Items[sku]), this);
        }