Esempio n. 1
0
        /// <summary>
        /// This method creates an invisible, nonoveridable, non-custom DataElement, of type bool.
        /// </summary>
        /// <param name="name">The name of the data element</param>
        /// <param name="value">The boolean value</param>
        /// <returns>IDataElement corresponding to the input parameters</returns>
        public static IDataElement CreateBoolElement(string name, bool value)
        {
            NonTranslateableLanguageItem dataElementName = new NonTranslateableLanguageItem(name);

            DataElement elem = new DataElement(dataElementName, dataElementName, DataType.Boolean, false);

            elem["iscustomproperty"].Value = false.ToString(CultureInfo.InvariantCulture);
            elem["allowoverride"].Value = false.ToString(CultureInfo.InvariantCulture);
            elem["visible"].Value = false.ToString(CultureInfo.InvariantCulture);

            elem.Data = DataItem.CreateDataItem(new NonTranslateableLanguageItem(String.Empty), DataType.Boolean, value);

            return elem;
        }
Esempio n. 2
0
        private IRoutingTable BuildInternalExternalSmtpRouting()
        {
            RoutingTable routingTable = new RoutingTable(new Guid("{AF6E5D89-0C6F-4B10-9A6C-658D13CD3EA8}"), new TranslateableLanguageItem("{8819B8B3-38AE-4D89-A05C-AB0904E979D1}"), ChannelType.SMTP);
            routingTable["resolve"] = new NonTranslateableLanguageItem("emailclient");

            RoutingItemCollection interalGroup = new RoutingItemCollection(Guid.NewGuid(), "Recipients:Internal");
            interalGroup.Add(new RoutingItem("Recipients:Internal", "Recipients:Internal"));
            interalGroup["InternalGroup"] = new NonTranslateableLanguageItem("true");
            interalGroup["assembly"] = new NonTranslateableLanguageItem("Workshare.InternalExternalResolver.dll");
            interalGroup["class"] = new NonTranslateableLanguageItem("Workshare.InternalExternalResolver");
            routingTable.Destinations.Add(interalGroup);

            routingTable.Sources = TestHelpers.BuildSenderGroup();
            routingTable.Destinations = TestHelpers.BuildRecipientGroup();
            TestHelpers.BuildMatrixCells(routingTable);
            return routingTable;
        }
