public void SetCurrent() { object instance = new object(); SafeContextSingleton <object> singleton = new SafeContextSingleton <object> ("test", delegate { return(new object()); }); Assert.That(singleton.Current, Is.Not.SameAs(instance)); singleton.SetCurrent(instance); Assert.That(singleton.Current, Is.SameAs(instance)); singleton.SetCurrent(new object()); Assert.That(singleton.Current, Is.Not.SameAs(instance)); }
public static IDisposable EnterMockStorageProviderScope(StorageProvider mock) { var previous = _innerMockStorageProvider.Current; _innerMockStorageProvider.SetCurrent(mock); return(new MockStorageProviderScope(previous)); }
public void UsesSafeContext_WithGivenKey() { object instance = new object(); SafeContextSingleton <object> singleton = new SafeContextSingleton <object> ("test", delegate { return(null); }); singleton.SetCurrent(instance); Assert.That(SafeContext.Instance.GetData("test"), Is.SameAs(instance)); }
public void HasCurrent() { SafeContextSingleton <object> singleton = new SafeContextSingleton <object> ("test", delegate { return(new object()); }); Assert.That(singleton.HasCurrent, Is.False); Dev.Null = singleton.Current; Assert.That(singleton.HasCurrent, Is.True); singleton.SetCurrent(null); Assert.That(singleton.HasCurrent, Is.False); }
public static void SetCurrent(WxeContext value) { s_context.SetCurrent(value); }
/// <summary> /// Sets the active mixin configuration configuration for the current thread. /// </summary> /// <param name="configuration">The configuration to be set, can be <see langword="null"/>.</param> public static void SetActiveConfiguration(MixinConfiguration configuration) { s_activeConfiguration.SetCurrent(configuration); }
private static void SetActiveScope(ClientTransactionScope scope) { s_scopeSingleton.SetCurrent(scope); }