Ejemplo n.º 1
0
        public void TestAddConditionGroupWithChildren()
        {
            IPolicyLanguage language = new PolicyLanguage(new Guid("{E8B22533-98EB-4D00-BDE4-406DC3E1858B}"), "en");

            XMLPolicyCatalogueStore catalogueStore = XMLPolicyCatalogueStore.Instance;
            catalogueStore.Reset();
            PolicyCatalogue policyCatalogue = new PolicyCatalogue(new Guid("{AB5E2A43-01FB-4AA6-98FC-8F74BB0621CA}"), language.Identifier, new TranslateableLanguageItem("{B5C31A66-1B39-4CA7-BF02-AF271B5864F7}"), catalogueStore);
            catalogueStore.AddPolicyCatalogue(policyCatalogue);

            PolicySetObserver policySetObserver = new PolicySetObserver(policyCatalogue);

            Assert.AreEqual(0, policyCatalogue.Conditions.Count);
            Assert.AreEqual(0, policyCatalogue.ConditionGroups.Count);

            IConditionGroup conditionGroup = new ConditionGroup(new Guid("{5823E98A-1F4D-44B9-BC0E-A538BD2C9262}"), new TranslateableLanguageItem("Test group"), ConditionLogic.AND, false);
            IConditionGroup subConditionGroup = new ConditionGroup(new Guid("{B87DF614-2400-4C1F-BEA8-3C2EB3964EAE}"), new TranslateableLanguageItem("Test sub group"), ConditionLogic.AND, false);
            ICondition condition = new Condition(new Guid("{98C73BC3-3E20-403C-8023-C91E2818355F}"), "TestClass", new TranslateableLanguageItem("This is a test"), OperatorType.Equals);
            subConditionGroup.Conditions.Add(condition);
            conditionGroup.Conditions.Add(subConditionGroup);

            policySetObserver.AddObject(conditionGroup);

            Assert.AreEqual(1, policyCatalogue.Conditions.Count);
            Assert.AreEqual(2, policyCatalogue.ConditionGroups.Count);
        }
Ejemplo n.º 2
0
        public void TestAddConditionGroup()
        {
            IPolicyLanguage language = new PolicyLanguage(new Guid("{E8B22533-98EB-4D00-BDE4-406DC3E1858B}"), "en");

            XMLPolicyCatalogueStore catalogueStore = XMLPolicyCatalogueStore.Instance;
            catalogueStore.Reset();
            PolicyCatalogue policyCatalogue = new PolicyCatalogue(new Guid("{AB5E2A43-01FB-4AA6-98FC-8F74BB0621CA}"), language.Identifier, new TranslateableLanguageItem("{B5C31A66-1B39-4CA7-BF02-AF271B5864F7}"), catalogueStore);
            catalogueStore.AddPolicyCatalogue(policyCatalogue);

            PolicySetObserver policySetObserver = new PolicySetObserver(policyCatalogue);

            Assert.AreEqual(0, policyCatalogue.ConditionGroups.Count);

            IConditionGroup conditionGroup = new ConditionGroup(new Guid("{B87DF614-2400-4C1F-BEA8-3C2EB3964EAE}"), new TranslateableLanguageItem("Test group"), ConditionLogic.AND, false);
            policySetObserver.AddObject(conditionGroup);

            Assert.AreEqual(1, policyCatalogue.ConditionGroups.Count);
        }
Ejemplo n.º 3
0
        public void TestAddCondition()
        {
            IPolicyLanguage language = new PolicyLanguage(new Guid("{E8B22533-98EB-4D00-BDE4-406DC3E1858B}"), "en");

            XMLPolicyCatalogueStore catalogueStore = XMLPolicyCatalogueStore.Instance;
            catalogueStore.Reset();
            PolicyCatalogue policyCatalogue = new PolicyCatalogue(new Guid("{AB5E2A43-01FB-4AA6-98FC-8F74BB0621CA}"), language.Identifier, new TranslateableLanguageItem("{B5C31A66-1B39-4CA7-BF02-AF271B5864F7}"), catalogueStore);
            catalogueStore.AddPolicyCatalogue(policyCatalogue);

            PolicySetObserver policySetObserver = new PolicySetObserver(policyCatalogue);

            Assert.AreEqual(0, policyCatalogue.Conditions.Count);

            ICondition condition = new Condition(new Guid("{98C73BC3-3E20-403C-8023-C91E2818355F}"), "TestClass", new TranslateableLanguageItem("This is a test"), OperatorType.Equals);
            policySetObserver.AddObject(condition);

            Assert.AreEqual(1, policyCatalogue.Conditions.Count);
        }