Esempio n. 3
0
        /// <summary>
        /// Creates a new policy object with default AuditLevel and ConditionGroup values. The IPolicy
        /// is created with a new GUID.
        /// </summary>
        /// <param name="policyName">The name of the policy</param>
        /// <param name="policySet">The policy set to which this policy belongs</param>
        /// <param name="policyStatus">The status of the policy</param>
        /// <param name="auditLevel">The audit level of the policy</param>
        /// <returns>The IPolicy object</returns>
        public static IPolicy CreatePolicy(string policyName, IPolicySet policySet, PolicyStatus policyStatus, string auditLevel)
        {
            IPolicy policy = new P5Policy(policySet, System.Guid.NewGuid(), new TranslateableLanguageItem(policyName), policyStatus);
            policy["AuditLevel"] = new NonTranslateableLanguageItem(auditLevel);
            policy["blockOnException"] = new NonTranslateableLanguageItem(bool.TrueString);
            policy[PolicyConstants.SkipVerifiedMessages] = new NonTranslateableLanguageItem(bool.FalseString);

            //create root condition group on the policy
        	ChannelType[] channelTypes = PolicyTypeInfoManager.Instance.GetInfo(policySet.PolicyType).ChannelTypes;
			IPolicyChannel[] channels = ChannelFactory.CreateChannels(channelTypes);
            policy.Conditions.Add(new ConditionGroup(Guid.NewGuid(), new TranslateableLanguageItem("Default Condition Group"), ConditionLogic.AND, false));

            foreach (IPolicyChannel channel in channels)
            {
                policy.Channels.Add(channel);
            }
            return policy;
        }
        public void TestConstruct()
        {
            RoutingTable routingTable = new RoutingTable(Guid.Empty, new TranslateableLanguageItem("RoutingName"), ChannelType.SMTP);
            routingTable["resolve"] = new NonTranslateableLanguageItem("emailclient");

            RoutingItemCollection interalGroup = new RoutingItemCollection(Guid.NewGuid(), "Recipients:Internal");
            interalGroup.Add(new RoutingItem("Recipients:Internal", "Recipients:Internal"));
            interalGroup["InternalGroup"] = new NonTranslateableLanguageItem("true");
            interalGroup["assembly"] = new NonTranslateableLanguageItem("Workshare.InternalExternalResolver.dll");
            interalGroup["class"] = new NonTranslateableLanguageItem("Workshare.InternalExternalResolver");
            routingTable.Destinations.Add(interalGroup);

            Assert.AreEqual("RoutingName", routingTable.Name.Value);
            Assert.AreEqual("Sources:Everyone", routingTable.DefaultSource.Name.Value);
            Assert.AreEqual(1, routingTable.Sources.Count);
            Assert.AreEqual("Sources:Everyone", routingTable.Sources[0].Name.Value);

            Assert.AreEqual("Destinations:Everyone", routingTable.DefaultDestination.Name.Value);
            Assert.AreEqual(2, routingTable.Destinations.Count);
            Assert.AreEqual("Recipients:Internal", routingTable.Destinations[0].Name.Value);
            Assert.AreEqual("Destinations:Everyone", routingTable.Destinations[1].Name.Value);
            Assert.AreEqual(2, routingTable.CellCount);
        }
        public void TestCopyConstruct()
        {
            RoutingTable routingTable = new RoutingTable(Guid.Empty, new TranslateableLanguageItem("RoutingName"), ChannelType.SMTP);
            routingTable["resolve"] = new NonTranslateableLanguageItem("emailclient");

            RoutingItemCollection interalGroup = new RoutingItemCollection(Guid.NewGuid(), "Recipients:Internal");
            interalGroup.Add(new RoutingItem("Recipients:Internal", "Recipients:Internal"));
            interalGroup["InternalGroup"] = new NonTranslateableLanguageItem("true");
            interalGroup["assembly"] = new NonTranslateableLanguageItem("Workshare.InternalExternalResolver.dll");
            interalGroup["class"] = new NonTranslateableLanguageItem("Workshare.InternalExternalResolver");
            routingTable.Destinations.Add(interalGroup);

            RoutingItemCollection collection1 = new RoutingItemCollection(Guid.NewGuid(), "Collection1");
            RoutingItemCollection collection2 = new RoutingItemCollection(Guid.NewGuid(), "Collection2");
            RoutingItemCollection collection3 = new RoutingItemCollection(Guid.NewGuid(), "Collection3");
            routingTable.Sources.Add(collection1);
            routingTable.Sources.Add(collection2);
            routingTable.Sources.Add(collection3);

            RoutingItemCollection collection4 = new RoutingItemCollection(Guid.NewGuid(), "Collection4");
            RoutingItemCollection collection5 = new RoutingItemCollection(Guid.NewGuid(), "Collection5");
            RoutingItemCollection collection6 = new RoutingItemCollection(Guid.NewGuid(), "Collection6");
            routingTable.Destinations.Add(collection4);
            routingTable.Destinations.Add(collection5);
            routingTable.Destinations.Add(collection6);

            RoutingTable routingTable2 = new RoutingTable(routingTable);
            routingTable["resolve"] = new NonTranslateableLanguageItem("emailclient");

            routingTable2.Destinations.Add(interalGroup);

            Assert.AreEqual(routingTable.Name.Value, routingTable2.Name.Value);
            Assert.AreEqual(routingTable.Sources.Count, routingTable2.Sources.Count);
            Assert.AreEqual(routingTable.Destinations.Count, routingTable2.Destinations.Count);
            Assert.AreEqual(routingTable.CellCount, routingTable2.CellCount);
            Assert.AreEqual(routingTable.ReadOnly, routingTable2.ReadOnly);
        }
Esempio n. 6
0
 public void TestGetIgnore()
 {
     IConditionGroup conditionGroup = new ConditionGroup();
     conditionGroup[IgnoreAttribute] = new NonTranslateableLanguageItem(Boolean.TrueString);
     Assert.AreEqual(true, CustomAttributes.GetIgnore(conditionGroup));
     conditionGroup[IgnoreAttribute].Value = Boolean.FalseString;
     Assert.AreEqual(false, CustomAttributes.GetIgnore(conditionGroup));
 }
