Example #1
0
        IMethodReturn IInterceptionBehavior.Invoke(IMethodInvocation input, GetNextInterceptionBehaviorDelegate getNext)
        {
            ProcessContextEntry();


            var targetType = input.Target.GetType() ?? input.MethodBase.DeclaringType;
            var targetVal  = input.Target;

            var args = new List <object>();

            for (int i = 0; i < input.Arguments.Count; i++)
            {
                args.Add(input.Arguments[i]);
            }

            var entryModel = new InterceptionEntryModel(targetVal, args, input.MethodBase);

            engine.OnEntry(entryModel);
            IMethodReturn result = getNext()(input, getNext);

            targetVal = input.Target;
            if (result.Exception != null)
            {
                var exceptionModel = new InterceptionExceptionModel(targetVal, input.MethodBase, result.Exception);
                engine.OnException(exceptionModel);
            }
            else
            {
                var exitModel = new InterceptionExitModel(targetVal, result.ReturnValue, input.MethodBase);
                engine.OnExit(exitModel);
            }
            ProcessContextExit();

            return(result);
        }
Example #2
0
        public void Processing_Data_Test_All_Constructors()
        {
            var entry           = new InterceptionEntryModel(_instance, _args, GetAttMethodBase());
            var processingModel = new InterceptionProcessingData(entry, new EngineConfiguration());

            Assert.IsTrue(processingModel.MethodAttributes.Count == 1);
            Assert.IsTrue(processingModel.MethodAttributes.Contains(typeof(AutoTestEngine.Attributes.AutoTest)));


            var exit = new InterceptionExitModel(_instance, _returnVal, GetAttMethodBase());

            processingModel = new InterceptionProcessingData(exit, new EngineConfiguration());

            Assert.IsTrue(processingModel.MethodAttributes.Count == 1);
            Assert.IsTrue(processingModel.MethodAttributes.Contains(typeof(AutoTestEngine.Attributes.AutoTest)));

            var exception = new InterceptionExceptionModel(_instance, GetAttMethodBase(), new Exception());

            processingModel = new InterceptionProcessingData(exception, new EngineConfiguration());
        }