private Action <CartItemCreateResource> GetCartItemEdit(int extraQuantity = 0)
        {
            var product = ResourcesHolder.EditAndCreate <ProductCreateResource, ProductResource>(p => p.IsWeighable = true).Value;

            ResourcesHolder.EditAndCreate <PromotionCreateResource, PromotionResource>(p => p.TriggeringQuantity = 1);
            return(c => { c.ProductId = product.Id; c.Quantity = product.Size + extraQuantity; });
        }
        public void TestSameBarcode()
        {
            var procuctResource = ResourcesHolder.GetLastOrCreate <ProductResource>().Value;
            var response        = ResourcesHolder.EditAndCreate <ProductCreateResource, ProductResource>(p => p.Barcode = procuctResource.Barcode);

            AssertBadRequestReason(response, BadRequestReason.SameExists);
        }
        public void Test_No_Promotion_On_Weighable_Product()
        {
            var cartItemEdit = GetCartItemEdit(-1);

            var cartItem = ResourcesHolder.EditAndCreate <CartItemCreateResource, CartItemResource>(cartItemEdit).Value;

            Assert.IsFalse(cartItem.ItemPrice.HasDiscount);
        }
Пример #4
0
        public void ManagerNotFound()
        {
            var managerId = CreatedResource.Id;

            ResourcesHolder.Delete <EmployeeResource>(managerId);

            var response = ResourcesHolder.EditAndCreate <EmployeeCreateResource, EmployeeUpdateResource, EmployeeResource>(u => u.ManagerId = managerId);

            AssertNotFound(response);
        }
        public void TestTwoPromotionApplies()
        {
            ResourcesHolder.Delete <PromotionResource>(CreatedResource.Id);
            Action <PromotionCreateResource> edit = p => { p.TriggeringQuantity = 2; p.IsReApply = true; };

            CreatedResource = ResourcesHolder.EditAndCreate <PromotionCreateResource, PromotionResource>(edit).Value;

            AddCartItem(2);

            var cart = GetExistingOrNew <CartResource>();
            var expectedPromotionDiscount = ExpectedPromotionDiscount(2);

            Assert.AreEqual(expectedPromotionDiscount, cart.CartPrice.BeforeDiscount - cart.CartPrice.TotalPrice);
        }
Пример #6
0
 public void FillDatabaseWithProducts()
 {
     for (int c = 0; c < 5; c++)
     {
         ResourcesHolder.Create <DepartmentResource>();
         for (int f = 0; f < 3; f++)
         {
             var category = GetRandomCreateResource <CategoryCreateResource, CategoryResource>();
             var family   = category.FamilyName;
             for (int s = 0; s < 3; s++)
             {
                 ResourcesHolder.EditAndCreate <CategoryCreateResource, CategoryResource>(sc => sc.FamilyName = family);
                 for (int p = 0; p < SCALE; p++)
                 {
                     ResourcesHolder.EditAndCreate <ProductCreateResource, ProductResource>(EditProductToWeighable());
                 }
             }
             ResourcesHolder.Create <PromotionResource>();
         }
     }
 }
Пример #7
0
 private EmployeeResource GetEmployeeWithManager(string managerId)
 {
     return(ResourcesHolder.EditAndCreate <EmployeeCreateResource, EmployeeUpdateResource, EmployeeResource>(u => u.ManagerId = managerId).Value);
 }
Пример #8
0
        public void TestDeliveryInvalidToHour()
        {
            var response = ResourcesHolder.EditAndCreate <DeliveryWindowCreateResource, DeliveryWindowResource>(d => { d.ToHour = 1; d.ToHour = 0; });

            AssertBadRequestReason(response, BadRequestReasonExtended.InvalidToHour);
        }