Esempio n. 7
0
        public IPolicyLanguageItem this[string index]
        {
            get
            {
                SetActiveLanguage();
                if (!m_attributes.ContainsKey(index))
                {
                    m_attributes[index] = new NonTranslateableLanguageItem("");
                }

                return m_attributes[index];
            }
            set
            {
                SetActiveLanguage();
                if (null != value)
                {
                    m_attributes[index] = value;
                }
                else 
                {
                    m_attributes[index] = new NonTranslateableLanguageItem("");
                }
            }
        }
Esempio n. 8
0
		private void ApplyConditions()
		{
			IPolicySet policySet = Template.PolicySet.Data;
			IPolicy p2 = Template[TemplatePolicy.AlertPolicy];

			foreach (ContentRule contentRule in m_rules)
			{
				P5Policy policy = new P5Policy(policySet, Guid.NewGuid(), new TranslateableLanguageItem(contentRule.RuleName), PolicyStatus.Active);

				string ruleName = contentRule.RuleName;
				string rating = contentRule.Level;
				List<ContentCondition> conditions = contentRule.Conditions;

				ConditionGroup conditionGroup = new ConditionGroup(Guid.NewGuid(), new TranslateableLanguageItem(""), ConditionLogic.OR, false);
				foreach (ContentCondition contentCondition in conditions)
				{
					List<string> contexts = contentCondition.Contexts;
					string explanation = contentCondition.Explanation;
					string conditionName = contentCondition.Name;
					string regex = contentCondition.Regex;

					DataMethod dm = BuildRegex(regex, BuildContexts(contexts), BuildCurrentFile(), BuildFileTypes());
					Condition condition = BuildCondition(conditionName, rating, BuildDataLeft(dm), BuildDataRight());
					condition["Description"] = new TranslateableLanguageItem(Guid.NewGuid(), explanation);
					conditionGroup.Conditions.Add(condition);
				}
				policy["AuditLevel"] = new NonTranslateableLanguageItem("None");
				policy["blockOnException"] = new NonTranslateableLanguageItem("false");
				policy.Conditions.Add(conditionGroup);
				policy.Channels = p2.Channels;
				policySet.Policies.Add(policy);
			}
		}
Esempio n. 9
0
		private Condition BuildCondition(string name, string rating, DataElement left, DataElement right)
		{
			Condition condition = new Condition(Guid.NewGuid(), "IDataLengthComparer", OperatorType.GreaterThan);
			condition["Rating"] = new NonTranslateableLanguageItem(rating);
			condition["preDefinedConditionType"] = new NonTranslateableLanguageItem("RegexInFileContext");
			condition.DataLeft = left;
			condition.DataRight = right;
			condition.Name = new NonTranslateableLanguageItem(name);
			return condition;
		}
        public void TestRemoveRoutingMatrixRecipients()
        {
            RoutingTable routingTable = new RoutingTable(Guid.Empty, new TranslateableLanguageItem("RoutingName"), ChannelType.SMTP);
            routingTable["resolve"] = new NonTranslateableLanguageItem("emailclient");

            RoutingItemCollection interalGroup = new RoutingItemCollection(Guid.NewGuid(), "Recipients:Internal");
            interalGroup.Add(new RoutingItem("Recipients:Internal", "Recipients:Internal"));
            interalGroup["InternalGroup"] = new NonTranslateableLanguageItem("true");
            interalGroup["assembly"] = new NonTranslateableLanguageItem("Workshare.InternalExternalResolver.dll");
            interalGroup["class"] = new NonTranslateableLanguageItem("Workshare.InternalExternalResolver");
            routingTable.Destinations.Add(interalGroup);

            RoutingItemCollection senders1 = new RoutingItemCollection(Guid.NewGuid(), "Collection1");
            RoutingItemCollection senders2 = new RoutingItemCollection(Guid.NewGuid(), "Collection2");
            routingTable.Sources.Add(senders1);
            routingTable.Sources.Add(senders2);

            RoutingItemCollection recipients1 = new RoutingItemCollection(Guid.NewGuid(), "Collection3");
            RoutingItemCollection recipients2 = new RoutingItemCollection(Guid.NewGuid(), "Collection4");
            routingTable.Destinations.Add(recipients1);
            routingTable.Destinations.Add(recipients2);

            Assert.AreEqual(6, routingTable.CellCount);

            Assert.IsFalse(routingTable.HasCell(recipients2, recipients1));
            Assert.IsFalse(routingTable.HasCell(senders1, senders2));
            Assert.IsTrue(routingTable.HasCell(senders1, recipients1));
            Assert.IsTrue(routingTable.HasCell(senders1, recipients2));
            Assert.IsTrue(routingTable.HasCell(senders2, recipients1));
            Assert.IsTrue(routingTable.HasCell(senders2, recipients2));

            //TODO: uncomment when precedence is implemented - RJ
            //Assert.AreEqual(1, routingTable[senders1, recipients1].Precedence);
            //Assert.AreEqual(2,routingTable[senders1, recipients2].Precedence);
            //Assert.AreEqual(3, routingTable[senders2, recipients1].Precedence);
            //Assert.AreEqual(4, routingTable[senders2, recipients2].Precedence);

            routingTable.Destinations.Remove(recipients1);

            Assert.AreEqual(4, routingTable.CellCount);

            Assert.IsFalse(routingTable.HasCell(recipients2, recipients1));
            Assert.IsFalse(routingTable.HasCell(senders1, senders2));
            Assert.IsFalse(routingTable.HasCell(senders1, recipients1));
            Assert.IsTrue(routingTable.HasCell(senders1, recipients2));
            Assert.IsFalse(routingTable.HasCell(senders2, recipients1));
            Assert.IsTrue(routingTable.HasCell(senders2, recipients2));

            //TODO: uncomment when precedence is implemented - RJ
            //Assert.AreEqual(1, routingTable[senders1, recipients2].Precedence);
            //Assert.AreEqual(2, routingTable[senders2, recipients2].Precedence);
        }
