public void CanClearAllPolicies() { PolicyList list = new PolicyList(); list.Set<IBuilderPolicy>(new MockPolicy(), typeof(object), null); list.Set<IBuilderPolicy>(new MockPolicy(), typeof(object), "1"); list.ClearAll(); Assert.AreEqual(0, list.Count); }
public void CanClearAllPolicies() { PolicyList list = new PolicyList(); list.Set <IBuilderPolicy>(new FakePolicy(), "1"); list.Set <IBuilderPolicy>(new FakePolicy(), "2"); list.ClearAll(); Assert.AreEqual(0, list.Count); }
public void CanClearAllPolicies() { PolicyList list = new PolicyList(); list.Set <IBuilderPolicy>(new MockPolicy(), typeof(object), null); list.Set <IBuilderPolicy>(new MockPolicy(), typeof(object), "1"); list.ClearAll(); Assert.AreEqual(0, list.Count); }
public void CanClearAllPolicies() { PolicyList list = new PolicyList(); list.Set <IBuilderPolicy>(new FakePolicy(), "1"); list.Set <IBuilderPolicy>(new FakePolicy(), "2"); Assert.IsNotNull(list.Get <IBuilderPolicy>("1")); Assert.IsNotNull(list.Get <IBuilderPolicy>("2")); list.ClearAll(); Assert.IsNull(list.Get <IBuilderPolicy>("1")); Assert.IsNull(list.Get <IBuilderPolicy>("2")); }
/// <summary> /// Remove all installed extensions from this container. /// </summary> /// <remarks> /// <para> /// This method removes all extensions from the container, including the default ones /// that implement the out-of-the-box behavior. After this method, if you want to use /// the container again you will need to either readd the default extensions or replace /// them with your own. /// </para> /// <para> /// The registered instances and singletons that have already been set up in this container /// do not get removed. /// </para> /// </remarks> /// <returns>The <see cref="UnityContainer"/> object that this method was called on (this in C#, Me in Visual Basic).</returns> public override IUnityContainer RemoveAllExtensions() { List <UnityContainerExtension> toRemove = new List <UnityContainerExtension>(extensions); toRemove.Reverse(); foreach (UnityContainerExtension extension in toRemove) { extension.Remove(); IDisposable disposable = extension as IDisposable; if (disposable != null) { disposable.Dispose(); } } extensions.Clear(); // Reset our policies, strategies, and registered names to reset to "zero" strategies.Clear(); policies.ClearAll(); registeredNames.Clear(); return(this); }