示例#1
0
 public Domain.Product ToDomainProduct()
 {
     Domain.Product p = new Domain.Product();
     p.Name      = this.Name;
     p.UnitPrice = this.UnitPrice;
     return(p);
 }
示例#2
0
 public Domain.Product ToDomainProduct()
 {
     Domain.Product p = new Domain.Product();
     p.Name = this.Name;
     p.UnitPrice = this.UnitPrice;
     return p;
 }
        public void GetFeaturedProductsWillReturnCorrectProduct()
        {
            // Fixture setup
            var product = new Product();
            product.Name = "Olives";
            product.UnitPrice = 24.5m;

            var repositoryStub = new Mock<ProductRepository>();
            repositoryStub
                .Setup(s => s.GetFeaturedProducts())
                .Returns(new[] { product });

            var sut =
                new ProductService(repositoryStub.Object);

            var userStub = new Mock<IPrincipal>();
            // Exercise system
            var products = 
                sut.GetFeaturedProducts(userStub.Object);
            var result = products.Single();
            // Verify outcome
            Assert.Equal(product.Name, result.Name);
            Assert.Equal(product.UnitPrice, result.UnitPrice);
            // Teardown
        }
示例#4
0
 public Extent WithItem(Product item)
 {
     var newExtent = new Extent(item);
     newExtent.Quantity = this.Quantity;
     newExtent.Updated = this.Updated;
     newExtent.total = this.total;
     return newExtent;
 }
示例#5
0
        public Extent(Product product)
        {
            if (product == null)
            {
                throw new ArgumentNullException("item");
            }

            this.product = product;
        }
 public void InsertProductWillAuditInsertion(Product product, [Frozen]Mock<IAuditor> auditorMock, AuditingProductRepository sut)
 {
     // Fixture setup
     // Exercise system
     sut.InsertProduct(product);
     // Verify outcome
     auditorMock.Verify(a => a.Record(It.Is<AuditEvent>(ae => ae.Name == "ProductInserted" && ae.Data.Equals(product))));
     // Teardown
 }
 public void InsertProductWillInsertProductInDecoratedRepository(Product product, [Frozen]Mock<ProductRepository> repositoryMock, AuditingProductRepository sut)
 {
     // Fixture setup
     // Exercise system
     sut.InsertProduct(product);
     // Verify outcome
     repositoryMock.Verify(r => r.InsertProduct(product));
     // Teardown
 }
 public void MapProductWillReturnCorrectResult(Product product, ContractMapper sut)
 {
     // Fixture setup
     var expectedContract = product.AsSource().OfLikeness<ProductContract>()
         .With(d => d.UnitPrice).EqualsWhen((s, d) => s.UnitPrice.AsSource().OfLikeness<MoneyContract>().Equals(d.UnitPrice));
     // Exercise system
     ProductContract result = sut.Map(product);
     // Verify outcome
     Assert.True(expectedContract.Equals(result));
     // Teardown
 }
示例#9
0
        public CampaignItem(Product product, bool isFeatured, Money discountPrice)
        {
            if (product == null)
            {
                throw new ArgumentNullException("product");
            }

            this.product = product;
            this.isFeatured = isFeatured;
            this.discountPrice = discountPrice;
        }
示例#10
0
        public ProductContract Map(Product product)
        {
            if (product == null)
            {
                throw new ArgumentNullException("product");
            }

            var pc = new ProductContract();
            pc.Id = product.Id;
            pc.Name = product.Name;
            pc.UnitPrice = this.Map(product.UnitPrice);
            return pc;
        }
        public CampaignItem Map(CampaignItemPresenter presenter)
        {
            if (presenter == null)
            {
                throw new ArgumentNullException("presenter");
            }
        
            var unitPrice = new Money(presenter.UnitPrice, "DKK");

            Money discountPrice = null;
            if (presenter.DiscountPrice.HasValue)
            {
                discountPrice = new Money(presenter.DiscountPrice.Value, "DKK");
            }

            var product = new Product(presenter.Id, presenter.ProductName, unitPrice);
            return new CampaignItem(product, presenter.IsFeatured, discountPrice);
        }
 public ProductViewModel(Product product)
 {
     this.id = product.Id;
     this.Name = product.Name;
     this.UnitPrice = product.UnitPrice;
 }
 public Product Apply(Product product, IPrincipal customer)
 {
     var discount = customer.IsInRole("PreferredCustomer") ? .95m : 1;
     return product.WithUnitPrice(product.UnitPrice.Multiply(discount));
 }