Esempio n. 11
0
 public void TestGetAssembly()
 {
     RoutingItemCollection routingItemCollection = new RoutingItemCollection();
     Assert.AreEqual(String.Empty, CustomAttributes.GetAssembly(routingItemCollection));
     routingItemCollection[AssemblyAttribute] = new NonTranslateableLanguageItem("abc");
     Assert.AreEqual("abc", CustomAttributes.GetAssembly(routingItemCollection));
 }
        public void TestWriteInternalExternalSmtpRoutingTables()
        {
            Guid languageGuid = new Guid("{054846D4-6540-4C78-BA7D-141C91EE6A4C}");
            PolicyLanguage language = new PolicyLanguage(languageGuid, "en");
            language[new Guid("{D0FE23B8-B8A0-4DD6-A0F1-A7836DC0417E}")] = "Test catalogue";
            language[new Guid("{24C8CB4E-71A2-434D-A5E4-8C6121E206FF}")] = "Internal financial users";
            language[new Guid("{39849BB1-2E79-43C6-8F68-229DAE589CDF}")] = "Internal legal users";

            XmlPolicyLanguageStore languageStore = XmlPolicyLanguageStore.Instance;
            languageStore.AddLanguage(language);

            XMLPolicyCatalogueStore catalogueStore = XMLPolicyCatalogueStore.Instance;
            catalogueStore.Reset();

            Guid catalogueId = new Guid("{B496E117-29DA-4770-87E9-62573B28BB4F}");
            XmlPolicyCatalogueWriter catalogueWriter = catalogueStore.GetWriter(catalogueId, languageGuid) as XmlPolicyCatalogueWriter;
            Assert.IsNotNull(catalogueWriter, "Expected a valid [IPolicyStoreWriter] writer");

            catalogueWriter.WriteName("{D0FE23B8-B8A0-4DD6-A0F1-A7836DC0417E}");

            string routingTableGuid = "{AF6E5D89-0C6F-4B10-9A6C-658D13CD3EA8}";
            RoutingTable internalRoutingTable = new RoutingTable(new Guid(routingTableGuid), new TranslateableLanguageItem("{24C8CB4E-71A2-434D-A5E4-8C6121E206FF}"), ChannelType.SMTP);
            internalRoutingTable["resolve"] = new NonTranslateableLanguageItem("emailclient");

            RoutingItemCollection interalGroup = new RoutingItemCollection(Guid.NewGuid(), "Recipients:Internal");
            interalGroup.Add(new RoutingItem("Recipients:Internal", "Recipients:Internal"));
            interalGroup["InternalGroup"] = new NonTranslateableLanguageItem("true");
            interalGroup["assembly"] = new NonTranslateableLanguageItem("Workshare.InternalExternalResolver.dll");
            interalGroup["class"] = new NonTranslateableLanguageItem("Workshare.InternalExternalResolver");
            internalRoutingTable.Destinations.Add(interalGroup);

            catalogueWriter.WriteRoutingTable(internalRoutingTable);

            routingTableGuid = "{533515D4-A339-419D-A4AC-8642BBFF4C82}";
            RoutingTable routingTable = new RoutingTable(new Guid(routingTableGuid), new TranslateableLanguageItem("{39849BB1-2E79-43C6-8F68-229DAE589CDF}"), ChannelType.SMTP);
            catalogueWriter.WriteRoutingTable(routingTable);

            catalogueWriter.Close();

            string testFilename = m_testPath + "ExpectedWriteInternalExternalRoutingTables.xml";
            string results = System.IO.File.ReadAllText(testFilename);
            results = results.Replace("{8C156180-2354-4DE8-B520-93EE66869AA9}", internalRoutingTable.Destinations[0].Identifier.ToString("B").ToUpper());
            results = results.Replace("{409B06D8-5EAC-4956-87DD-1942D549C098}", internalRoutingTable.Destinations[0].Name.Identifier.ToString("B").ToUpper());
            IRoutingItemCollection iac = internalRoutingTable.Destinations[0];
            IRoutingItem address = iac[0];
            results = results.Replace("{493FB257-7959-4290-A63C-116D9B9AC7F6}", address.Identifier.ToString("B").ToUpper());
            testFilename += ".tmp";
            System.IO.File.WriteAllText(testFilename, results);

            TestHelpers.CompareXml(testFilename, catalogueStore.GetStoreXML(catalogueId));
            System.IO.File.Delete(testFilename);
        }
