Beispiel #1
0
        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"));
        }
Beispiel #2
0
        public void CanAddPolicyToBagAndRetrieveIt()
        {
            PolicyList list = new PolicyList();

            list.Set <IBuilderPolicy>(new MockPolicy(), typeof(object), null);

            Assert.IsNotNull(list.Get <IBuilderPolicy>(typeof(object), null));
        }
Beispiel #3
0
        public void DefaultPolicyUsedWhenSpecificPolicyIsntAvailable()
        {
            PolicyList list          = new PolicyList();
            MockPolicy defaultPolicy = new MockPolicy();

            list.SetDefault <IBuilderPolicy>(defaultPolicy);

            Assert.AreSame(defaultPolicy, list.Get <IBuilderPolicy>(typeof(object), null));
        }
Beispiel #4
0
        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"));
        }
Beispiel #5
0
        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));
        }
Beispiel #6
0
        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"));
        }
Beispiel #7
0
        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));
        }