Пример #1
0
        public void EitherOrTest()
        {
            const double expected = 0.98;
            var          actual   = Probablility.EitherOr(0.9, 0.8);

            Assert.AreEqual(expected, actual, 0.0001);
        }
Пример #2
0
        /// <summary>
        /// Using the information entered by the user, performs the relevant calculation
        /// and displays it in the results text box.
        /// </summary>
        /// <param name="operation">The operation to perform with the input.</param>
        private void PerformCalculation(ProbablilityOperation operation)
        {
            double p1, p2;

            if (!IsValidInput(txtProb1.Text, out p1) || !IsValidInput(txtProb2.Text, out p2))
            {
                Log(LogLevel.Info, "Invalid values for probabilities.");
                ClearMainText();
                return;
            }

            switch (operation)
            {
            case ProbablilityOperation.CombinedWith:
                txtResult.Text = Probablility.CombinedWith(p1, p2).ToString("0.#####");
                break;

            case ProbablilityOperation.EitherOr:
                txtResult.Text = Probablility.EitherOr(p1, p2).ToString("0.#####");
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(operation), operation, "Invalid operation.");
            }

            Log(LogLevel.Info, operation + " of " + p1 + " and " + p2 + ": " + txtResult.Text);
        }
Пример #3
0
 public void ValidInputTest2()
 {
     Probablility.EitherOr(0.5, 1.001);
 }