public void TestRemoveActionMatrixCell() { ActionMatrix actionMatrix = new ActionMatrix(); RoutingItemCollection senders1 = new RoutingItemCollection(Guid.NewGuid(), "Senders1"); RoutingItemCollection senders2 = new RoutingItemCollection(Guid.NewGuid(), "Senders2"); RoutingItemCollection recipients1 = new RoutingItemCollection(Guid.NewGuid(), "Recipients1"); RoutingItemCollection recipients2 = new RoutingItemCollection(Guid.NewGuid(), "Recipients2"); Assert.AreEqual(0, actionMatrix.CellCount); actionMatrix[senders1, recipients1] = new ActionMatrixCell(senders1, recipients1); actionMatrix[senders1, recipients2] = new ActionMatrixCell(senders1, recipients2); actionMatrix[senders2, recipients2] = new ActionMatrixCell(senders2, recipients2); Assert.AreEqual(3, actionMatrix.CellCount); Assert.IsTrue(actionMatrix.HasCell(senders1, recipients1)); Assert.IsTrue(actionMatrix.HasCell(senders1, recipients2)); Assert.IsTrue(actionMatrix.HasCell(senders2, recipients2)); actionMatrix.Remove(senders1, recipients2); Assert.AreEqual(2, actionMatrix.CellCount); Assert.IsTrue(actionMatrix.HasCell(senders1, recipients1)); Assert.IsFalse(actionMatrix.HasCell(senders1, recipients2)); Assert.IsTrue(actionMatrix.HasCell(senders2, recipients2)); }
public void TestReadOnlyCopyConstruct() { RoutingTable routingTable = new RoutingTable(Guid.Empty, new TranslateableLanguageItem("RoutingName"), ChannelType.SMTP); 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, true, false); 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.IsTrue(routingTable2.ReadOnly); }
public void TestConstruct() { RoutingItemCollections group = new RoutingItemCollections(Guid.NewGuid(), "LocationsCollection"); RoutingItemCollection collection1 = new RoutingItemCollection(Guid.NewGuid(), "Collection1"); group.Add(collection1); Assert.AreEqual("LocationsCollection", group.Name.Value); Assert.AreEqual(1, group.Count); }
public override void Enter() { m_addressCollection = new RoutingItemCollection(Guid.NewGuid(), AddressSearchHelper.Instance.GetDefaultAddressCollectionName()); RoutingHelper.AddCollectionToAddressGroup(m_channel.Routing, m_addressGroup, m_addressCollection); UpdateChannelStateUI(); EditAddressCollectionState state = StateMachine.GetState(StateTypeEnum.EditAddressCollection) as EditAddressCollectionState; state.CollectionFormParent = m_collectionFormParent; state.Channel = m_channel; state.AddressGroup = m_addressGroup; state.AddressCollection = m_addressCollection; StateMachine.SetState(state); }
public void TestConstruct() { RoutingItemCollection collection = new RoutingItemCollection(Guid.Empty, "TestCollection"); RoutingItem testAddress = new RoutingItem("testName", "testAddress"); Assert.AreEqual("testName", testAddress.Name.Value); Assert.AreEqual("testAddress", testAddress.Content); collection.Add(testAddress); Assert.AreEqual(1, collection.Count); Assert.AreEqual("TestCollection", collection.Name.Value); }
public void TestIsDefaultAddressCollection() { IRoutingItemCollection addressCollection = new RoutingItemCollection(Guid.NewGuid(), "locationCollection"); Assert.IsFalse(AddressCollectionHelper.IsDefaultAddressCollection(addressCollection), "non-default location collection identified as default"); addressCollection["DefaultGroup"].Value = "ghdsgaj"; Assert.IsFalse(AddressCollectionHelper.IsDefaultAddressCollection(addressCollection), "non-default location collection identified as default"); addressCollection["DefaultGroup"].Value = "true"; Assert.IsTrue(AddressCollectionHelper.IsDefaultAddressCollection(addressCollection), "default location collection identified as not default"); addressCollection["DefaultGroup"].Value = "ghdsgaj"; Assert.IsFalse(AddressCollectionHelper.IsDefaultAddressCollection(addressCollection), "non-default location collection identified as default"); }
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; }
public override void Enter() { m_addressCollection = new RoutingItemCollection(Guid.NewGuid(), AddressSearchHelper.Instance.GetDefaultAddressCollectionName()); RoutingHelper.AddCollectionToAddressGroup(m_channel.Routing, m_addressGroup, m_addressCollection); bool isSource = (null != m_channel.Routing.Sources[m_addressCollection.Identifier]); RoutingHelper.SetRouterProperties(m_channel.Routing, m_addressCollection, isSource); UpdateChannelStateUI(); EditRoutingDetailState state = StateMachine.GetState(StateTypeEnum.EditRoutingDetail) as EditRoutingDetailState; state.CollectionFormParent = m_collectionFormParent; state.Channel = m_channel; state.AddressGroup = m_addressGroup; state.RoutingItemCollection = m_addressCollection; StateMachine.SetState(state); }
public void TestDeepCopy() { RoutingItemCollections group = new RoutingItemCollections(Guid.NewGuid(), "LocationsCollection"); RoutingItemCollection collection1 = new RoutingItemCollection(Guid.NewGuid(), "Collection1"); RoutingItemCollection collection2 = new RoutingItemCollection(Guid.NewGuid(), "Collection1"); RoutingItemCollection collection3 = new RoutingItemCollection(Guid.NewGuid(), "Collection3"); group.Add(collection1); group.Add(collection2); group.Add(collection3); RoutingItemCollections group2 = group.DeepCopy(true) as RoutingItemCollections; Assert.AreEqual(3, group.Count); Assert.AreEqual(group2.Name, group.Name); Assert.AreEqual(group2.Count, group.Count); Assert.IsTrue(group2.ReadOnly); }
public void TestCopyConstruct() { RoutingItemCollections group = new RoutingItemCollections(Guid.NewGuid(), "LocationsCollection"); RoutingItemCollection collection1 = new RoutingItemCollection(Guid.NewGuid(), "Collection1"); RoutingItemCollection collection2 = new RoutingItemCollection(Guid.NewGuid(), "Collection1"); RoutingItemCollection collection3 = new RoutingItemCollection(Guid.NewGuid(), "Collection3"); group.Add(collection1); group.Add(collection2); group.Add(collection3); RoutingItemCollections group2 = new RoutingItemCollections(group); Assert.AreEqual(3, group.Count); Assert.AreEqual(group2.Name.Value, group.Name.Value); Assert.AreEqual(group2.Count, group.Count); Assert.AreEqual(group2.ReadOnly, group.ReadOnly); }
public static IRoutingItemCollections BuildRecipientGroup() { IRoutingItemCollections addressGroup = new RoutingItemCollections(Guid.Empty, ""); IRoutingItemCollection recipients = new RoutingItemCollection(new Guid("{FA13BE82-9EB1-407E-9DD5-8005F3E840E4}"), "{50042595-6053-486A-B93D-961E20994C3F}"); recipients.Add(new RoutingItem(new Guid("{7833C99B-BA46-48C5-B9FF-44718A4E5D9F}"), "Ann", "[email protected]")); recipients.Add(new RoutingItem(new Guid("{77D2EF11-9EC5-4C51-ACF7-D62B21F24F55}"), "Sally", "[email protected]")); addressGroup.Add(recipients); IRoutingItemCollection dodgyRecipients = new RoutingItemCollection(new Guid("{13A8EBE5-8B1E-4919-82E2-8A860DE4043E}"), "{ABEDA70D-DCED-4DA1-90E4-C16F188DB2D9}"); dodgyRecipients.Add(new RoutingItem(new Guid("{D77BA793-023D-44F6-BC08-1B4BF9217087}"), "WieIs", "[email protected]")); dodgyRecipients.Add(new RoutingItem(new Guid("{33FC2B8A-F8F5-4366-BA4F-01C1F6534FE9}"), "JoeMama", "[email protected]")); addressGroup.Add(dodgyRecipients); return addressGroup; }
public static IRoutingItemCollections BuildSenderGroup() { IRoutingItemCollections addressGroup = new RoutingItemCollections(Guid.Empty, ""); IRoutingItemCollection senders = new RoutingItemCollection(new Guid("{A81631A6-6AA3-45F7-AADD-4853447E5BD6}"), "{E71D6CE9-77B6-4246-A7B5-E0F8BCE65742}"); senders.Add(new RoutingItem(new Guid("{625C4BDE-907F-4751-BDA1-0E59EDBBCE5C}"), "James", "[email protected]")); senders.Add(new RoutingItem(new Guid("{6970F70A-B28D-4694-AEFA-C3D687F56112}"), "Jane", "[email protected]")); addressGroup.Add(senders); IRoutingItemCollection dodgySenders = new RoutingItemCollection(new Guid("{0DAACC5C-6167-42C7-AED0-55D1D9CC5096}"), "{30394243-1498-43C6-9732-0EE96AD2CC77}"); dodgySenders.Add(new RoutingItem(new Guid("{55B21D2B-6D35-42AD-B6EB-83632F2538D0}"), "JoeMa", "[email protected]")); dodgySenders.Add(new RoutingItem(new Guid("{29B963D7-F4A9-48A3-9F15-19434CE7FAA6}"), "Se", "[email protected]")); addressGroup.Add(dodgySenders); return addressGroup; }
public void TestCopyConstruct() { RoutingItemCollection collection = new RoutingItemCollection(Guid.Empty, "TestCollection"); RoutingItem testAddress = new RoutingItem("testName", "testAddress"); Assert.AreEqual("testName", testAddress.Name.Value); Assert.AreEqual("testAddress", testAddress.Content); collection.Add(testAddress); testAddress = new RoutingItem("testName2", "testAddress2"); collection.Add(testAddress); RoutingItemCollection collection2 = new RoutingItemCollection(collection, false, false); Assert.AreEqual(2, collection.Count); Assert.AreEqual("TestCollection", collection.Name.Value); Assert.IsFalse(collection2.ReadOnly); }
public void TestDeepCopy() { RoutingItemCollection collection = new RoutingItemCollection(Guid.Empty, "TestCollection"); RoutingItem testAddress = new RoutingItem("testName", "testAddress"); Assert.AreEqual("testName", testAddress.Name.Value); Assert.AreEqual("testAddress", testAddress.Content); collection.Add(testAddress); testAddress = new RoutingItem("testName2", "testAddress2"); collection.Add(testAddress); RoutingItemCollection collection2 = collection.DeepCopy(true) as RoutingItemCollection; Assert.AreEqual(2, collection.Count); Assert.AreEqual("TestCollection", collection.Name.Value); Assert.IsTrue(collection2.ReadOnly); }
public void TestCollection() { RoutingItemCollections group = new RoutingItemCollections(Guid.NewGuid(), "LocationsCollection"); RoutingItemCollection collection1 = new RoutingItemCollection(Guid.NewGuid(), "Collection1"); RoutingItemCollection collection2 = new RoutingItemCollection(Guid.NewGuid(), "Collection1"); RoutingItemCollection collection3 = new RoutingItemCollection(Guid.NewGuid(), "Collection3"); group.Add(collection1); group.Add(collection2); group.Add(collection3); RoutingItem address1 = new RoutingItem("Name1", "Address1"); RoutingItem address2 = new RoutingItem("Name2", "Address2"); RoutingItem address3 = new RoutingItem("Name3", "Address3"); RoutingItem address4 = new RoutingItem("Name4", "Address4"); RoutingItem address5 = new RoutingItem("Name5", "Address5"); RoutingItem address6 = new RoutingItem("Name6", "Address6"); collection1.Add(address1); collection1.Add(address2); collection1.Add(address3); collection2.Add(address4); collection2.Add(address5); collection3.Add(address6); Assert.AreEqual(3, collection1.Count); Assert.AreEqual(2, collection2.Count); Assert.AreEqual(1, collection3.Count); RoutingItem address = group[2][0] as RoutingItem; Assert.AreEqual("Name6", address.Name.Value); Assert.AreEqual("Address6", address.Content); address = group[1][1] as RoutingItem; Assert.AreEqual("Name5", address.Name.Value); Assert.AreEqual("Address5", address.Content); address = group[0][0] as RoutingItem; Assert.AreEqual("Name1", address.Name.Value); Assert.AreEqual("Address1", address.Content); }
public void TestGetNeighbours() { RoutingTable table = new RoutingTable(Guid.NewGuid(), new NonTranslateableLanguageItem("TestRoutingTable"), Workshare.Policy.ChannelType.SMTP); table.Sources = new RoutingItemCollections(); table.Destinations = new RoutingItemCollections(); IRoutingItemCollection senderA = new RoutingItemCollection(Guid.NewGuid(), "senderA"); IRoutingItemCollection senderB = new RoutingItemCollection(Guid.NewGuid(), "senderB"); IRoutingItemCollection senderC = new RoutingItemCollection(Guid.NewGuid(), "senderC"); IRoutingItemCollection recipA = new RoutingItemCollection(Guid.NewGuid(), "recipA"); IRoutingItemCollection recipB = new RoutingItemCollection(Guid.NewGuid(), "recipB"); IRoutingItemCollection recipC = new RoutingItemCollection(Guid.NewGuid(), "recipC"); //add into the routing table table.Sources.Add(senderA); table.Sources.Add(senderB); table.Sources.Add(senderC); table.Destinations.Add(recipA); table.Destinations.Add(recipB); table.Destinations.Add(recipC); IRoutingItemCollection notInMyRoutingTable = new RoutingItemCollection(Guid.NewGuid(), "notInMyRoutingTable"); Assert.IsNull(EditRoutingDetailState.GetNeighbours(null, table), "Should return null when either param is null."); Assert.IsNull(EditRoutingDetailState.GetNeighbours(notInMyRoutingTable, null), "Should return null when either param is null."); Assert.IsNull(EditRoutingDetailState.GetNeighbours(notInMyRoutingTable, table), "Should return null when 1st param does not exist in the table"); Assert.AreSame(table.Sources, EditRoutingDetailState.GetNeighbours(senderA, table), "Expected to return the table.Sources object for this param"); Assert.AreSame(table.Sources, EditRoutingDetailState.GetNeighbours(senderB, table), "Expected to return the table.Sources object for this param"); Assert.AreSame(table.Sources, EditRoutingDetailState.GetNeighbours(senderC, table), "Expected to return the table.Sources object for this param"); Assert.AreSame(table.Destinations, EditRoutingDetailState.GetNeighbours(recipA, table), "Expected to return the table.Destinations object for this param"); Assert.AreSame(table.Destinations, EditRoutingDetailState.GetNeighbours(recipB, table), "Expected to return the table.Destinations object for this param"); Assert.AreSame(table.Destinations, EditRoutingDetailState.GetNeighbours(recipC, table), "Expected to return the table.Destinations object for this param"); }
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); }
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"); }
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 TestSetClass() { IRoutingItemCollection routingItemCollection = new RoutingItemCollection(); Assert.AreEqual(String.Empty, ((IPolicyLanguageItem)routingItemCollection[ClassAttribute]).Value); CustomAttributes.SetClass(routingItemCollection, "myClass"); Assert.AreEqual(Guid.Empty, routingItemCollection[ClassAttribute].Identifier); Assert.AreEqual("myClass", ((IPolicyLanguageItem)routingItemCollection[ClassAttribute]).Value); }
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 TestAddActionGroupMultipleTimes() { PolicyCatalogue policyCatalogue; PolicyChannel channel; AddActionPostAddToChannel(out channel, out policyCatalogue); IActionMatrix actionMatrix = channel.Actions; Dictionary<KeyValuePair<Guid, Guid>, IActionMatrixCell>.Enumerator enumerator = actionMatrix.GetEnumerator(); enumerator.MoveNext(); KeyValuePair<KeyValuePair<Guid, Guid>, IActionMatrixCell> currentKeyValuePair = enumerator.Current; IPolicyObjectCollection<IActionConditionGroup> actionConditionGroups = currentKeyValuePair.Value.ActionConditionGroups; Assert.AreEqual(1, actionConditionGroups.Count); IActionConditionGroup actionConditionGroup = actionConditionGroups[0]; Assert.IsNotNull(actionConditionGroup, "Expected a valid action condition group"); ActionGroup actionGroup = actionConditionGroup.ActionGroup as ActionGroup; Assert.AreEqual(1, actionGroup.Actions.Count, "Expected one action"); IAction action = actionConditionGroup.ActionGroup.Actions[0]; Assert.IsNotNull(action, "Expected a valid action"); // Lets add another cell IRoutingItemCollection senders = new RoutingItemCollection(new Guid("{1B5380C6-EFD3-445E-80EE-0AFAB63B870A}"), "Another sources"); IRoutingItemCollection recipients = new RoutingItemCollection(new Guid("{AE069B6D-2CD9-4EB1-8128-A28421D35FB1}"), "Another destinations"); ActionMatrixCell actionMatrixCell = new ActionMatrixCell(senders, recipients); ConditionGroup conditionGroup = new ConditionGroup(new Guid("{0E409581-5ED4-4563-933C-E6272F4521FD}"), new TranslateableLanguageItem("Another test condition group"), ConditionLogic.AND, false); ActionConditionGroup actionConditionGroup2 = new ActionConditionGroup(conditionGroup, actionGroup, false); actionMatrixCell.ActionConditionGroups.Add(actionConditionGroup2); actionMatrix[senders, recipients] = actionMatrixCell; 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(4, policyCatalogue.LocationsCollection.Count, "Expected two location groups"); Assert.AreEqual(3, policyCatalogue.Locations.Count, "Expected three locations"); }
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; }
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"); }
public static IRoutingItemCollections BuildAddressGroup(string[] addressCollection, List<string[]> addresses) { IRoutingItemCollections addressGroup = new RoutingItemCollections(Guid.Empty, ""); IRoutingItemCollection senders = new RoutingItemCollection(new Guid(addressCollection[0]), addressCollection[1]); foreach (string[] address in addresses) { senders.Add(new RoutingItem(new Guid(address[0]), address[1], address[2])); } addressGroup.Add(senders); IRoutingItemCollection dodgySenders = new RoutingItemCollection(new Guid("{0DAACC5C-6167-42C7-AED0-55D1D9CC5096}"), "{30394243-1498-43C6-9732-0EE96AD2CC77}"); dodgySenders.Add(new RoutingItem(new Guid("{55B21D2B-6D35-42AD-B6EB-83632F2538D0}"), "JoeMa", "[email protected]")); dodgySenders.Add(new RoutingItem(new Guid("{29B963D7-F4A9-48A3-9F15-19434CE7FAA6}"), "Se", "[email protected]")); addressGroup.Add(dodgySenders); return addressGroup; }
public void TestCreatePolicySetChannelsMasterCataloguePrepopulateRouting() { string testCatalogue = m_testPath + "TestCreatePolicySetChannelsMasterCatalogue.xml"; string languageFilename = m_testPath + "TestCreatePolicySetChannelsMasterCatalogueLanguage.xml"; string policySetFilename = m_testPath + "TestCreatePolicySetChannelsMasterCataloguePolicySet.xml"; XmlPolicyLanguageStore languageStore = XmlPolicyLanguageStore.Instance; languageStore.Reset(); Guid languageId = new Guid("{E8B22533-98EB-4D00-BDE4-406DC3E1858B}"); PolicyLanguageCache.Instance.ActiveLanguageId = languageId; IPolicyLanguage language = new PolicyLanguage(languageId, "en"); language.DefaultLanguage = true; languageStore.AddLanguage(language); PolicyLanguageCache policyLanguageCache = PolicyLanguageCache.Instance; policyLanguageCache.SetLanguageItemText(languageId, new Guid("{B5C31A66-1B39-4CA7-BF02-AF271B5864F7}"), "New catalogue"); policyLanguageCache.SetLanguageItemText(languageId, new Guid("{9465CA41-A0A1-40BD-BE26-E83E17D83148}"), "New policy set"); policyLanguageCache.SetLanguageItemText(languageId, new Guid("{08BC5764-4879-42ED-9AD8-15040C4ADEDE}"), "New policy"); policyLanguageCache.SetLanguageItemText(languageId, new Guid("{39C06E29-074C-46C8-BE3D-F1CD92BB8D66}"), "Test channel"); policyLanguageCache.SetLanguageItemText(languageId, new Guid("{03005F4E-04FC-4287-B2A6-25F877D9C31B}"), "Test sources"); policyLanguageCache.SetLanguageItemText(languageId, new Guid("{3BF2C1D6-0F40-4A32-A311-6F65A5D271BD}"), "Test destinations"); policyLanguageCache.SetLanguageItemText(languageId, new Guid("{A8CEBEDF-92EA-4DCC-8053-08E5245ED84D}"), "Test routing table"); policyLanguageCache.SetLanguageItemText(languageId, new Guid("{86D8056D-BA38-44FA-B9BD-100CFB7113F8}"), "Test condition group"); policyLanguageCache.SetLanguageItemText(languageId, new Guid("{040C4E16-EE88-4B91-833F-8F30A536DAC6}"), "Test action group"); policyLanguageCache.SetLanguageItemText(languageId, new Guid("{F03E6CD1-98C0-4590-B789-907ECF90BEBF}"), "Test data element"); policyLanguageCache.SetLanguageItemText(languageId, new Guid("{6197CDBE-9F42-4A61-9369-238355BAB404}"), "Test data element display"); policyLanguageCache.SetLanguageItemText(languageId, new Guid("{E5C29C65-9600-42D9-8CD6-6638F40F9341}"), "Test data item"); policyLanguageCache.SetLanguageItemText(languageId, new Guid("{463295F1-A5A2-4BB1-B029-7917AC75E9E6}"), "Test action"); 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); IPolicyStore policyStore = new XmlStore(); IPolicySet policySet = new PolicySet(new Guid("{29EC30A5-1271-4306-89C8-5811172D901A}"), new TranslateableLanguageItem("{9465CA41-A0A1-40BD-BE26-E83E17D83148}"), policyStore, policyCatalogue, false); IPolicy newPolicy = new P5Policy(policySet, new Guid("{D257D4DC-4A12-438F-A32A-CF1CE4474441}"), new TranslateableLanguageItem("{08BC5764-4879-42ED-9AD8-15040C4ADEDE}"), PolicyStatus.Active); policySet.Policies.Add(newPolicy); // Create policy set channel PolicyChannel channel = new PolicyChannel(new Guid("{0FE26539-7AAD-46DC-8D5B-9651CC00B9E4}"), new TranslateableLanguageItem("{39C06E29-074C-46C8-BE3D-F1CD92BB8D66}"), ChannelType.SMTP); // Create routing table RoutingTable routingTable = new RoutingTable(new Guid("{CDF0252C-3D5D-4AFB-98C2-89CF00FE2175}"), new TranslateableLanguageItem("{A8CEBEDF-92EA-4DCC-8053-08E5245ED84D}"), ChannelType.SMTP); IRoutingItemCollection senders = new RoutingItemCollection(new Guid("{441FDCBF-B606-4325-8CD5-E829AD5303B9}"), "{03005F4E-04FC-4287-B2A6-25F877D9C31B}"); 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}"), "{3BF2C1D6-0F40-4A32-A311-6F65A5D271BD}"); recipients.Add(new RoutingItem(new Guid("{9E26C6A2-ABE2-427D-9D78-5B8547ADA8D2}"), "Jet Li", "*****@*****.**")); routingTable.Sources.Add(senders); routingTable.Destinations.Add(recipients); // Assign routing table to channel channel.Routing = routingTable; // Create action matrix ActionMatrix actionMatrix = new ObjectModel.ActionMatrix(false); // Create an action matrix cell ActionMatrixCell actionMatrixCell = new ObjectModel.ActionMatrixCell(senders, recipients); // Populate the action matrix cell ConditionGroup conditionGroup = new ConditionGroup(new Guid("{661EDD6F-D750-493A-9932-E56C8C22E2CF}"), new TranslateableLanguageItem("{86D8056D-BA38-44FA-B9BD-100CFB7113F8}"), ConditionLogic.AND, false); ActionGroup actionGroup = new ObjectModel.ActionGroup(new Guid("{32D97853-2680-4B02-A391-22CAEE87B017}"), new TranslateableLanguageItem("{040C4E16-EE88-4B91-833F-8F30A536DAC6}"), 1); IActionConditionGroup actionConditionGroup = new ObjectModel.ActionConditionGroup(conditionGroup, actionGroup, false); ObjectModel.Action action = new ObjectModel.Action(new Guid("{5153B00E-7D30-4D37-90F9-75E55AA1B32B}"), new TranslateableLanguageItem("{463295F1-A5A2-4BB1-B029-7917AC75E9E6}"), "TestAction.dll", "Test.Action", RunAt.Client, false, 1); //TODO JE DataItem dataItem = DataItem.CreateDataItem(new TranslateableLanguageItem("{E5C29C65-9600-42D9-8CD6-6638F40F9341}"), DataType.String, "Not again, when will it ever end!"); DataElement dataElement = new DataElement(new Guid("{39500989-0B41-4C4E-85DF-CCB4FBD5BEB8}"), new TranslateableLanguageItem("{F03E6CD1-98C0-4590-B789-907ECF90BEBF}"), new TranslateableLanguageItem("{6197CDBE-9F42-4A61-9369-238355BAB404}"), DataType.String, dataItem); action.DataElements.Add(dataElement); actionConditionGroup.ActionGroup.Actions.Add(action); // Assign the action condition group to the matrix cell actionMatrixCell.ActionConditionGroups.Add(actionConditionGroup); // Assign the action matrix cell to the action matrix actionMatrix[senders, recipients] = actionMatrixCell; // Assign action matrix to channel channel.Actions = actionMatrix; // Assign channel to policy newPolicy.Channels.Add(channel); // Save everything IPolicyCatalogueWriter catalogueWriter = catalogueStore.GetWriter(policyCatalogue.Identifier, language.Identifier); catalogueWriter.WriteCatalogue(policyCatalogue); catalogueWriter.Close(); policySet.Save(); TestHelpers.CompareXml(policySetFilename, policyStore.XMLRepresentation); IRoutingMatrixCell routingMatrixCell = routingTable[senders, recipients]; string expectedCatalogueXml = System.IO.File.ReadAllText(testCatalogue); expectedCatalogueXml = expectedCatalogueXml.Replace("{0}", routingMatrixCell.Name.Identifier.ToString("B").ToUpper()); expectedCatalogueXml = expectedCatalogueXml.Replace("{1}", routingMatrixCell.Description.Identifier.ToString("B").ToUpper()); testCatalogue += ".tmp"; System.IO.File.WriteAllText(testCatalogue, expectedCatalogueXml); TestHelpers.CompareXml(testCatalogue, catalogueStore.GetStoreXML(policySet.MasterCatalogue.Identifier)); string expectedLanguageXml = System.IO.File.ReadAllText(languageFilename); expectedLanguageXml = expectedLanguageXml.Replace("{0}", routingMatrixCell.Name.Identifier.ToString("B").ToUpper()); expectedLanguageXml = expectedLanguageXml.Replace("{1}", routingMatrixCell.Description.Identifier.ToString("B").ToUpper()); languageFilename += ".tmp"; System.IO.File.WriteAllText(languageFilename, expectedLanguageXml); TestHelpers.CompareXml(languageFilename, languageStore.GetXMLRepresentation(language.Identifier, language.Name.Value)); }
private IRoutingItemCollection GetTestRoutingItemCollectionData() { IRoutingItemCollection routingItemCollection = new RoutingItemCollection(); //device types List<string> deviceTypes = DeviceTypeDisplayTranslator.Instance.DataTypes; IRoutingItem routingItem = new RoutingItem(deviceTypes[0], deviceTypes[0]); CustomAttributes.SetContentType(routingItem, Workshare.Policy.Routing.RemovableDeviceItemContentTypes.DeviceType); routingItemCollection.Add(routingItem); routingItem = new RoutingItem(deviceTypes[1], deviceTypes[1]); CustomAttributes.SetContentType(routingItem, Workshare.Policy.Routing.RemovableDeviceItemContentTypes.DeviceType); routingItemCollection.Add(routingItem); routingItem = new RoutingItem(deviceTypes[2], deviceTypes[2]); CustomAttributes.SetContentType(routingItem, Workshare.Policy.Routing.RemovableDeviceItemContentTypes.DeviceType); routingItemCollection.Add(routingItem); //volume names routingItem = new RoutingItem("volumeName1", "volumeName1"); CustomAttributes.SetContentType(routingItem, Workshare.Policy.Routing.RemovableDeviceItemContentTypes.VolumeName); routingItemCollection.Add(routingItem); routingItem = new RoutingItem("volumeName2", "volumeName2"); CustomAttributes.SetContentType(routingItem, Workshare.Policy.Routing.RemovableDeviceItemContentTypes.VolumeName); routingItemCollection.Add(routingItem); //volume ids routingItem = new RoutingItem("volumeID1", "volumeID1"); CustomAttributes.SetContentType(routingItem, Workshare.Policy.Routing.RemovableDeviceItemContentTypes.VolumeID); routingItemCollection.Add(routingItem); routingItem = new RoutingItem("volumeID2", "volumeID2"); CustomAttributes.SetContentType(routingItem, Workshare.Policy.Routing.RemovableDeviceItemContentTypes.VolumeID); routingItemCollection.Add(routingItem); return routingItemCollection; }
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 void TestSetAssembly() { IRoutingItemCollection routingItemCollection = new RoutingItemCollection(); Assert.AreEqual(String.Empty, ((IPolicyLanguageItem)routingItemCollection[AssemblyAttribute]).Value); CustomAttributes.SetAssembly(routingItemCollection, "abc"); Assert.AreEqual(Guid.Empty, routingItemCollection[AssemblyAttribute].Identifier); Assert.AreEqual("abc", ((IPolicyLanguageItem)routingItemCollection[AssemblyAttribute]).Value); }