Exemplo n.º 1
0
 private void ExecuteMethodInfoScenario <T>(Expression <Action <T> > lambdaExpression)
 {
     using (FaultScope fs = CreateFaultScope(GetTargetMethodBase(lambdaExpression.Body)))
     {
         lambdaExpression.Compile()(default(T));
     }
 }
Exemplo n.º 2
0
 public void TestGenericMethodIsGeneric()
 {
     // Note that 'int' and 'string' are different types. Fault injection looks at the generic types.
     using (FaultScope fs = CreateFaultScope(((Action <int>)TargetMethodOneGenericParam <int>).Method))
     {
         TargetMethodOneGenericParam <string>("");
     }
 }
Exemplo n.º 3
0
 public void TestGenericClassMethodIsGeneric()
 {
     // Note that 'int' and 'string' are different types. Fault injection looks at the generic types.
     using (FaultScope fs = CreateFaultScope(typeof(TargetNestedClassGeneric <int>).GetMethod("TargetMethod")))
     {
         new TargetNestedClassGeneric <string>(false).TargetMethod();
     }
 }
Exemplo n.º 4
0
 public void TestGenericClassConstructorIsGeneric()
 {
     // This is currently unsupported. If it is fixed, then remove the Assert.Throws.
     Assert.Throws <FaultInjectionException>(() =>
     {
         // Note that 'int' and 'string' are different types. Fault injection looks at the generic types.
         using (FaultScope fs = CreateFaultScope(typeof(TargetNestedClassGeneric <int>).GetConstructor(new Type[] { typeof(bool) })))
         {
             new TargetNestedClassGeneric <string>(true);
         }
     });
 }
        public void TestTrapPerformanceWithFaultScope()
        {
            TimeSpan NoTrap = MeasurePerformance(PerformanceActionNoTrap);

            TimeSpan  WithFaultScope;
            FaultRule faultRule = new FaultRule("Microsoft.Test.AcceptanceTests.FaultInjection.PerformanceTests.PerformanceActionWithTrap()",
                                                BuiltInConditions.TriggerOnEveryCall,
                                                BuiltInFaults.ReturnFault());

            using (FaultScope fs = new FaultScope(faultRule))
            {
                WithFaultScope = MeasurePerformance(PerformanceActionWithTrap);
            }

            // We allow it to be 150x slower.
            // BUG: This test is unstable -- in some cases the perf difference is as high as the following:
            //   Time with no trap: 00:00:00.0042113; Time with trap in fault scope: 00:00:00.7645935
            // so we are disabling the assert for now.
            if (WithFaultScope.Ticks >= NoTrap.Ticks * 150)
            {
                // Assert.Null(string.Format("Time with no trap: {0}; Time with trap in fault scope: {1}", NoTrap, WithFaultScope));
            }
        }