Ejemplo n.º 4
0
        public void TestAddDataElement()
        {
            IPolicyLanguage language = new PolicyLanguage(new Guid("{E8B22533-98EB-4D00-BDE4-406DC3E1858B}"), "en");

            XMLPolicyCatalogueStore catalogueStore = XMLPolicyCatalogueStore.Instance;
            catalogueStore.Reset();
            PolicyCatalogue policyCatalogue = new PolicyCatalogue(new Guid("{AB5E2A43-01FB-4AA6-98FC-8F74BB0621CA}"), language.Identifier, new TranslateableLanguageItem("{B5C31A66-1B39-4CA7-BF02-AF271B5864F7}"), catalogueStore);
            catalogueStore.AddPolicyCatalogue(policyCatalogue);

            PolicySetObserver policySetObserver = new PolicySetObserver(policyCatalogue);

            Assert.AreEqual(0, policyCatalogue.DataElements.Count);

            // Create data elements
            DataMethod dataMethod = new DataMethod("ThisIsATest");
            DataItem parameterDataItem = DataItem.CreateDataItem(new TranslateableLanguageItem("Test data item to the left"), DataType.String, "Lets go dynamo");

            DataElement parameterDataElement = new DataElement(new Guid("{015035B7-1793-464D-AF69-030E9DC7151E}"), new TranslateableLanguageItem("Test parameter data element"), new TranslateableLanguageItem(""), DataType.String, parameterDataItem);
            dataMethod.Parameters.Add(new Parameter("somethingTerrible", parameterDataElement));
            IDataSource dataSource = new DataSource("ThisIsADodgyAssembly.dll", "ItWantsToTakeOverYourComputer", dataMethod);

            DataElement leftDataElement = new DataElement(new Guid("{454672AC-BCED-4DAB-813F-6CF14E6289C5}"), new TranslateableLanguageItem("Test data left"), new TranslateableLanguageItem(""), DataType.Object, dataSource);
            policySetObserver.AddObject(leftDataElement);

            IDataItem dataRightDataItem = DataItem.CreateDataItem(new TranslateableLanguageItem("Test data item to the right"), DataType.String, "This is a test");
            DataElement rightDataElement = new DataElement(new Guid("{4E2F50C5-D310-47A1-AE3A-621F5C77FA68}"), new TranslateableLanguageItem("Test data right"), new TranslateableLanguageItem(""), DataType.String, dataRightDataItem);

            policySetObserver.AddObject(rightDataElement);

            Assert.AreEqual(2, policyCatalogue.DataElements.Count);
        }
Ejemplo n.º 5
0
        public void TestAddChannel()
        {
            IPolicyLanguage language = new PolicyLanguage(new Guid("{E8B22533-98EB-4D00-BDE4-406DC3E1858B}"), "en");

            XMLPolicyCatalogueStore catalogueStore = XMLPolicyCatalogueStore.Instance;
            catalogueStore.Reset();
            PolicyCatalogue policyCatalogue = new PolicyCatalogue(new Guid("{AB5E2A43-01FB-4AA6-98FC-8F74BB0621CA}"), language.Identifier, new TranslateableLanguageItem("{B5C31A66-1B39-4CA7-BF02-AF271B5864F7}"), catalogueStore);
            catalogueStore.AddPolicyCatalogue(policyCatalogue);

            PolicySetObserver policySetObserver = new PolicySetObserver(policyCatalogue);

            Assert.AreEqual(0, policyCatalogue.Channels.Count);

			IPolicyChannel channel = new PolicyChannel(new Guid("{0FE26539-7AAD-46DC-8D5B-9651CC00B9E4}"), new TranslateableLanguageItem("Test channel"), ChannelType.SMTP);
            policySetObserver.AddObject(channel);

            Assert.AreEqual(1, policyCatalogue.Channels.Count);
        }
