Exemplo n.º 1
0
        /// <summary>
        /// Adds HTML attributes and styles that need to be rendered.
        /// </summary>
        /// <param name="writer">
        /// A System.Web.UI.HtmlTextWriter that represents the output stream to render
        /// HTML content on the client
        /// </param>
        /// <remarks>
        /// The method overrides the base class to add the attributes necessary to
        /// render the control as as text input.
        /// </remarks>
        protected override void AddAttributesToRender(HtmlTextWriter writer)
        {
            base.AddAttributesToRender(writer);
            // Add attributes necessary to display an text control
            writer.AddAttribute(HtmlTextWriterAttribute.Type, "text");
            writer.AddAttribute(HtmlTextWriterAttribute.Name, UniqueID);
            writer.AddStyleAttribute("text-align", Alignment.ToString());
            // Add user defined attributes to control colour formatting
            writer.AddAttribute("negativeColor", NegativeColor.Name);


            if (PositiveColor != Color.Empty)
            {
                writer.AddAttribute("positiveColor", PositiveColor.Name);
            }
            // Add user defined attributes to control minimum and maximum values
            writer.AddAttribute("minAmount", MinAmount.ToString());
            writer.AddAttribute("maxAmount", MaxAmount.ToString());
            // Add client side event handlers
            string onKeyPress = "EnsureNumeric()";

            if (OnKeyPress != string.Empty)
            {
                onKeyPress += "," + OnKeyPress;
            }
            writer.AddAttribute("onkeypress", onKeyPress);
        }
        public void MinAmountevaluateTest()
        {
            MinAmount min = new MinAmount(15, filter);

            Assert.IsFalse(min.evaluate(list, user));

            min = new MinAmount(5, filter);
            Assert.IsTrue(min.evaluate(list, user));
        }
Exemplo n.º 3
0
        public void checkConsistency()
        {
            int            min = 10, max = 5;
            TrueCondition  trueCondition  = new TrueCondition();
            FalseCondition falseCondition = new FalseCondition();

            Assert.IsFalse(trueCondition.checkConsistent(falseCondition), "1");
            Assert.IsFalse(falseCondition.checkConsistent(trueCondition), "2");

            MinAmount minAmount = new MinAmount(min, new AllProductsFilter());
            MaxAmount maxAmount = new MaxAmount(max, new AllProductsFilter());

            Assert.IsFalse(minAmount.checkConsistent(maxAmount), "3");
            Assert.IsFalse(maxAmount.checkConsistent(minAmount), "4");

            List <IBooleanExpression> list = new List <IBooleanExpression>();

            list.Add(trueCondition);
            list.Add(minAmount);

            Assert.IsFalse(IBooleanExpression.confirmListConsist(falseCondition, list));
            Assert.IsFalse(IBooleanExpression.confirmListConsist(maxAmount, list));

            List <int> list1 = new List <int>();

            list1.Add(1);
            List <int> list2 = new List <int>();

            list2.Add(2);
            ProductListFilter f1         = new ProductListFilter(list1);
            ProductListFilter f2         = new ProductListFilter(list2);
            MinAmount         minAmount2 = new MinAmount(min, f1);
            MaxAmount         maxAmount2 = new MaxAmount(max, f2);

            Assert.IsFalse(maxAmount.checkConsistent(minAmount2));
            Assert.IsTrue(maxAmount2.checkConsistent(minAmount2));
            f2.productIds = list1;
            Assert.IsFalse(maxAmount2.checkConsistent(minAmount2));

            minAmount.amount = max;
            maxAmount.amount = min;
            Assert.IsTrue(minAmount.checkConsistent(maxAmount), "5");
        }
Exemplo n.º 4
0
        private void addDiscountPolicy()
        {
            bridge.Login(getStoreOwner1(), password);
            ItemFilter         filter1 = new AllProductsFilter();
            IBooleanExpression leaf1   = new MinAmount(5, filter1);
            ItemFilter         filter2 = new AllProductsFilter();
            IBooleanExpression leaf2   = new MinAmount(10, filter2);
            IBooleanExpression complex = new XorExpression();

            //we add manually ids for the leaves becuase there is no stub for them at the moment.
            //Not adding these ids will cause the json serializer to falsly think it has a loop (parent and children have the same id -> .Equals() = true)
            leaf2.id = 20;
            leaf1.id = 21;
            complex.addChildren(leaf1, leaf2);
            IOutcome outcome  = new FreeProduct(productId, 1);
            Discount discount = new Discount(complex, outcome);
            string   json     = JsonHandler.SerializeObject(discount);

            policyId = bridge.addDiscountPolicy(storeId, json);
            Assert.IsTrue(policyId >= 0);
        }