public void CanAddMultiplePoliciesToBagAndRetrieveThem() { PolicyList list = new PolicyList(); FakePolicy policy1 = new FakePolicy(); FakePolicy policy2 = new FakePolicy(); list.Set <IBuilderPolicy>(policy1, "1"); list.Set <IBuilderPolicy>(policy2, "2"); Assert.AreSame(policy1, list.Get <IBuilderPolicy>("1")); Assert.AreSame(policy2, list.Get <IBuilderPolicy>("2")); }
public void CanAddMultiplePoliciesToBagAndRetrieveThem() { PolicyList list = new PolicyList(); MockPolicy policy1 = new MockPolicy(); MockPolicy policy2 = new MockPolicy(); list.Set<IBuilderPolicy>(policy1, typeof(object), "1"); list.Set<IBuilderPolicy>(policy2, typeof(string), "2"); Assert.AreSame(policy1, list.Get<IBuilderPolicy>(typeof(object), "1")); Assert.AreSame(policy2, list.Get<IBuilderPolicy>(typeof(string), "2")); }
public void CanAddMultiplePoliciesToBagAndRetrieveThem() { PolicyList list = new PolicyList(); MockPolicy policy1 = new MockPolicy(); MockPolicy policy2 = new MockPolicy(); list.Set <IBuilderPolicy>(policy1, typeof(object), "1"); list.Set <IBuilderPolicy>(policy2, typeof(string), "2"); Assert.AreSame(policy1, list.Get <IBuilderPolicy>(typeof(object), "1")); Assert.AreSame(policy2, list.Get <IBuilderPolicy>(typeof(string), "2")); }
EventBrokerPolicy GetEventBrokerPolicy(Type type) { EventBrokerPolicy policy = (EventBrokerPolicy)policies.Get <IEventBrokerPolicy>(type); if (policy == null) { policy = new EventBrokerPolicy(); policies.Set <IEventBrokerPolicy>(policy, type); } return(policy); }
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")); }
public void CanAddPolicyToBagAndRetrieveIt() { PolicyList list = new PolicyList(); list.Set<IBuilderPolicy>(new MockPolicy(), typeof(object), null); Assert.IsNotNull(list.Get<IBuilderPolicy>(typeof(object), null)); }
public void CanAddPolicyToBagAndRetrieveIt() { PolicyList list = new PolicyList(); list.Set <IBuilderPolicy>(new MockPolicy(), typeof(object), null); Assert.IsNotNull(list.Get <IBuilderPolicy>(typeof(object), null)); }
public void DefaultPolicyUsedWhenSpecificPolicyIsntAvailable() { PolicyList list = new PolicyList(); MockPolicy defaultPolicy = new MockPolicy(); list.SetDefault <IBuilderPolicy>(defaultPolicy); Assert.AreSame(defaultPolicy, list.Get <IBuilderPolicy>(typeof(object), null)); }
public void CanClearDefaultPolicy() { PolicyList list = new PolicyList(); MockPolicy defaultPolicy = new MockPolicy(); list.SetDefault<IBuilderPolicy>(defaultPolicy); list.ClearDefault<IBuilderPolicy>(); Assert.IsNull(list.Get<IBuilderPolicy>(typeof(object), null)); }
public void CanClearPolicy() { PolicyList list = new PolicyList(); MockPolicy policy = new MockPolicy(); list.Set<IBuilderPolicy>(policy, typeof(string), "1"); list.Clear<IBuilderPolicy>(typeof(string), "1"); Assert.IsNull(list.Get<IBuilderPolicy>(typeof(string), "1")); }
public void CanClearPolicy() { PolicyList list = new PolicyList(); FakePolicy policy = new FakePolicy(); list.Set <IBuilderPolicy>(policy, typeof(string)); list.Clear <IBuilderPolicy>(typeof(string)); Assert.IsNull(list.Get <IBuilderPolicy>(typeof(string))); }
public void SetOverwritesExistingPolicy() { PolicyList list = new PolicyList(); MockPolicy policy1 = new MockPolicy(); MockPolicy policy2 = new MockPolicy(); list.Set<IBuilderPolicy>(policy1, typeof(string), "1"); list.Set<IBuilderPolicy>(policy2, typeof(string), "1"); Assert.AreSame(policy2, list.Get<IBuilderPolicy>(typeof(string), "1")); }
public void SetOverwritesExistingPolicy() { PolicyList list = new PolicyList(); MockPolicy policy1 = new MockPolicy(); MockPolicy policy2 = new MockPolicy(); list.Set <IBuilderPolicy>(policy1, typeof(string), "1"); list.Set <IBuilderPolicy>(policy2, typeof(string), "1"); Assert.AreSame(policy2, list.Get <IBuilderPolicy>(typeof(string), "1")); }
public void CanClearDefaultPolicy() { PolicyList list = new PolicyList(); MockPolicy defaultPolicy = new MockPolicy(); list.SetDefault <IBuilderPolicy>(defaultPolicy); list.ClearDefault <IBuilderPolicy>(); Assert.IsNull(list.Get <IBuilderPolicy>(typeof(object), null)); }
public void SpecificPolicyOverridesDefaultPolicy() { PolicyList list = new PolicyList(); MockPolicy defaultPolicy = new MockPolicy(); MockPolicy specificPolicy = new MockPolicy(); list.Set <IBuilderPolicy>(specificPolicy, typeof(object), null); list.SetDefault <IBuilderPolicy>(defaultPolicy); Assert.AreSame(specificPolicy, list.Get <IBuilderPolicy>(typeof(object), null)); }
public void PolicyRegisteredForTypeIsUsedIfKeyIsNotFound() { PolicyList list = new PolicyList(); FakePolicy policyForType = new FakePolicy(); list.Set <IBuilderPolicy>(policyForType, typeof(object)); IBuilderPolicy result = list.Get <IBuilderPolicy>(new NamedTypeBuildKey <object>("name")); Assert.Same(policyForType, result); }
public void CanRegisterGenericPolicyAndRetrieveWithSpecificGenericInstance() { PolicyList list = new PolicyList(); FakePolicy policy = new FakePolicy(); list.Set(policy, typeof(IDummy <>)); FakePolicy result = list.Get <FakePolicy>(typeof(IDummy <int>)); Assert.AreSame(policy, result); }
public void DefaultPolicyUsedWhenSpecificPolicyIsntAvailable() { PolicyList list = new PolicyList(); FakePolicy defaultPolicy = new FakePolicy(); list.SetDefault <IBuilderPolicy>(defaultPolicy); IBuilderPolicy result = list.Get <IBuilderPolicy>(typeof(object)); Assert.AreSame(defaultPolicy, result); }
public void CanAddPolicyToBagAndRetrieveIt() { PolicyList list = new PolicyList(); FakePolicy policy = new FakePolicy(); list.Set <IBuilderPolicy>(policy, typeof(object)); IBuilderPolicy result = list.Get <IBuilderPolicy>(typeof(object)); Assert.AreSame(policy, result); }
public void PolicyRegisteredForOpenGenericTypeUsedIfKeyIsNotFound() { PolicyList list = new PolicyList(); FakePolicy policyForType = new FakePolicy(); list.Set <IBuilderPolicy>(policyForType, typeof(IDummy <>)); IBuilderPolicy result = list.Get <IBuilderPolicy>(new NamedTypeBuildKey <IDummy <object> >("name")); Assert.AreSame(policyForType, result); }
public void CanGetLocalPolicy() { PolicyList innerList = new PolicyList(); PolicyList outerList = new PolicyList(innerList); FakePolicy innerPolicy = new FakePolicy(); innerList.Set(innerPolicy, typeof(object)); FakePolicy result = outerList.Get <FakePolicy>(typeof(object), true); Assert.IsNull(result); }
public void WillUseInnerDefaultPolicyWhenOuterHasNoAnswer() { PolicyList innerList = new PolicyList(); PolicyList outerList = new PolicyList(innerList); FakePolicy policy = new FakePolicy(); innerList.SetDefault(policy); FakePolicy result = outerList.Get <FakePolicy>(typeof(object)); Assert.AreSame(policy, result); }
public void CanClearDefaultPolicy() { PolicyList list = new PolicyList(); FakePolicy defaultPolicy = new FakePolicy(); list.SetDefault <IBuilderPolicy>(defaultPolicy); list.ClearDefault <IBuilderPolicy>(); IBuilderPolicy result = list.Get <IBuilderPolicy>(typeof(object)); Assert.IsNull(result); }
public void SpecificPolicyOverridesDefaultPolicy() { PolicyList list = new PolicyList(); FakePolicy defaultPolicy = new FakePolicy(); FakePolicy specificPolicy = new FakePolicy(); list.Set <IBuilderPolicy>(specificPolicy, typeof(object)); list.SetDefault <IBuilderPolicy>(defaultPolicy); IBuilderPolicy result = list.Get <IBuilderPolicy>(typeof(object)); Assert.AreSame(specificPolicy, result); }
public void SpecificGenericPolicyComesBeforeGenericPolicy() { PolicyList list = new PolicyList(); FakePolicy genericPolicy = new FakePolicy(); FakePolicy specificPolicy = new FakePolicy(); list.Set(genericPolicy, typeof(IDummy <>)); list.Set(specificPolicy, typeof(IDummy <int>)); FakePolicy result = list.Get <FakePolicy>(typeof(IDummy <int>)); Assert.AreSame(specificPolicy, result); }
public void SetOverwritesExistingPolicy() { PolicyList list = new PolicyList(); FakePolicy policy1 = new FakePolicy(); FakePolicy policy2 = new FakePolicy(); list.Set <IBuilderPolicy>(policy1, typeof(string)); list.Set <IBuilderPolicy>(policy2, typeof(string)); IBuilderPolicy result = list.Get <IBuilderPolicy>(typeof(string)); Assert.AreSame(policy2, result); }
public void PolicyForClosedGenericTypeOverridesPolicyForOpenType() { PolicyList list = new PolicyList(); FakePolicy openTypePolicy = new FakePolicy(); FakePolicy closedTypePolicy = new FakePolicy(); list.Set <IBuilderPolicy>(openTypePolicy, typeof(IDummy <>)); list.Set <IBuilderPolicy>(closedTypePolicy, typeof(IDummy <object>)); IBuilderPolicy result = list.Get <IBuilderPolicy>(new NamedTypeBuildKey <IDummy <object> >("name")); Assert.AreSame(closedTypePolicy, result); }
public void SpecificInnerPolicyOverridesDefaultOuterPolicy() { PolicyList innerList = new PolicyList(); PolicyList outerList = new PolicyList(innerList); FakePolicy innerPolicy = new FakePolicy(); FakePolicy outerPolicy = new FakePolicy(); innerList.Set(innerPolicy, typeof(object)); outerList.SetDefault(outerPolicy); FakePolicy result = outerList.Get <FakePolicy>(typeof(object)); Assert.AreSame(innerPolicy, result); }
public void WillAskInnerPolicyListWhenOuterHasNoAnswer() { PolicyList innerList = new PolicyList(); PolicyList outerList = new PolicyList(innerList); FakePolicy policy = new FakePolicy(); innerList.Set(policy, typeof(object)); IPolicyList containingPolicies; FakePolicy result = outerList.Get <FakePolicy>(typeof(object), out containingPolicies); Assert.AreSame(policy, result); Assert.AreSame(innerList, containingPolicies); }
public void OuterPolicyOverridesInnerPolicy() { PolicyList innerList = new PolicyList(); PolicyList outerList = new PolicyList(innerList); FakePolicy innerPolicy = new FakePolicy(); FakePolicy outerPolicy = new FakePolicy(); innerList.Set(innerPolicy, typeof(object)); outerList.Set(outerPolicy, typeof(object)); IPolicyList containingPolicyList; FakePolicy result = outerList.Get <FakePolicy>(typeof(object), out containingPolicyList); Assert.AreSame(outerPolicy, result); Assert.AreSame(outerList, containingPolicyList); }
public void SpecificPolicyOverridesDefaultPolicy() { PolicyList list = new PolicyList(); MockPolicy defaultPolicy = new MockPolicy(); MockPolicy specificPolicy = new MockPolicy(); list.Set<IBuilderPolicy>(specificPolicy, typeof(object), null); list.SetDefault<IBuilderPolicy>(defaultPolicy); Assert.AreSame(specificPolicy, list.Get<IBuilderPolicy>(typeof(object), null)); }
public void DefaultPolicyUsedWhenSpecificPolicyIsntAvailable() { PolicyList list = new PolicyList(); MockPolicy defaultPolicy = new MockPolicy(); list.SetDefault<IBuilderPolicy>(defaultPolicy); Assert.AreSame(defaultPolicy, list.Get<IBuilderPolicy>(typeof(object), null)); }