Esempio n. 13
0
        private IDataElement InitDataElem(string elementName)
        {
            IDataElement elem;

            foreach (IDataElement de in m_action.DataElements)
            {
                if (de.Name.Value == elementName)
                {
                    return de;
                }
            }

            NonTranslateableLanguageItem dataElementName =
                            new NonTranslateableLanguageItem(elementName);

            elem =
                new DataElement(dataElementName, dataElementName, DataType.Boolean, false);

            elem["iscustomproperty"].Value = false.ToString(CultureInfo.InvariantCulture);
            elem["allowoverride"].Value = false.ToString(CultureInfo.InvariantCulture);
            elem["visible"].Value = false.ToString(CultureInfo.InvariantCulture);

            elem.Data = DataItem.CreateDataItem(
                new NonTranslateableLanguageItem(String.Empty), DataType.Boolean,false);

            m_action.DataElements.Add(elem);

            return elem;
        }
        public void TestOfflineSmtpRoutingCopyNullOffline()
        {
            RoutingTable routingTable = new RoutingTable(Guid.Empty, new TranslateableLanguageItem("RoutingName"), ChannelType.SMTP);
            routingTable["resolve"] = new NonTranslateableLanguageItem("emailclient");

            RoutingItemCollection interalGroup = new RoutingItemCollection(Guid.NewGuid(), "Recipients:Internal");
            interalGroup.Add(new RoutingItem("Recipients:Internal", "Recipients:Internal"));
            interalGroup["InternalGroup"] = new NonTranslateableLanguageItem("true");
            interalGroup["assembly"] = new NonTranslateableLanguageItem("Workshare.InternalExternalResolver.dll");
            interalGroup["class"] = new NonTranslateableLanguageItem("Workshare.InternalExternalResolver");
            routingTable.Destinations.Add(interalGroup);

            IRoutingMatrixCell offlineCell = routingTable.Offline;
            Assert.IsNotNull(offlineCell, "Expected a valid offline routing cell");
            offlineCell.Name.Value = "This is an offline cell";

            RoutingTable copy = new RoutingTable(null, false, false);
        }
        public void TestOfflineSmtpRoutingCopyCreateNew()
        {
            RoutingTable routingTable = new RoutingTable(Guid.Empty, new TranslateableLanguageItem("RoutingName"), ChannelType.SMTP);
            routingTable["resolve"] = new NonTranslateableLanguageItem("emailclient");

            RoutingItemCollection interalGroup = new RoutingItemCollection(Guid.NewGuid(), "Recipients:Internal");
            interalGroup.Add(new RoutingItem("Recipients:Internal", "Recipients:Internal"));
            interalGroup["InternalGroup"] = new NonTranslateableLanguageItem("true");
            interalGroup["assembly"] = new NonTranslateableLanguageItem("Workshare.InternalExternalResolver.dll");
            interalGroup["class"] = new NonTranslateableLanguageItem("Workshare.InternalExternalResolver");
            routingTable.Destinations.Add(interalGroup);

            IRoutingMatrixCell offlineCell = routingTable.Offline;
            Assert.IsNotNull(offlineCell, "Expected a valid offline routing cell");
            offlineCell.Name.Value = "This is an offline cell";
            offlineCell.Description.Value = "This is a cell that will be used in offline mode";
            Assert.IsNotNull(offlineCell, "Expected a valid offline routing cell");

            RoutingTable copy = routingTable.DeepCopy(false, true) as RoutingTable;
            Assert.AreEqual(offlineCell.Name.Value, copy.Offline.Name.Value);
            Assert.AreNotEqual(offlineCell.Description.Identifier, copy.Offline.Description.Identifier);
            Assert.AreEqual(offlineCell.Description.Value, copy.Offline.Description.Value);
            copy.Offline.Description.Value = "A change was made";
            Assert.AreNotEqual(offlineCell.Description.Value, copy.Offline.Description.Value);

            RoutingTable copy2 = new RoutingTable(routingTable, false, true);
            routingTable["resolve"] = new NonTranslateableLanguageItem("emailclient");

            copy2.Destinations.Add(interalGroup);

            Assert.AreEqual(offlineCell.Name.Value, copy2.Offline.Name.Value);
            Assert.AreNotEqual(offlineCell.Description.Identifier, copy2.Offline.Description.Identifier);
            Assert.AreEqual(offlineCell.Description.Value, copy2.Offline.Description.Value);
            copy2.Offline.Description.Value = "A change was made";
            Assert.AreNotEqual(offlineCell.Description.Value, copy2.Offline.Description.Value);
        }
        public void TestOfflineSmtpRouting()
        {
            RoutingTable routingTable = new RoutingTable(Guid.Empty, new TranslateableLanguageItem("RoutingName"), ChannelType.SMTP);
            routingTable["resolve"] = new NonTranslateableLanguageItem("emailclient");

            RoutingItemCollection interalGroup = new RoutingItemCollection(Guid.NewGuid(), "Recipients:Internal");
            interalGroup.Add(new RoutingItem("Recipients:Internal", "Recipients:Internal"));
            interalGroup["InternalGroup"] = new NonTranslateableLanguageItem("true");
            interalGroup["assembly"] = new NonTranslateableLanguageItem("Workshare.InternalExternalResolver.dll");
            interalGroup["class"] = new NonTranslateableLanguageItem("Workshare.InternalExternalResolver");
            routingTable.Destinations.Add(interalGroup);

            Assert.IsNotNull(routingTable.Offline, "Expected a valid offline routing cell");
        }
