Exemple #1
0
        public void TSTestAddTicker()
        {
            bool   expected = true;
            bool   result   = true;
            int    num      = 5;
            Ticker tick     = new Ticker(4, 10);

            TickerSet tS = new TickerSet(num, "Set Name");

            for (int i = 0; i < num; i++)
            {
                if (!tS.addTicker(tick))
                {
                    result = false;
                }
                ;
            }

            Assert.AreEqual(expected, result);
        }
Exemple #2
0
        private void Add(object sender, RoutedEventArgs e)
        {
            if (cTS == null)
            {
                errorMessage("Slot is empty");
                return;
            }
            if (cTS.getName() == empty)
            {
                errorMessage("Slot is empty");
                return;
            }
            int amount, max, start;
            try
            {
                amount = Int32.Parse(amountRoll.Text);//Try to covert string to int for amount
            }
            catch
            {
                errorMessage("Amount is an illegal input");
                return;
            }
            if (amount <= 0)
            {
                errorMessage("Amount is less than or equal to 0 which is an illegal input");
                return;
            }

            try
            {
                max = Int32.Parse(maxNum.Text);//Try to covert string to int for max
            }
            catch
            {
                errorMessage("Max number is an illegal input");
                return;
            }
            if (max <= 0)
            {
                errorMessage("Max number is less than or equal to 0 which is an illegal input");
                return;
            }

            try
            {
                start = Int32.Parse(startNum.Text);//Try to covert string to int for start
            }
            catch
            {
                errorMessage("Starting number is an illegal input");
                return;
            }

            for (int i = 0; i < amount; i++)//Loop for each number in amout
            {
                if (cTS.size() >= size)//End loop if size of the current ticker set is greater the max size
                {
                    break;
                }

                common.Ticker tick = new common.Ticker(max, start);//Create ticker
                cTS.addTicker(tick);//Add ticker
                cTS.getTicker(i);//Get ticker
            }
            display();
            amountRoll.Text = "";
            maxNum.Text = "";
            startNum.Text = "";
            errorMessage("");
            memoryName();
            
        }