/// <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); }); }
/// <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); }); }
/// <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); }); }
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); }
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(); }
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(""); }
public ReadOnlyStaticConstructor(StaticConstructor staticConstructor) { body = new ReadOnlyMethodBody(staticConstructor.Body); }