Ejemplo n.º 1
0
        //private void FillDropdown()
        //{
        //    prods.Add("Vegemite Scroll", "VS5");
        //    prods.Add("Blueberry Muffin", "MB11");
        //    prods.Add("Croissant", "CF");

        //    products.Add("Vegemite Scroll");
        //    products.Add("Blueberry Muffin");
        //    products.Add("Croissant");

        //    comboBox1.DataSource = products;

        //}

        private void button1_Click(object sender, EventArgs e)
        {
            textBox1.Clear();
            List <string> finaloutput = new List <string>();

            IProduct prod = null;

            ProductFactory pf = new ProductFactory();

            if (textBox2.Text != string.Empty)
            {
                finaloutput.Add("Vegemite Scroll");
                finaloutput.Add("-------------");
                prod = pf.GetProduct("VS5");
                var lst = prod.Calculate(Convert.ToInt32(textBox2.Text));
                lst.RemoveAt(lst.Count() - 1);
                finaloutput.AddRange(lst);
                finaloutput.Add("-------------");
            }
            if (textBox3.Text != string.Empty)
            {
                finaloutput.Add("Blackberry Muffin");
                finaloutput.Add("-------------");
                prod = pf.GetProduct("MB11");
                var lst = prod.Calculate(Convert.ToInt32(textBox3.Text));
                lst.RemoveAt(lst.Count() - 1);
                finaloutput.AddRange(lst);
                finaloutput.Add("-------------");
            }
            if (textBox4.Text != string.Empty)
            {
                finaloutput.Add("Croissant");
                finaloutput.Add("-------------");
                prod = pf.GetProduct("CF");
                var lst = prod.Calculate(Convert.ToInt32(textBox4.Text));
                lst.RemoveAt(lst.Count() - 1);
                finaloutput.AddRange(lst);
            }

            if (finaloutput.Count() == 0)
            {
                textBox1.Text = "Please add the proper quantity as per the packs available";
                return;
            }
            string joinedList = string.Join(Environment.NewLine, finaloutput);

            textBox1.Text = joinedList; //string.Join(Environment.NewLine, textBox1, joinedList);

            if (joinedList == string.Empty)
            {
                textBox1.Text = "Please add the proper quantity as per the packs available";
            }
            //textBox1.Text= prod.Calculate(Convert.ToInt32(textBox2.Text)).ToString();
        }
Ejemplo n.º 2
0
        public void CalculateBlueberryMuffinwithNull()
        {
            var      quantity = 14;
            IProduct prod     = null;

            BakeryProj.ProductFactory pfobj = new ProductFactory();
            prod = pfobj.GetProduct("MB11");
            var result = prod.Calculate(quantity);

            Assert.IsFalse(result.Contains(""));
        }
Ejemplo n.º 3
0
        public void CalculateBlueberryMuffinOutput2()
        {
            var      quantity = 14;
            IProduct prod     = null;

            BakeryProj.ProductFactory pfobj = new ProductFactory();
            prod = pfobj.GetProduct("MB11");
            var result = prod.Calculate(quantity);

            Assert.IsTrue(result.Contains("1 x 8 $24.95"));
        }
        public void calculate_crossaintWithNullInputput()
        {
            var      quantity = 0;
            IProduct prod     = null;

            BakeryProj.ProductFactory pfobj = new ProductFactory();
            prod = pfobj.GetProduct("CF");
            var result = prod.Calculate(quantity);

            Assert.IsFalse(result.Contains(""));
        }
        public void calculate_crossaintoutput2()
        {
            var      quantity = 13;
            IProduct prod     = null;

            BakeryProj.ProductFactory pfobj = new ProductFactory();
            prod = pfobj.GetProduct("CF");
            var result = prod.Calculate(quantity);

            Assert.IsTrue(result.Contains("2 x 5 $9.95"));
        }
Ejemplo n.º 6
0
        public void CalculateVegimiteScrollwithIncorrectValue()
        {
            var      quantity = 14;
            IProduct prod     = null;

            BakeryProj.ProductFactory pfobj = new ProductFactory();
            prod = pfobj.GetProduct("VS5");
            var result = prod.Calculate(quantity);

            Assert.IsFalse(result.Contains("7 x 2 $9.95"));
        }
Ejemplo n.º 7
0
        public void CalculateVegimiteScroll()
        {
            var      quantity = 10;
            IProduct prod     = null;

            BakeryProj.ProductFactory pfobj = new ProductFactory();
            prod = pfobj.GetProduct("VS5");
            var result = prod.Calculate(quantity);

            Assert.IsTrue(result.Contains("2 x 5 $6.99"));
        }