Пример #1
0
 public void DecimalValue()
 {
     double value;
       _calculator = new Calc();
       _calculator.Parse("5.5");
       value = _calculator.Result();
       Assert.AreEqual(value, (double)5.5);
 }
Пример #2
0
 public void Testmultipilicationmethod()
 {
     //arrange
         var calc = new Calc();
         var result = calc.Mul(2, 4);
         //Assert
         Assert.AreEqual(8, result);
 }
Пример #3
0
 public void NoOperator()
 {
     double value;
       _calculator =  new Calc();
       _calculator.Parse("5");
       value = _calculator.Result();
       Assert.AreEqual(value, (double)5);
 }
Пример #4
0
 public void NoOperatorMultipleValues()
 {
     double value;
       _calculator = new Calc();
       _calculator.Parse("5");
       _calculator.Parse("5");
      value =  _calculator.Result();
 }
Пример #5
0
 public void Testadditionmethod()
 {
     //arrange
         var calc = new Calc();
         var result = calc.Add(2, 4);
         //Assert
         Assert.AreEqual(6, result);
 }
Пример #6
0
 public void SimpleAddition()
 {
     double value;
       _calculator = new Calc();
       _calculator.ParseString("1+1");
       value = _calculator.Result();
       Assert.AreEqual(value, (double)2);
 }
Пример #7
0
 public void ComplexParen()
 {
     double value;
       _calculator = new Calc();
       _calculator.ParseString("2*(1+1)");
       value = _calculator.Result();
       Assert.AreEqual(value, (double)4);
 }
Пример #8
0
 public void ParseStringWithSimpleParse()
 {
     double value;
       _calculator = new Calc();
       _calculator.ParseString("5 + ");
       _calculator.Parse("5");
       value = _calculator.Result();
       Assert.AreEqual(value, (double)10);
 }
Пример #9
0
        public void TestEmptyString()
        {
            //test logic here
            var calc = new Calc();

            var result = calc.EmptyMethod();

            Assert.IsNull(result);
        }
Пример #10
0
        public MainWindow()
        {
            InitializeComponent();
            c = new Calc();
            textBox1.Text = defaultString;

            numberOneBuffer = "";
            numberTwoBuffer = "";
        }
Пример #11
0
 public void ArithmicUnderflow()
 {
     double value;
       _calculator = new Calc();
       _calculator.Parse(double.MinValue.ToString("R"));
       _calculator.Parse("-");
       _calculator.Parse(double.MaxValue.ToString("R"));
       value = _calculator.Result();
 }
Пример #12
0
 public void DivideByZero()
 {
     double value;
       _calculator = new Calc();
       _calculator.Parse("5");
       _calculator.Parse("/");
       _calculator.Parse("0");
       value = _calculator.Result();
 }
Пример #13
0
        static void Main()
        {

            Calc c = new Calc();
            int ans = c.Add(10, 84);
            Console.WriteLine("10 + 84 = {0}", ans);
            Console.ReadLine();

        }
Пример #14
0
 public void SimpleMultiply()
 {
     double value;
       _calculator = new Calc();
       _calculator.Parse("5");
       _calculator.Parse("*");
       _calculator.Parse("5");
       value = _calculator.Result();
       Assert.AreEqual(value, (double)25);
 }
Пример #15
0
 public void SimpleDivision()
 {
     double value;
       _calculator = new Calc();
       _calculator.Parse("5");
       _calculator.Parse("/");
       _calculator.Parse("5");
       value = _calculator.Result();
       Assert.AreEqual(value, (double)1);
 }
Пример #16
0
 public void SimpleSubtraction()
 {
     double value;
       _calculator = new Calc();
       _calculator.Parse("5");
       _calculator.Parse("-");
       _calculator.Parse("5");
       value = _calculator.Result();
       Assert.AreEqual(value, (double)0);
 }
Пример #17
0
 public void SimpleExponent()
 {
     double value;
       _calculator = new Calc();
       _calculator.Parse("2");
       _calculator.Parse("^");
       _calculator.Parse("2");
       value = _calculator.Result();
       Assert.AreEqual(value, (double)4);
 }
Пример #18
0
 public void OperatorParsing()
 {
     double value;
       _calculator = new Calc();
       _calculator.Parse("5");
       _calculator.Parse("+");
       _calculator.Parse("5");
       value = _calculator.Result();
       Assert.AreEqual(value, (double)10);
 }
Пример #19
0
        public void TestAdditionMethod()
        {
            //arranges the method
            var calc = new Calc();

            //shows the action
            var result = calc.Add(2, 4);

            //Assert
            Assert.AreEqual(6, result);
        }
Пример #20
0
        public void TestDivideMethod()
        {
            //arranges the method
            var calc = new Calc();

            //shows the action
            var result = calc.Div(9, 3);

            //asserts whether the correct answer is the result
            Assert.AreEqual(3, result);
        }
Пример #21
0
        public void TestMultiplymethod()
        {
            //arranges the method
            var calc = new Calc();

            //shows the action
            var result = calc.Mul(2, 4);

            //Assert
            Assert.AreEqual(8, result);
        }
Пример #22
0
        public void TestSubtractMethod()
        {
            //arranges the method
            var calc = new Calc();

            //shows the action
            var result = calc.Sub(20, 5);

            //assert
            Assert.AreEqual(15, result);
        }
Пример #23
0
 public void ComplexMultiply()
 {
     double value;
       double expected = 0;
       _calculator = new Calc();
       _calculator.Parse("0");
       for (double i = 1.5486154; i < 10; i++)
       {
     _calculator.Parse("*");
     expected = expected * i;
     _calculator.Parse(i.ToString());
       }
       value = _calculator.Result();
       Assert.AreEqual(value, expected);
 }
Пример #24
0
 public void ComplexSubtraction()
 {
     double value;
       double expected = 0;
       _calculator = new Calc();
       _calculator.Parse("0");
       for (double i = 1.5; i < 100; i++)
       {
     _calculator.Parse("-");
     expected = expected - i;
     _calculator.Parse(i.ToString());
       }
       value = _calculator.Result();
       Assert.AreEqual(value, expected);
 }
Пример #25
0
        static void Main(string[] args)
        {
            Calc _calculator = new Calc();
              string equation;
              double lastResult = 0;

              while (true)
              {
            Console.WriteLine("Input your equation.");
            equation = Console.ReadLine().Trim();
            if (!_calculator.Operators.ContainsKey(equation[0]))
              _calculator.Clear();
            _calculator.ParseString(equation);
            lastResult = _calculator.Result();
            Console.WriteLine("= " + lastResult.ToString());
              }
        }
Пример #26
0
 public void NoOperatorParseString()
 {
     _calculator = new Calc();
       _calculator.ParseString("5 5");
       _calculator.Result();
 }
Пример #27
0
 public MainWindow()
 {
     InitializeComponent();
     Calculate   = new Calc();
     DataContext = Calculate;
 }
Пример #28
0
 public void Setup()
 {
     uut = new Calc();
 }
Пример #29
0
 public MainWindow()
 {
     InitializeComponent();
     calculator = new Calc();
 }
Пример #30
0
 public Append(Calc c)
 {
     this.c = c;
 }
Пример #31
0
 public Calculate(Calc c)
 {
     this.c = c;
 }
Пример #32
0
 public Operator(Calc c)
 {
     this.c = c;
 }
Пример #33
0
 public Clear(Calc c)
 {
     this.c = c;
 }
Пример #34
0
 public Backspace(Calc c)
 {
     this.c = c;
 }