Beispiel #1
0
        /// <summary>
        /// Action after pressing the operation button which requires only one operand
        /// </summary>
        /// <param name="operation">Selected operation</param>
        public void one_operand_btn_click(string operation)
        {
            if (display.Text != "Chyba!")
            {
                try
                {
                    switch (operation)
                    {
                    case "!":
                        if (display.Text.Length != 0)
                        {
                            show_number(Math.Fact(dispString_to_numb(display.Text)));
                            insert_mode = false;
                        }
                        break;

                    default:
                        break;
                    }
                }
                catch (Exception)
                {
                    display.Text = "Chyba!";
                    return;
                }
            }
        }
Beispiel #2
0
        public void FactTest()
        {
            Assert.AreEqual((ulong)720, math.Fact(6));
            Assert.AreEqual((ulong)3628800, math.Fact(10));
            Assert.AreEqual((ulong)1, math.Fact(1));
            Assert.AreEqual((ulong)1, math.Fact(0));

            /// <summary> NaN result</summary>
            string noFailMessage = "No exception message when result was NaN.";

            try
            {
                math.Fact(-1);
                Assert.Fail(noFailMessage);
            }
            catch (Exception)
            {
            }
        }