예제 #1
0
 public void DiscountPriceIsCorrect([Frozen]Money expectedPrice, CampaignItem sut)
 {
     // Fixture setup
     // Exercise system
     Money result = sut.DiscountPrice;
     // Verify outcome
     Assert.Equal(expectedPrice, result);
     // Teardown
 }
예제 #2
0
 public void IsFeaturedIsCorrect([Frozen]bool expectedResult, CampaignItem sut)
 {
     // Fixture setup
     // Exercise system
     bool result = sut.IsFeatured;
     // Verify outcome
     Assert.Equal(expectedResult, result);
     // Teardown
 }
예제 #3
0
 public void ProductIsCorrect([Frozen]Product expectedProduct, CampaignItem sut)
 {
     // Fixture setup
     // Exercise system
     Product result = sut.Product;
     // Verify outcome
     Assert.Equal(expectedProduct, result);
     // Teardown
 }
 public void MapCampaignItemWithDiscountWillReturnCorrectResult(CampaignItem item, PresentationMapper sut)
 {
     // Fixture setup
     var expectedPresenter = item.AsSource().OfLikeness<CampaignItemPresenter>()
         .With(d => d.Id).EqualsWhen((s, d) => s.Product.Id == d.Id)
         .With(d => d.ProductName).EqualsWhen((s, d) => s.Product.Name == d.ProductName)
         .With(d => d.UnitPrice).EqualsWhen((s, d) => s.Product.UnitPrice.Amount == d.UnitPrice)
         .With(d => d.DiscountPrice).EqualsWhen((s, d) => s.DiscountPrice.Amount == d.DiscountPrice);
     // Exercise system
     var result = sut.Map(item);
     // Verify outcome
     Assert.True(expectedPresenter.Equals(result));
     // Teardown
 }
        public virtual CampaignItemPresenter Map(CampaignItem item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }        

            var presenter = new CampaignItemPresenter();
            presenter.Id = item.Product.Id;
            presenter.IsFeatured = item.IsFeatured;
            presenter.DiscountPrice = item.DiscountPrice != null ? item.DiscountPrice.Amount : new decimal?();
            presenter.ProductName = item.Product.Name;
            presenter.UnitPrice = item.Product.UnitPrice.Amount;

            return presenter;
        }
        public override void Update(CampaignItem item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            var dbItem = new Product();
            dbItem.ProductId = item.Product.Id;

            this.context.AttachTo("Products", dbItem);

            dbItem.IsFeatured = item.IsFeatured;
            if (item.DiscountPrice == null)
            {
                dbItem.DiscountedUnitPrice = null;
            }
            else
            {
                dbItem.DiscountedUnitPrice = item.DiscountPrice.Amount;
            }

            this.context.SaveChanges();
        }
 public abstract void Update(CampaignItem item);
예제 #8
0
 public abstract void Update(CampaignItem item);