Esempio n. 17
0
 public void TestGetRiskRating()
 {
     IConditionGroup conditionGroup = new ConditionGroup();
     Assert.AreEqual(ConditionUnitFactory.RiskRatingType.Undefined, CustomAttributes.GetRiskRating(conditionGroup));
     conditionGroup[RiskRatingAttribute] = new NonTranslateableLanguageItem(Enum.GetName(typeof(ConditionUnitFactory.RiskRatingType), ConditionUnitFactory.RiskRatingType.High));
     Assert.AreEqual(ConditionUnitFactory.RiskRatingType.High, CustomAttributes.GetRiskRating(conditionGroup));
     conditionGroup[RiskRatingAttribute] = new NonTranslateableLanguageItem(Enum.GetName(typeof(ConditionUnitFactory.RiskRatingType), ConditionUnitFactory.RiskRatingType.Medium));
     Assert.AreEqual(ConditionUnitFactory.RiskRatingType.Medium, CustomAttributes.GetRiskRating(conditionGroup));
     conditionGroup[RiskRatingAttribute] = new NonTranslateableLanguageItem(Enum.GetName(typeof(ConditionUnitFactory.RiskRatingType), ConditionUnitFactory.RiskRatingType.Low));
     Assert.AreEqual(ConditionUnitFactory.RiskRatingType.Low, CustomAttributes.GetRiskRating(conditionGroup));
 }
