protected void Button1_Click(object sender, EventArgs e)
        {
            var customer = new Customer();
            var result = customer.CalculatePercentOfGoalSteps(this.TextBox1.Text, this.TextBox2.Text);

            Label1.Text = "You reached " + result + "% of your goal!";
        }
예제 #2
0
        private void btnCalculate_Click(object sender, EventArgs e)
        {
            var customer = new Customer();

            var result = customer.CalculatePercentOfGoalSteps(this.txtTowardsGoal.Text,
                this.txtStepsToday.Text);

            lblResult.Text = "You reached " + result + "% of your goal!!!";
        }
        public void CalculatePercentOfGoalStepsTestGoalIsNull()
        {
            // -- Arrange
            var customer = new Customer();
            string goalSteps = null;
            string actualSteps = "2000";

            // -- Actual
            var actual = customer.CalculatePercentOfGoalSteps(goalSteps, actualSteps);

            // -- Assert
        }
예제 #4
0
        public void CalculatePercentOfGoalStepsTestValidActualIsZero()
        {
            //-- Arrange
            var customer = new Customer();
            string goalSteps = "5000";
            string actualSteps = "0";
            decimal expected = 0M;

            //-- Act
            var actual = customer.CalculatePercentOfGoalSteps(goalSteps, actualSteps);

            //-- Assert
            Assert.AreEqual(expected, actual);
        }
        private void CalculateButton_Click(object sender, EventArgs e)
        {
            var customer = new Customer();

            try
            {
                var result = customer.CalculatePercentOfGoalSteps(GoalTextBox.Text, StepsTextBox.Text);
                ResultLabel.Text = "You reached " + result + "% of your goal!";
            }
            catch (ArgumentException ex)
            {
                MessageBox.Show("Your entry was not valid: " + ex.Message);
                ResultLabel.Text = string.Empty;

                // Don't want to have the exception thrown out, else it will still be handled by global exception handler
                //throw;
            }
        }
        public void CalculatePercentOfGoalStepsTestGoalIsNotNumeric()
        {
            // -- Arrange
            var customer = new Customer();
            string goalSteps = "one";
            string actualSteps = "2000";

            // -- Actual
            try
            {
                var actual = customer.CalculatePercentOfGoalSteps(goalSteps, actualSteps);
            }
            catch (Exception ex)
            {
                Assert.AreEqual("Goal must be numeric", ex.Message);
                throw;
            }
            // -- Assert
        }