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

            var result = calc.EmptyMethod();

            Assert.IsNull(result);
        }
Esempio n. 10
0
        public MainWindow()
        {
            InitializeComponent();
            c = new Calc();
            textBox1.Text = defaultString;

            numberOneBuffer = "";
            numberTwoBuffer = "";
        }
Esempio n. 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();
 }
Esempio n. 12
0
 public void DivideByZero()
 {
     double value;
       _calculator = new Calc();
       _calculator.Parse("5");
       _calculator.Parse("/");
       _calculator.Parse("0");
       value = _calculator.Result();
 }
Esempio n. 13
0
        static void Main()
        {

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

        }
Esempio n. 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);
 }
Esempio n. 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);
 }
Esempio n. 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);
 }
Esempio n. 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);
 }
Esempio n. 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);
 }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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);
 }
Esempio n. 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);
 }
Esempio n. 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());
              }
        }
Esempio n. 26
0
 public void NoOperatorParseString()
 {
     _calculator = new Calc();
       _calculator.ParseString("5 5");
       _calculator.Result();
 }
Esempio n. 27
0
 public MainWindow()
 {
     InitializeComponent();
     Calculate   = new Calc();
     DataContext = Calculate;
 }
Esempio n. 28
0
 public void Setup()
 {
     uut = new Calc();
 }
 public MainWindow()
 {
     InitializeComponent();
     calculator = new Calc();
 }
Esempio n. 30
0
 public Append(Calc c)
 {
     this.c = c;
 }
Esempio n. 31
0
 public Calculate(Calc c)
 {
     this.c = c;
 }
Esempio n. 32
0
 public Operator(Calc c)
 {
     this.c = c;
 }
Esempio n. 33
0
 public Clear(Calc c)
 {
     this.c = c;
 }
Esempio n. 34
0
 public Backspace(Calc c)
 {
     this.c = c;
 }