コード例 #1
0
 void Calculate(object sender, EventArgs e)
 {
     try
     {
         if (calculateTo.SelectedIndex == -1)
         {
             Alerts.InvalidInput(messageToUser: AppResources.emtpyEquationPickerCalculate);
         }
         else
         {
             if (calculateTo.SelectedIndex == 0)
             {
                 decimal distance = Velocity_VDT.GetDistance(velocityEntry.Text, timeEntry.Text);
                 Result.Text  = string.Format(AppResources.lblResultDistance, distance);
                 showHow.Text = string.Format(AppResources.velocity_VDT_distanceAnswer, distance, velocityEntry.Text, timeEntry.Text);
             }
             else if (calculateTo.SelectedIndex == 1)
             {
                 decimal time = Velocity_VDT.GetTime(velocityEntry.Text, distanceEntry.Text);
                 Result.Text  = string.Format(AppResources.lblResultTime, time);
                 showHow.Text = string.Format(AppResources.velocity_VDT_timeAnswer, time, distanceEntry.Text, velocityEntry.Text);
             }
             else
             {
                 decimal velocity = Velocity_VDT.GetVelocity(distanceEntry.Text, timeEntry.Text);
                 Result.Text  = string.Format(AppResources.lblResultVelocity, velocity);
                 showHow.Text = string.Format(AppResources.velocity_VDT_velocityAnswer, velocity, distanceEntry.Text, timeEntry.Text);
             }
         }
     }
     catch (FormatException j)
     {
         Alerts.InvalidInput(messageToUser: AppResources.errorFormatMessage);
     }
     catch (DivideByZeroException j)
     {
         Alerts.InvalidInput(messageToUser: AppResources.errorDivideByZeroMessage);
     }
     catch (Exception j)
     {
         Alerts.InvalidInput(messageToUser: j.Message);
     }
 }
コード例 #2
0
        public void VDT_Can_Calculate_Time()
        {
            var time = Velocity_VDT.GetTime("10", "100");

            Assert.IsTrue(time == (decimal)10);
        }
コード例 #3
0
        public void VDT_Can_Calculate_Distance()
        {
            var distance = Velocity_VDT.GetDistance("100", "10");

            Assert.IsTrue(distance == (decimal)1000);
        }
コード例 #4
0
        public void VDT_Can_Calculate_Velocity()
        {
            var velocity = Velocity_VDT.GetVelocity("100", "10");

            Assert.IsTrue(velocity == (decimal)10);
        }