Beispiel #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);
 }
 public void SetUp()
 {
     _calculator = new Calculator();
     _validator = new Validator(-10, 10);
     _calcProxy = new CalcProxy(_validator, _calculator);
     _calcProxyWithLimits = new CalcProxy(new Validator(-10, 10), _calculator);
 }
Beispiel #3
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);
        }
Beispiel #4
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);
        }
Beispiel #5
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
            }
        }
 public void TestInitialize()
 {
     _calculator = new Calculator();
     _coordinator = new CalcProxy(new Validator(-100, 100), _calculator);
     _coordinatorWithLimits = new CalcProxy(new Validator(-10, 10), _calculator);
 }
Beispiel #7
0
 public override int Resolve(int a, int b)
 {
     return(CalcProxy.BinaryOperation(CalcProxy.Calculator.Multiply, a, b));
 }
Beispiel #8
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
            }
        }
Beispiel #9
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);
 }
Beispiel #10
0
 public override int Resolve(int a, int b)
 {
     return(CalcProxy.BinaryOperation(CalcProxy.Calculator.Substract, a, b));
 }