Esempio n. 1
0
 private void FinallyExecutedOnException(SimpleClass foo)
 {
     try
     {
         throw new Exception();
     }
     catch (Exception)
     {
         // swallow
     }
     finally
     {
         foo.data = 5;
     }
 }
Esempio n. 2
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.");
        }
Esempio n. 3
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);
        }
Esempio n. 4
0
 private void PassByReference(ref SimpleClass parameter)
 {
     parameter.data = 5;
 }