Пример #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
        public void CombinedWithTest()
        {
            const double expected = 0.72;
            var          actual   = Probablility.CombinedWith(0.9, 0.8);

            Assert.AreEqual(expected, actual, 0.0001);
        }
Пример #3
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);
        }
Пример #4
0
 public void ValidInputTest3()
 {
     Probablility.CombinedWith(-0.000001, 0.5);
 }
Пример #5
0
 public void ValidInputTest2()
 {
     Probablility.EitherOr(0.5, 1.001);
 }
Пример #6
0
 public void ValidInputTest1()
 {
     Probablility.CombinedWith(0.5, -1);
 }