Exemple #1
0
        public void OverflowTestMethod()
        {
            DelegateExample _newInstance = new DelegateExample();

            _newInstance.PerformCalculationVar = _newInstance.PerformSumMethod;
            int _result = _newInstance.PerformCalculationVar(int.MaxValue, int.MaxValue);
        }
Exemple #2
0
        public void SumTestMethod()
        {
            DelegateExample _newInstance = new DelegateExample();

            _newInstance.PerformCalculationVar = _newInstance.PerformSumMethod;
            Assert.AreEqual <int>(_newInstance.PerformSumMethod(0, int.MaxValue), _newInstance.PerformCalculationVar(0, int.MaxValue));
            Assert.AreEqual <int>(_newInstance.PerformSumMethod(int.MinValue, int.MaxValue), _newInstance.PerformCalculationVar(int.MinValue, int.MaxValue));
        }
Exemple #3
0
        public void MulticastTestMethod()
        {
            DelegateExample _newInstance = new DelegateExample();

            _newInstance.PerformCalculationVar = _newInstance.PerformSumMethod;
            //Multicast #1
            _newInstance.PerformCalculationVar = new DelegateExample.PerformCalculation(_newInstance.PerformSumMethod) + new DelegateExample.PerformCalculation(DelegateExample.PerformSubtractMethod);
            //Multicast #1
            _newInstance.PerformCalculationVar  = new DelegateExample.PerformCalculation(PerformSumMethod);
            _newInstance.PerformCalculationVar += new DelegateExample.PerformCalculation(DelegateExample.PerformSubtractMethod);
            Assert.AreEqual <int>(-1, _newInstance.PerformCalculationMethod(1, 2));
        }