public void TestReadChannel() { string policyCatalogueFilename = m_testPath + "SamplePolicyCatalogue.xml"; string policyLanguageFilename = m_testPath + "SampleLanguageBase.xml"; string policyFilename = m_testPath + "SamplePolicy.xml"; XmlPolicyLanguageStore.Instance.AddLanguage(System.IO.File.ReadAllText(policyLanguageFilename)); XMLPolicyCatalogueStore catalogueStore = XMLPolicyCatalogueStore.Instance; catalogueStore.AddPolicyCatalogue(System.IO.File.ReadAllText(policyCatalogueFilename)); XmlStore store = new XmlStore(System.IO.File.ReadAllText(policyFilename)); XmlPolicyReader xmlPolicyReader = store.Reader as XmlPolicyReader; string policySetId = "{8FC9EB93-C376-4E96-B22E-71FAA848393D}"; string policyId = "{F067B5B0-431A-4A34-BDD8-307C83DD8F7C}"; string xpath = string.Format(@"/PolicySetStore/PolicySets/PolicySet[@id='{0}']/Policies/Policy[@id='{1}']/Channels", policySetId, policyId); Assert.AreEqual(1, xmlPolicyReader.PolicySets.Count); IPolicySet policySet = xmlPolicyReader.PolicySets[0]; Assert.IsNotNull(policySet); IPolicy policy = policySet.Policies[new Guid(policyId)]; Assert.IsNotNull(policy); PolicyObjectCollection<IPolicyChannel> channels = new PolicyObjectCollection<IPolicyChannel>(); XmlChannelsReader reader = new XmlChannelsReader(xmlPolicyReader, channels, policy, xpath); reader.Read(); Assert.AreEqual(2, channels.Count, "Expected two channels"); int channelIndex = 0; ValidateChannel1(channels[channelIndex++]); ValidateChannel2(channels[channelIndex++]); }
public void TestReadChannelActionMatrix() { string policyCatalogueFilename = m_testPath + "SamplePolicyCatalogue.xml"; string policyLanguageFilename = m_testPath + "SampleLanguageBase.xml"; string policyFilename = m_testPath + "SamplePolicy.xml"; XmlPolicyLanguageStore.Instance.AddLanguage(System.IO.File.ReadAllText(policyLanguageFilename)); XMLPolicyCatalogueStore catalogueStore = XMLPolicyCatalogueStore.Instance; catalogueStore.Reset(); catalogueStore.AddPolicyCatalogue(System.IO.File.ReadAllText(policyCatalogueFilename)); XmlStore store = new XmlStore(System.IO.File.ReadAllText(policyFilename)); XmlPolicyReader xmlPolicyReader = store.Reader as XmlPolicyReader; string policySetId = "{8FC9EB93-C376-4E96-B22E-71FAA848393D}"; string policyId = "{C7D62E10-D889-4EF5-AF3D-823C82C230CA}"; string xpath = string.Format(@"/PolicySetStore/PolicySets/PolicySet[@id='{0}']/Policies/Policy[@id='{1}']/Channels", policySetId, policyId); Assert.AreEqual(1, xmlPolicyReader.PolicySets.Count); IPolicySet policySet = xmlPolicyReader.PolicySets[0]; Assert.IsNotNull(policySet); IPolicy policy = policySet.Policies[new Guid(policyId)]; Assert.IsNotNull(policy); PolicyObjectCollection<IPolicyChannel> channels = new PolicyObjectCollection<IPolicyChannel>(); XmlChannelsReader reader = new XmlChannelsReader(xmlPolicyReader, channels, policy, xpath); reader.Read(); Assert.AreEqual(1, channels.Count, "Expected one channel"); IPolicyChannel channel = channels[0]; Assert.IsNotNull(channel); Assert.IsNotNull(channel.Actions, "Expected a valid instance of the channel actions collection"); IActionMatrix actionMatrix = channel.Actions; Assert.IsNotNull(actionMatrix); Assert.AreEqual("", actionMatrix.Name.Value); Dictionary<KeyValuePair<Guid, Guid>, IActionMatrixCell>.Enumerator enumerator = actionMatrix.GetEnumerator(); Assert.IsTrue(enumerator.MoveNext(), "Expectd the enumerator to move to the first item"); IActionMatrixCell actionMatrixCell = enumerator.Current.Value; Assert.IsNotNull(actionMatrixCell, "Expected a valid action matrix cell"); IPolicyObjectCollection<IActionConditionGroup> actionConditiongroups = actionMatrixCell.ActionConditionGroups; Assert.IsNotNull(actionConditiongroups, "Expected a valid action condition group collection"); Assert.AreEqual(1, actionConditiongroups.Count, "Expected one action condition group collection"); IActionConditionGroup actionConditionGroup = actionConditiongroups[0]; Assert.IsNotNull(actionConditionGroup, "Expected a valid action condition group"); IActionGroup actionGroup = actionConditionGroup.ActionGroup; Assert.IsNotNull(actionGroup, "Expected a valid action group"); Assert.AreEqual(new Guid("{987B7C8B-5ADD-4696-8456-DDE11D95CE0B}"), actionGroup.Identifier); Assert.AreEqual("Protect us please", actionGroup.Name.Value); Assert.AreEqual(1, actionGroup.ActionGroups.Count); IActionGroup subActionGroup = actionGroup.ActionGroups[0]; Assert.IsNotNull(subActionGroup, "Expected a valid sub-action group"); Assert.AreEqual(new Guid("{BBEF6879-6D10-455d-A5D9-86D9B8B725A6}"), subActionGroup.Identifier); Assert.AreEqual("Email us please", subActionGroup.Name.Value); Assert.IsNotNull(subActionGroup.ActionGroups, "Expected the sub-ActionGroup's ActionGroup to be valid"); Assert.AreEqual(0, subActionGroup.ActionGroups.Count); Assert.IsNotNull(subActionGroup.Actions, "Expected the sub-ActionGroup's Actions to be valid"); Assert.AreEqual(1, subActionGroup.Actions.Count); IAction action = subActionGroup.Actions[0]; Assert.IsNotNull(action, "Expected a valid action"); Assert.AreEqual(new Guid("{72551FD1-D46D-4af6-8DA3-76B5BCE01FD8}"), action.Identifier); Assert.AreEqual("CustomAction2.dll", action.Assembly); Assert.IsNotNull(action.DataElements, "Expected the data elements to be valid for the action"); Assert.AreEqual(1, action.DataElements.Count); IDataElement dataElement = action.DataElements[0]; Assert.IsNotNull(dataElement, "Expected a valid data element"); Assert.AreEqual(new Guid("{4E2F50C5-D310-47A1-AE3A-621F5C77FA68}"), dataElement.Identifier); Assert.AreEqual("Profanity lookup", dataElement.Name.Value); Assert.AreEqual(1, actionGroup.Actions.Count); action = actionGroup.Actions[0]; Assert.IsNotNull(action, "Expected a valid action"); Assert.AreEqual(new Guid("{26BCFA7E-3605-4ee7-ACC6-0AFB4D5EBB71}"), action.Identifier); Assert.AreEqual("CustomAction.dll", action.Assembly); Assert.IsNotNull(action.DataElements, "Expected the data elements to be valid for the action"); Assert.AreEqual(1, action.DataElements.Count); dataElement = action.DataElements[0]; Assert.IsNotNull(dataElement, "Expected a valid data element"); Assert.AreEqual(new Guid("{7CED5561-FD8C-423C-838F-9440EDFE6758}"), dataElement.Identifier); Assert.AreEqual("Discrimination lookup", dataElement.Name.Value); }
public void TestReadChannelRoutingMatrix() { string policyCatalogueFilename = m_testPath + "SamplePolicyCatalogue.xml"; string policyLanguageFilename = m_testPath + "SampleLanguageBase.xml"; string policyFilename = m_testPath + "SamplePolicy.xml"; XmlPolicyLanguageStore.Instance.AddLanguage(System.IO.File.ReadAllText(policyLanguageFilename)); XMLPolicyCatalogueStore catalogueStore = XMLPolicyCatalogueStore.Instance; catalogueStore.AddPolicyCatalogue(System.IO.File.ReadAllText(policyCatalogueFilename)); XmlStore store = new XmlStore(System.IO.File.ReadAllText(policyFilename)); XmlPolicyReader xmlPolicyReader = store.Reader as XmlPolicyReader; string policySetId = "{8FC9EB93-C376-4E96-B22E-71FAA848393D}"; string policyId = "{C7D62E10-D889-4EF5-AF3D-823C82C230CA}"; string xpath = string.Format(@"/PolicySetStore/PolicySets/PolicySet[@id='{0}']/Policies/Policy[@id='{1}']/Channels", policySetId, policyId); Assert.AreEqual(1, xmlPolicyReader.PolicySets.Count); IPolicySet policySet = xmlPolicyReader.PolicySets[0]; Assert.IsNotNull(policySet); IPolicy policy = policySet.Policies[new Guid(policyId)]; Assert.IsNotNull(policy); PolicyObjectCollection<IPolicyChannel> channels = new PolicyObjectCollection<IPolicyChannel>(); XmlChannelsReader reader = new XmlChannelsReader(xmlPolicyReader, channels, policy, xpath); reader.Read(); Assert.AreEqual(1, channels.Count, "Expected one channel"); IPolicyChannel channel = channels[0]; Assert.IsNotNull(channel); Assert.IsNotNull(channel.Routing, "Expected a valid instance of the channel routing collection"); IRoutingTable smtpRouting = channel.Routing; Assert.IsNotNull(smtpRouting, "Expected the routing table type to be SMTP"); Assert.IsTrue(smtpRouting.CellCount > 0, "Expected a routing matrix with cells inserted"); }