Ejemplo n.º 6
0
        public void TestAddRoutingPostAddToChannel()
        {
            IPolicyLanguage language = new PolicyLanguage(new Guid("{E8B22533-98EB-4D00-BDE4-406DC3E1858B}"), "en");

            XMLPolicyCatalogueStore catalogueStore = XMLPolicyCatalogueStore.Instance;
            catalogueStore.Reset();
            PolicyCatalogue policyCatalogue = new PolicyCatalogue(new Guid("{AB5E2A43-01FB-4AA6-98FC-8F74BB0621CA}"), language.Identifier, new TranslateableLanguageItem("{B5C31A66-1B39-4CA7-BF02-AF271B5864F7}"), catalogueStore);
            catalogueStore.AddPolicyCatalogue(policyCatalogue);

            PolicySetObserver policySetObserver = new PolicySetObserver(policyCatalogue);

            Assert.AreEqual(0, policyCatalogue.Channels.Count);
            Assert.AreEqual(0, policyCatalogue.RoutingTables.Count);
            Assert.AreEqual(0, policyCatalogue.LocationsCollection.Count);
            Assert.AreEqual(0, policyCatalogue.Locations.Count);

            PolicyChannel channel = new PolicyChannel(new Guid("{0FE26539-7AAD-46DC-8D5B-9651CC00B9E4}"), new TranslateableLanguageItem("Test channel"), ChannelType.SMTP);
            policySetObserver.AddObject(channel);

            IRoutingItemCollection senders = new RoutingItemCollection(new Guid("{441FDCBF-B606-4325-8CD5-E829AD5303B9}"), "Test sources");
            senders.Add(new RoutingItem(new Guid("{D41A47E2-CC13-46FF-BE83-829625792576}"), "James Brown", "*****@*****.**"));
            senders.Add(new RoutingItem(new Guid("{B031DFE9-54E7-482B-8955-18CFB8F06A40}"), "Nat King Cole", "*****@*****.**"));
            IRoutingItemCollection recipients = new RoutingItemCollection(new Guid("{29C44E5C-5405-409F-8513-A99AE246536F}"), "Test destinations");
            recipients.Add(new RoutingItem(new Guid("{9E26C6A2-ABE2-427D-9D78-5B8547ADA8D2}"), "Jet Li", "*****@*****.**"));

            RoutingTable routingTable = new RoutingTable(new Guid("{CDF0252C-3D5D-4AFB-98C2-89CF00FE2175}"), new TranslateableLanguageItem("Test routing table"), ChannelType.SMTP);

            routingTable.Sources.Add(senders);
            routingTable.Destinations.Add(recipients);

            channel.Routing = routingTable;

            IRoutingItemCollection recipients2 = new RoutingItemCollection(new Guid("{4E17A792-0CBC-4362-8A82-A1A7FF3C71B0}"), "More test destinations");
            recipients2.Add(new RoutingItem(new Guid("{98CE8CF9-6CF1-4F32-BE4F-C2D381E6C972}"), "why you", "*****@*****.**"));

            routingTable.Destinations.Add(recipients2);

            Assert.AreEqual(1, policyCatalogue.Channels.Count, "Expected one channel");
            Assert.AreEqual(1, policyCatalogue.RoutingTables.Count, "Expected one routing table");
            Assert.AreEqual(3, policyCatalogue.LocationsCollection.Count, "Expected two location groups");
            Assert.AreEqual(4, policyCatalogue.Locations.Count, "Expected three locations");
        }
