Beispiel #1
0
        public void call_finally_executed_on_exception()
        {
            // setup the callbacks for GetTracer and FinishTracer
            var getTracerParameters    = DefaultGetTracerImplementation();
            var finishTracerParameters = DefaultFinishTracerImplementation();

            // call the method that will be instrumented
            var parameter = new SimpleClass();

            parameter.data = 1;
            Assert.DoesNotThrow(() => { FinallyExecutedOnException(parameter); }, "Exception should not have been thrown.");

            ValidateTracers(getTracerParameters, finishTracerParameters, "FinallyExecutedOnException", parameter.GetType().ToString(), this, new object[] { parameter }, null, null);

            // validate that the finally clause was executed
            Assert.AreEqual(5, parameter.data, "The finally clause was not executed.");
        }
Beispiel #2
0
        public void call_pass_by_reference()
        {
            // setup the callbacks for GetTracer and FinishTracer
            var getTracerParameters    = DefaultGetTracerImplementation();
            var finishTracerParameters = DefaultFinishTracerImplementation();

            // call the method that will be instrumented
            SimpleClass parameter = new SimpleClass();

            parameter.data = 3;
            Assert.DoesNotThrow(() => { PassByReference(ref parameter); }, "Exception should not have been thrown.");

            ValidateTracers(getTracerParameters, finishTracerParameters, "PassByReference", parameter.GetType().ToString() + "&", this, new object[] { null }, null, null);

            // validate that the function was able to modify the parameter
            Assert.AreEqual(5, parameter.data);
        }