Esempio n. 1
0
 public void AddWithDifferentArguments()
 {
     _calculator = new Calculator();
     _calcProxy = new CalcProxy(new Validator(-10, 10), _calculator);
     int result = _calcProxy.BinaryOperation(_calculator.Add, 2, 5);
     Assert.AreEqual(7, result);
 }
Esempio n. 2
0
        public void Substract()
        {
            _calculator = new Calculator();
            _calcProxy = new CalcProxy(new Validator(-10, 10), _calculator);
            int result = _calcProxy.BinaryOperation(_calculator.Substract, 5, 3);

            Assert.AreEqual(2, result);
        }
Esempio n. 3
0
        public void Add()
        {
            _calculator = new Calculator();
            _calcProxy = new CalcProxy(new Validator(-10, 10), _calculator);
            int result = _calcProxy.BinaryOperation(_calculator.Add, 5, 2);

            Assert.AreEqual(7, result);
        }
Esempio n. 4
0
        public void ArgumentsExceedLimitsInverse()
        {
            _calculator = new Calculator();
            CalcProxy calcProxyWithLimits = new CalcProxy(new Validator(-10, 10), _calculator);
            try
            {
                calcProxyWithLimits.BinaryOperation(_calculator.Add, -30, -50);
                Assert.Fail("This should fail as arguments exceed both limits");
            }
            catch (OverflowException)
            {

                // Ok, this works
            }
        }
Esempio n. 5
0
 public override int Resolve(int a, int b)
 {
     return(CalcProxy.BinaryOperation(CalcProxy.Calculator.Multiply, a, b));
 }
Esempio n. 6
0
        public void ValidateResultExceedingLowerLimit()
        {
            _calculator = new Calculator();
            CalcProxy calcProxyWithLimits = new CalcProxy(new Validator(-10, 10), _calculator);
            try
            {
                calcProxyWithLimits.BinaryOperation(_calculator.Add, -20, -1);
                Assert.Fail("This should fail as result exceed upper limit");
            }
            catch (OverflowException)
            {

                // Ok, this works
            }
        }
Esempio n. 7
0
 public void SubstractReturningNegative()
 {
     _calculator = new Calculator();
     _calcProxy = new CalcProxy(new Validator(-10, 10), _calculator);
     int result = _calcProxy.BinaryOperation(_calculator.Substract, 3, 5);
     Assert.AreEqual(-2, result);
 }
Esempio n. 8
0
 public override int Resolve(int a, int b)
 {
     return(CalcProxy.BinaryOperation(CalcProxy.Calculator.Substract, a, b));
 }