Esempio n. 18
0
 public void TestGetPreDefinedConditionType()
 {
     IConditionGroup conditionGroup = new ConditionGroup();
     Assert.AreEqual(ConditionUnitFactory.PreDefinedConditionType.Undefined, CustomAttributes.GetPreDefinedConditionType(conditionGroup));
     conditionGroup[PreDefinedConditionTypeAttribute] = new NonTranslateableLanguageItem(Enum.GetName(typeof(ConditionUnitFactory.PreDefinedConditionType), ConditionUnitFactory.PreDefinedConditionType.FileType));
     Assert.AreEqual(ConditionUnitFactory.PreDefinedConditionType.FileType, CustomAttributes.GetPreDefinedConditionType(conditionGroup));
     conditionGroup[PreDefinedConditionTypeAttribute] = new NonTranslateableLanguageItem(Enum.GetName(typeof(ConditionUnitFactory.PreDefinedConditionType), ConditionUnitFactory.PreDefinedConditionType.RegexInFileContext));
     Assert.AreEqual(ConditionUnitFactory.PreDefinedConditionType.RegexInFileContext, CustomAttributes.GetPreDefinedConditionType(conditionGroup));
     conditionGroup[PreDefinedConditionTypeAttribute] = new NonTranslateableLanguageItem(Enum.GetName(typeof(ConditionUnitFactory.PreDefinedConditionType), ConditionUnitFactory.PreDefinedConditionType.RegexInFileName));
     Assert.AreEqual(ConditionUnitFactory.PreDefinedConditionType.RegexInFileName, CustomAttributes.GetPreDefinedConditionType(conditionGroup));
 }
Esempio n. 19
0
 public void TestGetContentType()
 {
     Workshare.Policy.ObjectModel.IRoutingItem routingItem = new Workshare.Policy.ObjectModel.RoutingItem("routingItem", "routingItemContent");
     Assert.AreEqual(String.Empty, CustomAttributes.GetContentType(routingItem));
     routingItem[ContentTypeAttribute] = new NonTranslateableLanguageItem(RemovableDeviceItemContentTypes.DeviceType);
     Assert.AreEqual(RemovableDeviceItemContentTypes.DeviceType, CustomAttributes.GetContentType(routingItem));
     routingItem[ContentTypeAttribute] = new NonTranslateableLanguageItem(RemovableDeviceItemContentTypes.VolumeID);
     Assert.AreEqual(RemovableDeviceItemContentTypes.VolumeID, CustomAttributes.GetContentType(routingItem));
     routingItem[ContentTypeAttribute] = new NonTranslateableLanguageItem(RemovableDeviceItemContentTypes.VolumeName);
     Assert.AreEqual(RemovableDeviceItemContentTypes.VolumeName, CustomAttributes.GetContentType(routingItem));
 }
        public void TestRecipients()
        {
            RoutingTable routingTable = new RoutingTable(Guid.Empty, new TranslateableLanguageItem("RoutingName"), ChannelType.SMTP);
            routingTable["resolve"] = new NonTranslateableLanguageItem("emailclient");

            RoutingItemCollection interalGroup = new RoutingItemCollection(Guid.NewGuid(), "Recipients:Internal");
            interalGroup.Add(new RoutingItem("Recipients:Internal", "Recipients:Internal"));
            interalGroup["InternalGroup"] = new NonTranslateableLanguageItem("true");
            interalGroup["assembly"] = new NonTranslateableLanguageItem("Workshare.InternalExternalResolver.dll");
            interalGroup["class"] = new NonTranslateableLanguageItem("Workshare.InternalExternalResolver");
            routingTable.Destinations.Add(interalGroup);

            RoutingItemCollection collection1 = new RoutingItemCollection(Guid.NewGuid(), "Collection1");
            RoutingItemCollection collection2 = new RoutingItemCollection(Guid.NewGuid(), "Collection2");
            RoutingItemCollection collection3 = new RoutingItemCollection(Guid.NewGuid(), "Collection3");
            routingTable.Destinations.Add(collection1);
            routingTable.Destinations.Add(collection2);
            routingTable.Destinations.Add(collection3);

            RoutingItemCollection collection = routingTable.Destinations[0] as RoutingItemCollection;
            Assert.AreEqual("Recipients:Internal", collection.Name.Value);

            collection = routingTable.Destinations[1] as RoutingItemCollection;
            Assert.AreEqual("Collection1", collection.Name.Value);

            collection = routingTable.Destinations[2] as RoutingItemCollection;
            Assert.AreEqual("Collection2", collection.Name.Value);

            collection = routingTable.Destinations[3] as RoutingItemCollection;
            Assert.AreEqual("Collection3", collection.Name.Value);

            Assert.AreEqual(0, routingTable.CellCount);
        }
