コード例 #1
0
        public void CorrectlyMergedUIProperties()
        {
            string[] props = { "EXECUTE", "transparent", "autoexpand" };
            #region setup

            BasicAction basic = new BasicAction();
            PolicyResponseAction pra = new PolicyResponseAction();
            pra.Action = basic;

            PolicyResponseActionMerger merger = new PolicyResponseActionMerger(pra);

            bool propValue = true;
            for (int i = 0; i < 3; i++)
            {
                //set the property sets up such that the properties have different values
                ActionPropertySet newSet = new ActionPropertySet();
                foreach (string s in props)
                {
                    newSet[s] = new ActionProperty(s, typeof(bool), PropertyDisplayType.Checkbox, propValue, propValue, propValue, false);
                }
                merger.AddActionPropertySet(newSet);
                propValue = !propValue;
            }

            #endregion

            PolicyResponseAction resultPra = merger.MergePra() as PolicyResponseAction;

            // if at least one user override is false then the override is false
            // if at least one visible is true the it should be what ?
            foreach (string s in props)
            {
                Assert.IsFalse((bool)resultPra.InternalProperties[s].Override, "Override should be disallowed for {0}", s);
                Assert.IsTrue((bool)resultPra.InternalProperties[s].Visible, "props should be visible for {0}", s);
            }
            Assert.IsTrue((bool)(resultPra.InternalProperties["EXECUTE"].Value), "EXECUTE property should be true if at least one set specifies true");
            Assert.IsFalse((bool)(resultPra.InternalProperties["transparent"].Value), "transparent property should be false if at least one set specifies false");
            Assert.IsTrue((bool)resultPra.InternalProperties["autoexpand"].Value, "autoexpand property value should be true");
        }
コード例 #2
0
        public void TestMergePra()
        {
            BasicAction basic = new BasicAction();
            ActionPropertySet set = new ActionPropertySet();
            set.Add("Test", new ActionProperty("Test","test"));
            basic.PropertySet = set;
            PolicyResponseAction pra = new PolicyResponseAction();
            pra.Action = basic;
            pra.InternalProperties = set;
            
            PolicyResponseActionMerger merger = new PolicyResponseActionMerger(pra);
            set["Test"].Value = "test2";
            merger.AddActionPropertySet(set);

            PolicyResponseAction praNew = (PolicyResponseAction) merger.MergePra();
            Assert.AreEqual(praNew.InternalProperties["ThisWasMerged"].Value.ToString(), "sisterhood", "Property value should be - sisterhood");
            Assert.AreEqual(2, basic.CountMerged, "Expected 2 property sets to be sent to the action");
            Assert.AreNotEqual(praNew, pra, "Expected a new {0} back", praNew.GetType().ToString());
        }
コード例 #3
0
        public void EnsureSystemPropertiesArePreserved()
        {
            #region setup
            string[] systemProperties = { "CurrentUser", "Date", "RecipientList", "RunAt", "FileType" };

            BasicAction basic = new BasicAction();
            ActionPropertySet set = new ActionPropertySet();
            set["Add"] = new ActionProperty("TEST", "test");
            basic.PropertySet = set;
            PolicyResponseAction pra = new PolicyResponseAction();
            pra.Action = basic;
            pra.InternalProperties = set;

            set["Add"].Value = "test2";
            foreach (string s in systemProperties)
            {
                set.SystemProperties[s] = new ActionProperty(s, s);
            }

            PolicyResponseActionMerger merger = new PolicyResponseActionMerger(pra);

            merger.AddActionPropertySet(set);
            #endregion

            //execute
            pra = merger.MergePra() as PolicyResponseAction;

            //verify
            foreach (string s in systemProperties)
            {
                SortedList<string, IActionProperty> aps = pra.InternalProperties.SystemProperties;
                Assert.IsTrue(aps.ContainsKey(s) && aps[s].Value.ToString() == s, "System property {0} has been modified after merge", s);
            }
        }