Ejemplo n.º 7
0
        private void AddActionPostAddToChannel(out PolicyChannel channel, out PolicyCatalogue policyCatalogue)
        {
            IPolicyLanguage language = new PolicyLanguage(new Guid("{E8B22533-98EB-4D00-BDE4-406DC3E1858B}"), "en");

            XMLPolicyCatalogueStore catalogueStore = XMLPolicyCatalogueStore.Instance;
            catalogueStore.Reset();
            policyCatalogue = new PolicyCatalogue(new Guid("{AB5E2A43-01FB-4AA6-98FC-8F74BB0621CA}"), language.Identifier, new TranslateableLanguageItem("{B5C31A66-1B39-4CA7-BF02-AF271B5864F7}"), catalogueStore);
            catalogueStore.AddPolicyCatalogue(policyCatalogue);

            PolicySetObserver policySetObserver = new PolicySetObserver(policyCatalogue);

            Assert.AreEqual(0, policyCatalogue.Channels.Count);
            Assert.AreEqual(0, policyCatalogue.ActionGroups.Count);
            Assert.AreEqual(0, policyCatalogue.Actions.Count);
            Assert.AreEqual(0, policyCatalogue.LocationsCollection.Count);
            Assert.AreEqual(0, policyCatalogue.Locations.Count);

            channel = new PolicyChannel(new Guid("{0FE26539-7AAD-46DC-8D5B-9651CC00B9E4}"), new TranslateableLanguageItem("Test channel"), ChannelType.SMTP);
            policySetObserver.AddObject(channel);

            IRoutingItemCollection senders = new RoutingItemCollection(new Guid("{441FDCBF-B606-4325-8CD5-E829AD5303B9}"), "Test sources");
            senders.Add(new RoutingItem(new Guid("{D41A47E2-CC13-46FF-BE83-829625792576}"), "James Brown", "*****@*****.**"));
            senders.Add(new RoutingItem(new Guid("{B031DFE9-54E7-482B-8955-18CFB8F06A40}"), "Nat King Cole", "*****@*****.**"));
            IRoutingItemCollection recipients = new RoutingItemCollection(new Guid("{29C44E5C-5405-409F-8513-A99AE246536F}"), "Test destinations");
            recipients.Add(new RoutingItem(new Guid("{9E26C6A2-ABE2-427D-9D78-5B8547ADA8D2}"), "Jet Li", "*****@*****.**"));
            ActionMatrix actionMatrix = new ActionMatrix();
            ActionMatrixCell actionMatrixCell = new ActionMatrixCell(senders, recipients);

            ConditionGroup conditionGroup = new ConditionGroup(new Guid("{9D065722-1106-4FC1-8D48-58733661B929}"), new TranslateableLanguageItem("Test condition group"), ConditionLogic.AND, false);
            ActionGroup actionGroup = new ActionGroup(new Guid("{E2A16C4D-E112-4249-92B9-612732117809}"), new TranslateableLanguageItem("Test action group"), 1);
            Action action = new Action(new Guid("{A5FAA63E-4F25-456F-92F9-9BB465C18F1F}"), "Test.dll", "Do.It", RunAt.Client, false, 1); //TODO JE
            ActionConditionGroup actionConditionGroup = new ActionConditionGroup(conditionGroup, actionGroup, false);

            actionMatrixCell.ActionConditionGroups.Add(actionConditionGroup);
            actionGroup.Actions.Add(action);

            actionMatrix[senders, recipients] = actionMatrixCell;

            channel.Actions = actionMatrix;
        }
