示例#1
0
 /// <summary>
 /// Setups the target for mocking all static calls.
 /// </summary>
 /// <param name="targetType">Target type</param>
 /// <param name="behavior">Specifies behavior of the mock. Default is <see cref="Behavior.RecursiveLoose"/></param>
 /// <param name="staticConstructor">Defines the behavior of the static constructor</param>
 public static void SetupStatic(Type targetType, Behavior behavior, StaticConstructor staticConstructor)
 {
     ProfilerInterceptor.GuardInternal(() =>
     {
         MockingContext.CurrentRepository.InterceptStatics(targetType, behavior, staticConstructor == StaticConstructor.Mocked);
     });
 }
示例#2
0
 /// <summary>
 /// Setups the target for mocking all static calls.
 /// </summary>
 /// <param name="staticType">Static type</param>
 /// <param name="staticConstructor">Defines the behavior of the static constructor</param>
 public static void SetupStatic(Type staticType, StaticConstructor staticConstructor)
 {
     ProfilerInterceptor.GuardInternal(() =>
     {
         MockingContext.CurrentRepository.InterceptStatics(staticType, null, staticConstructor == StaticConstructor.Mocked);
     });
 }
示例#3
0
 /// <summary>
 /// Setups the target for mocking all static calls.
 /// </summary>
 /// <param name="staticType">Static type</param>
 /// <param name="staticConstructor">Defines the behavior of the static constructor</param>
 public static void SetupStatic(Type staticType, StaticConstructor staticConstructor)
 {
     ProfilerInterceptor.GuardInternal(() =>
     {
         MockCreationSettings settings = MockCreationSettings.GetSettings();
         MockingContext.CurrentRepository.InterceptStatics(staticType, settings, staticConstructor == StaticConstructor.Mocked);
     });
 }
示例#4
0
        public void StaticConstructor_Success()
        {
            var original = new StaticConstructor("original");
            var remute   = new Remute();
            var actual   = remute.With(original, x => x.Property1, "updated value");

            Assert.AreEqual("updated value", actual.Property1);
            Assert.AreEqual("original", original.Property1);
            Assert.AreNotSame(original, actual);
        }
示例#5
0
        static void printStatic()
        {
            var sc1 = new StaticConstructor();
            var sc2 = new StaticConstructor();
            var sc3 = new StaticConstructor();
            var sc4 = new StaticConstructor();
            var sc5 = new StaticConstructor();
            var sc6 = new StaticConstructor();
            var sc7 = new StaticConstructor();

            StaticConstructor.DisplayCounter();
        }
示例#6
0
 public string CallStaticConstructor(Translators.MethodTranslateContext methodContext)
 {
     if (methodContext.MethodInfo == StaticConstructor)
     {
         return("");
     }
     if (!methodContext.StaticReference.Contains(this))
     {
         methodContext.StaticReference.Add(this);
         if (StaticConstructor != null)
         {
             return($"{StaticConstructor.CXXMethodCallName(this)}();");
         }
     }
     return("");
 }
示例#7
0
 public ReadOnlyStaticConstructor(StaticConstructor staticConstructor)
 {
     body = new ReadOnlyMethodBody(staticConstructor.Body);
 }