Esempio n. 21
0
 public void TestGetClass()
 {
     RoutingItemCollection routingItemCollection = new RoutingItemCollection();
     Assert.AreEqual(String.Empty, CustomAttributes.GetClass(routingItemCollection));
     routingItemCollection[ClassAttribute] = new NonTranslateableLanguageItem("anotherClass");
     Assert.AreEqual("anotherClass", CustomAttributes.GetClass(routingItemCollection));
 }   
        public void TestHasCell()
        {
            RoutingTable routingTable = new RoutingTable(Guid.Empty, new TranslateableLanguageItem("RoutingName"), ChannelType.SMTP);
            routingTable["resolve"] = new NonTranslateableLanguageItem("emailclient");

            RoutingItemCollection interalGroup = new RoutingItemCollection(Guid.NewGuid(), "Recipients:Internal");
            interalGroup.Add(new RoutingItem("Recipients:Internal", "Recipients:Internal"));
            interalGroup["InternalGroup"] = new NonTranslateableLanguageItem("true");
            interalGroup["assembly"] = new NonTranslateableLanguageItem("Workshare.InternalExternalResolver.dll");
            interalGroup["class"] = new NonTranslateableLanguageItem("Workshare.InternalExternalResolver");
            routingTable.Destinations.Add(interalGroup);

            IRoutingItemCollection defaultSenders = routingTable.DefaultSource;
            IRoutingItemCollection defautRecipients = routingTable.DefaultDestination;
            IRoutingItemCollection internalRecipients = routingTable.Destinations[0];

            Assert.AreEqual(2, routingTable.CellCount);

            Assert.IsFalse(routingTable.HasCell(defautRecipients, internalRecipients));
            Assert.IsTrue(routingTable.HasCell(defaultSenders, defautRecipients));
            Assert.IsTrue(routingTable.HasCell(defaultSenders, internalRecipients));
        }
Esempio n. 23
0
        private static IRoutingTable SmtpInternalExternalRoutingTableFactory(string name)
        {
            IRoutingTable routingTable = new RoutingTable(Guid.NewGuid(), new TranslateableLanguageItem(name), ChannelType.SMTP);
            routingTable["resolve"] = new NonTranslateableLanguageItem("emailclient");

            RoutingItemCollection interalGroup = new RoutingItemCollection(Guid.NewGuid(), "Recipients:Internal");
            interalGroup.Add(new Workshare.Policy.ObjectModel.RoutingItem("Recipients:Internal", "Recipients:Internal"));
            interalGroup["InternalGroup"] = new NonTranslateableLanguageItem("true");
            interalGroup["assembly"] = new NonTranslateableLanguageItem("Workshare.InternalExternalResolver.dll");
            interalGroup["class"] = new NonTranslateableLanguageItem("Workshare.Policy.Routing.InternalExternalRouter");
            routingTable.Destinations.Add(interalGroup);

            // creating default sources group
            IRoutingItemCollection defaultSenders = routingTable.DefaultSource;
            defaultSenders.Name.Value = Properties.Resources.ROUTING_EVERYONE;

            // creating external destinations group
            IRoutingItemCollection recipients = routingTable.DefaultDestination;
            recipients.Name.Value = Properties.Resources.ROUTING_EXTERNALRECIPIENTS;
            IRoutingMatrixCell cell = routingTable[defaultSenders, recipients];
            cell.Name = new TranslateableLanguageItem(Properties.Resources.ROUTING_TO + recipients.Name.Value);

            // creating internal destinations group
            recipients = routingTable.Destinations[0];
            recipients.Name.Value = Properties.Resources.ROUTING_INTERNALRECIPIENTS;
            cell = routingTable[defaultSenders, recipients];
            cell.Name = new TranslateableLanguageItem(Properties.Resources.ROUTING_TO + recipients.Name.Value);

            RefreshRoutingMatrixTablePrecedences(routingTable);


            return routingTable;
        }
 public IPolicyLanguageItem Clone()
 {
     NonTranslateableLanguageItem item = new NonTranslateableLanguageItem(this);
     return item;
 }