Ejemplo n.º 8
0
        public void TestAddActionPreAddToChannel()
        {
            IPolicyLanguage language = new PolicyLanguage(new Guid("{E8B22533-98EB-4D00-BDE4-406DC3E1858B}"), "en");

            XMLPolicyCatalogueStore catalogueStore = XMLPolicyCatalogueStore.Instance;
            catalogueStore.Reset();
            PolicyCatalogue policyCatalogue = new PolicyCatalogue(new Guid("{AB5E2A43-01FB-4AA6-98FC-8F74BB0621CA}"), language.Identifier, new TranslateableLanguageItem("{B5C31A66-1B39-4CA7-BF02-AF271B5864F7}"), catalogueStore);
            catalogueStore.AddPolicyCatalogue(policyCatalogue);

            PolicySetObserver policySetObserver = new PolicySetObserver(policyCatalogue);

            Assert.AreEqual(0, policyCatalogue.Channels.Count);
            Assert.AreEqual(0, policyCatalogue.ActionGroups.Count);
            Assert.AreEqual(0, policyCatalogue.Actions.Count);
            Assert.AreEqual(0, policyCatalogue.LocationsCollection.Count);
            Assert.AreEqual(0, policyCatalogue.Locations.Count);

            PolicyChannel channel = new PolicyChannel(new Guid("{0FE26539-7AAD-46DC-8D5B-9651CC00B9E4}"), new TranslateableLanguageItem("Test channel"), ChannelType.SMTP);
            policySetObserver.AddObject(channel);

            IRoutingItemCollection senders = new RoutingItemCollection(new Guid("{441FDCBF-B606-4325-8CD5-E829AD5303B9}"), "Test sources");
            IRoutingItemCollection recipients = new RoutingItemCollection(new Guid("{29C44E5C-5405-409F-8513-A99AE246536F}"), "Test destinations");
            ActionMatrix actionMatrix = new ActionMatrix();
            channel.Actions = actionMatrix;

            ActionMatrixCell actionMatrixCell = new ActionMatrixCell(senders, recipients);
            actionMatrix[senders, recipients] = actionMatrixCell;          

            ConditionGroup conditionGroup = new ConditionGroup(new Guid("{9D065722-1106-4FC1-8D48-58733661B929}"), new TranslateableLanguageItem("Test condition group"), ConditionLogic.AND, false);
            ActionGroup actionGroup = new ActionGroup(new Guid("{E2A16C4D-E112-4249-92B9-612732117809}"), new TranslateableLanguageItem("Test action group"), 1);
            Action action = new Action(new Guid("{A5FAA63E-4F25-456F-92F9-9BB465C18F1F}"), "Test.dll", "Do.It", RunAt.Client, false, 1); //TODO JE
            ActionConditionGroup actionConditionGroup = new ActionConditionGroup(conditionGroup, actionGroup, false);
            
            actionMatrixCell.ActionConditionGroups.Add(actionConditionGroup);
            actionGroup.Actions.Add(action);

            Assert.AreEqual(1, policyCatalogue.Channels.Count, "Expected one channel");
            Assert.AreEqual(1, policyCatalogue.ActionGroups.Count, "Expected one action group");
            Assert.AreEqual(1, policyCatalogue.Actions.Count, "Expected one action");
            Assert.AreEqual(2, policyCatalogue.LocationsCollection.Count, "Expected two location groups");
            Assert.AreEqual(0, policyCatalogue.Locations.Count, "Expected no locations");
        }
Ejemplo n.º 9
0
        public void TestAddDataElementPreAddToCondition()
        {
            IPolicyLanguage language = new PolicyLanguage(new Guid("{E8B22533-98EB-4D00-BDE4-406DC3E1858B}"), "en");

            XMLPolicyCatalogueStore catalogueStore = XMLPolicyCatalogueStore.Instance;
            catalogueStore.Reset();
            PolicyCatalogue policyCatalogue = new PolicyCatalogue(new Guid("{AB5E2A43-01FB-4AA6-98FC-8F74BB0621CA}"), language.Identifier, new TranslateableLanguageItem("{B5C31A66-1B39-4CA7-BF02-AF271B5864F7}"), catalogueStore);
            catalogueStore.AddPolicyCatalogue(policyCatalogue);

            PolicySetObserver policySetObserver = new PolicySetObserver(policyCatalogue);

            Assert.AreEqual(0, policyCatalogue.Conditions.Count);
            Assert.AreEqual(0, policyCatalogue.DataElements.Count);

            DataElement dataElementLeft = new DataElement(new Guid("{AC48B709-8DED-467D-8778-BB0A1520FDDC}"), new TranslateableLanguageItem("Data left test"), new TranslateableLanguageItem("This is the data to the left"), DataType.String, DataItem.CreateDataItem(new TranslateableLanguageItem("Test"), DataType.String, "This is some data"));
            DataElement dataElementRight = new DataElement(new Guid("{697DAD36-021C-451A-A67C-08D892CFC23A}"), new TranslateableLanguageItem("Data right test"), new TranslateableLanguageItem("This is the data to the right"), DataType.String, DataItem.CreateDataItem(new TranslateableLanguageItem("Test"), DataType.String, "This is some data"));
            Condition condition = new Condition(new Guid("{79F9C52C-8F04-473B-8487-8CB241DBED31}"), "Myclass", new TranslateableLanguageItem("Test condition"), OperatorType.Equals);
            condition.DataLeft = dataElementLeft;
            condition.DataRight = dataElementRight;

            policySetObserver.AddObject(condition);

            Assert.AreEqual(1, policyCatalogue.Conditions.Count, "Expected one condition");
            Assert.AreEqual(2, policyCatalogue.DataElements.Count, "Expected two data elements");
        }