Ejemplo n.º 1
0
        public void TestConstruction()
        {
            RoutingItem testAddress = new RoutingItem("testName", "testAddress");

            Assert.AreEqual("testName", testAddress.Name.Value);
            Assert.AreEqual("testAddress", testAddress.Content);
        }
Ejemplo n.º 2
0
        public void TestAttributes()
        {
            RoutingItem testAddress = new RoutingItem("testName", "testAddress");

            testAddress["Attribute1"].Value = "accepted attribute 1";
            testAddress["Attribute2"].Value = "accepted attribute 2";

            Assert.AreEqual("accepted attribute 1", testAddress["Attribute1"].Value);
            Assert.AreEqual("accepted attribute 2", testAddress["Attribute2"].Value);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        public void TestCopyConstruct()
        {
            RoutingItem testAddress = new RoutingItem("testName", "testAddress");

            testAddress["Attribute1"].Value = "accepted attribute 1";
            testAddress["Attribute2"].Value = "accepted attribute 2";

            RoutingItem testAddress2 = new RoutingItem(testAddress, false, false);

            Assert.AreEqual("testName", testAddress2.Name.Value);
            Assert.AreEqual("testAddress", testAddress2.Content);
            Assert.AreEqual("accepted attribute 1", testAddress2["Attribute1"].Value);
            Assert.AreEqual("accepted attribute 2", testAddress2["Attribute2"].Value);
            Assert.IsFalse(testAddress2.ReadOnly);
        }
Ejemplo n.º 5
0
        public void TestClone()
        {
            RoutingItem testAddress = new RoutingItem("testName", "testAddress", true);

            testAddress["Attribute1"].Value = "accepted attribute 1";
            testAddress["Attribute2"].Value = "accepted attribute 2";

            RoutingItem testAddress2 = testAddress.Clone() as RoutingItem;

            Assert.AreEqual("testName", testAddress2.Name.Value);
            Assert.AreEqual("testAddress", testAddress2.Content);
            Assert.AreEqual("accepted attribute 1", testAddress2["Attribute1"].Value);
            Assert.AreEqual("accepted attribute 2", testAddress2["Attribute2"].Value);
            Assert.IsTrue(testAddress2.ReadOnly);
            Assert.AreNotEqual(testAddress.Identifier, testAddress2.Identifier);
        }
Ejemplo n.º 6
0
        public void TestDeepCopy()
        {
            RoutingItem testAddress = new RoutingItem("testName", "testAddress");

            testAddress["Attribute1"].Value = "accepted attribute 1";
            testAddress["Attribute2"].Value = "accepted attribute 2";

            RoutingItem testAddress2 = testAddress.DeepCopy(true) as RoutingItem;

            Assert.AreEqual("testName", testAddress2.Name.Value);
            Assert.AreEqual("testAddress", testAddress2.Content);
            Assert.AreEqual("accepted attribute 1", testAddress2["Attribute1"].Value);
            Assert.AreEqual("accepted attribute 2", testAddress2["Attribute2"].Value);
            Assert.IsTrue(testAddress2.ReadOnly);

        }
Ejemplo n.º 7
0
        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);
        }
Ejemplo n.º 8
0
        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);
        }
Ejemplo n.º 9
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));
 }
Ejemplo n.º 10
0
 public void TestSetContentType()
 {
     Workshare.Policy.ObjectModel.IRoutingItem routingItem = new Workshare.Policy.ObjectModel.RoutingItem("routingItem", "routingItemContent");
     Assert.AreEqual(string.Empty, routingItem[ContentTypeAttribute].Value);
     CustomAttributes.SetContentType(routingItem, RemovableDeviceItemContentTypes.DeviceType);
     Assert.AreEqual(Guid.Empty, routingItem[ContentTypeAttribute].Identifier);
     Assert.AreEqual(RemovableDeviceItemContentTypes.DeviceType, routingItem[ContentTypeAttribute].Value);
     CustomAttributes.SetContentType(routingItem, RemovableDeviceItemContentTypes.VolumeID);
     Assert.AreEqual(Guid.Empty, routingItem[ContentTypeAttribute].Identifier);
     Assert.AreEqual(RemovableDeviceItemContentTypes.VolumeID, routingItem[ContentTypeAttribute].Value);
     CustomAttributes.SetContentType(routingItem, RemovableDeviceItemContentTypes.VolumeName);
     Assert.AreEqual(Guid.Empty, routingItem[ContentTypeAttribute].Identifier);
     Assert.AreEqual(RemovableDeviceItemContentTypes.VolumeName, routingItem[ContentTypeAttribute].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;
        }
Ejemplo n.º 12
0
        private Dictionary<Guid, IRoutingItem> ReadRoutingItems(XmlNodeList addressesNode)
        {
            Dictionary<Guid, IRoutingItem> addressDictionary = new Dictionary<Guid, IRoutingItem>();

            List<string> exclusions = new List<string>();
            exclusions.Add("id");
            exclusions.Add("name");
            exclusions.Add("address");

            foreach (XmlNode addressNode in addressesNode)
            {
                XmlAttributeCollection attributes = addressNode.Attributes;
                string id = attributes.GetNamedItem(exclusions[0]).InnerText;
                string name = attributes.GetNamedItem(exclusions[1]).InnerText;
                string address = attributes.GetNamedItem(exclusions[2]).InnerText;

                Guid guidId = new Guid(id);
                IRoutingItem currentAddress = new RoutingItem(guidId, name, address);
                new XmlCustomAttributesReader(currentAddress, attributes, exclusions).Read();

                addressDictionary.Add(guidId, currentAddress);
            }

            return addressDictionary;
        }
Ejemplo n.º 13
0
        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);
        }
        private List<IRoutingItem> GetRoutingItems()
        {

            List<IRoutingItem> routingItems = new List<IRoutingItem>();

            string[] tokenisedMembers = Workshare.Utilities.StringUtilities.Tokenise(m_ui.GroupMembers);
            foreach (string token in tokenisedMembers)
            {
                string trimmed_token = token.Trim();

                if (!string.IsNullOrEmpty(trimmed_token))
                {
                    //validate each string.
                    RoutingItem add = new RoutingItem(trimmed_token, trimmed_token);
                    routingItems.Add(add as IRoutingItem);
                }
            }

            return routingItems;
        }
        /// <summary>
        /// Builds a list of RoutingItem objects from the Volume IDs text box
        /// </summary>
        /// <returns>The list of RoutingItem objects</returns>
        private List<IRoutingItem> GetRoutingItemsFromVolumeIDs()
        {
            List<IRoutingItem> routingItems = new List<IRoutingItem>();

            //convert to tokenised list
            string[] members = Utilities.StringUtilities.Tokenise(m_ui.VolumeID);
            DeviceTypeDisplayTranslator displayTranslator = DeviceTypeDisplayTranslator.Instance;
            foreach (string member in members)
            {
                string trimmed_member = member.Trim();

                if (!String.IsNullOrEmpty(trimmed_member))
                {
                    IRoutingItem routingItem = new RoutingItem(trimmed_member, trimmed_member);
                    CustomAttributes.SetContentType(routingItem, Workshare.Policy.Routing.RemovableDeviceItemContentTypes.VolumeID);
                    routingItems.Add(routingItem);
                }
            }

            return routingItems;
        }
        /// <summary>
        /// Builds a list of RoutingItem objects from the items in the Device Types checked list box
        /// </summary>
        /// <returns>The list of RoutingItem objects</returns>
        private List<IRoutingItem> GetRoutingItemsFromDeviceTypes()
        {
            List<IRoutingItem> routingItems = new List<IRoutingItem>();
            
            DeviceTypeDisplayTranslator displayTranslator = DeviceTypeDisplayTranslator.Instance;

            //get device types
            int index = 0;
            foreach (string deviceType in m_ui.CheckedDeviceTypes)
            {
                try
                {
                    string deviceTypeData = displayTranslator.GetDataType(deviceType);
                    IRoutingItem routingItem = new RoutingItem(deviceTypeData, deviceTypeData);
                    CustomAttributes.SetContentType(routingItem, Workshare.Policy.Routing.RemovableDeviceItemContentTypes.DeviceType);
                    routingItems.Add(routingItem);
                }
                catch (ArgumentException ex)
                {
					ErrorMessage errorMessage = new ErrorMessage(
						"DEVICETYPE_UNKNOWN", "Workshare.PolicyDesigner.Properties.Resources", System.Reflection.Assembly.GetExecutingAssembly());
					Logger.LogError(errorMessage.LogString);
					Logger.LogError(ex);
                }
                index++;
            }

            //Remember that the ItemCheck event was rasied *before* the state changes.
            //So, do extra processing for the item that changed. We may need to add it to, 
            //or remove it from, our list
            if (m_changedDeviceTypeIndex >= 0)
            {
                string changedDeviceType = m_ui.DeviceTypes[m_changedDeviceTypeIndex] as string;
                string changedDeviceTypeData = displayTranslator.GetDataType(changedDeviceType);
                if (m_changedDeviceTypeNewCheckState == CheckState.Checked)
                {
                    //item should be in our list
                    IRoutingItem changedRoutingItem = null;
                    foreach(IRoutingItem routingItem in routingItems)
                    {
                        if (routingItem.Content == changedDeviceTypeData)
                        {
                            changedRoutingItem = routingItem;
                        }
                    }
                    if (null == changedRoutingItem)
                    {
                        IRoutingItem routingItem = new RoutingItem(changedDeviceTypeData, changedDeviceTypeData);
                        CustomAttributes.SetContentType(routingItem, Workshare.Policy.Routing.RemovableDeviceItemContentTypes.DeviceType);
                        routingItems.Add(routingItem);
                    }
                }
                else if (m_changedDeviceTypeNewCheckState == CheckState.Unchecked)
                {
                    //item shouldn't be in our list.
                    IRoutingItem changedRoutingItem = null;
                    foreach (IRoutingItem routingItem in routingItems)
                    {
                        if (routingItem.Content == changedDeviceTypeData)
                        {
                            changedRoutingItem = routingItem;
                        }
                    }
                    if (null != changedRoutingItem)
                    {
                        routingItems.Remove(changedRoutingItem);
                    }
                }
                else
                {
                    //don't currently support intermediate state
                    System.Diagnostics.Debug.Assert(false);
                }
            }

            return routingItems;
        }
Ejemplo n.º 17
0
 public RoutingItem(RoutingItem rhs, bool readOnly, bool createNewId)
     : base(rhs, readOnly, createNewId)
 {
     m_content = rhs.m_content;
 }
Ejemplo n.º 18
0
 public RoutingItem(RoutingItem rhs)
     : base(rhs, rhs.ReadOnly, false)
 {
     m_content = rhs.m_content;
 }
Ejemplo n.º 19
0
        public void TestCollection()
        {
            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);
            RoutingItem testAddress2 = new RoutingItem("testName2", "testAddress2");
            collection.Add(testAddress2);

            RoutingItem addTest = collection[0] as RoutingItem;

            Assert.AreEqual(addTest.Name.Value, testAddress.Name.Value);
            Assert.AreEqual(addTest.Content, testAddress.Content);
            Assert.AreEqual(addTest["Attribute1"].Value, testAddress["Attribute1"].Value);
            Assert.AreEqual(addTest["Attribute2"].Value, testAddress["Attribute2"].Value);

            addTest = collection[1] as RoutingItem;
            Assert.AreEqual(addTest.Name.Value, testAddress2.Name.Value);
            Assert.AreEqual(addTest.Content, testAddress2.Content);
            Assert.AreEqual(addTest["Attribute1"].Value, testAddress2["Attribute1"].Value);
            Assert.AreEqual(addTest["Attribute2"].Value, testAddress2["Attribute2"].Value);
        }
        public void TestWriteAddressGroup()
        {
            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("{63A4F19E-332A-4006-BD0A-688BD184CB9F}")] = "Financial Users";
            language[new Guid("{852F1BEC-CCB6-4203-8701-89CAE87EA97B}")] = "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 address1GuidString = "{625C4BDE-907F-4751-BDA1-0E59EDBBCE5C}";
            string address2GuidString = "{6970F70A-B28D-4694-AEFA-C3D687F56112}";
            string address3GuidString = "{7833C99B-BA46-48c5-B9FF-44718A4E5D9F}";
            string address4GuidString = "{77D2EF11-9EC5-4c51-ACF7-D62B21F24F55}";

            IRoutingItem address1 = new RoutingItem(new Guid(address1GuidString), "James", "[email protected]");
            IRoutingItem address2 = new RoutingItem(new Guid(address2GuidString), "Jane", "[email protected]");
            IRoutingItem address3 = new RoutingItem(new Guid(address3GuidString), "Ann", "[email protected]");
            IRoutingItem address4 = new RoutingItem(new Guid(address4GuidString), "Sally", "[email protected]");

            catalogueWriter.WriteLocation(address1);
            catalogueWriter.WriteLocation(address2);
            catalogueWriter.WriteLocation(address3);
            catalogueWriter.WriteLocation(address4);

            RoutingItemCollection recipients1 = new RoutingItemCollection(new Guid("{A81631A6-6AA3-45f7-AADD-4853447E5BD6}"), "{63A4F19E-332A-4006-BD0A-688BD184CB9F}");
            recipients1.Add(address1);
            recipients1.Add(address2);
            RoutingItemCollection recipients2 = new RoutingItemCollection(new Guid("{FA13BE82-9EB1-407e-9DD5-8005F3E840E4}"), "{852F1BEC-CCB6-4203-8701-89CAE87EA97B}");
            recipients2.Add(address3);
            recipients2.Add(address4);

            catalogueWriter.WriteLocationCollection(recipients1);
            catalogueWriter.WriteLocationCollection(recipients2);

            catalogueWriter.Close();

            TestHelpers.CompareXml(m_testPath + "ExpectedWriteAddressGroup.xml", catalogueStore.GetStoreXML(catalogueId));
        }
        public void TestWriteAddressAttributes()
        {
            Guid languageId = new Guid("{A2F11E75-7E10-4668-9FB5-FCB8E3841C8F}");
            PolicyLanguage language = new PolicyLanguage(languageId, "en");
            language[new Guid("{A2A6EA49-8CB2-4578-8BD5-EBCD57A1B424}")] = "Test sources";
            language[new Guid("{EBF8443B-4912-44F2-89BE-A0A055332D1B}")] = "This is my first custom property";
            language[new Guid("{8053E60C-EED7-464D-84EA-ECB51C291237}")] = "This is my second custom property";

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

            XMLPolicyCatalogueStore catalogueStore = XMLPolicyCatalogueStore.Instance;
            catalogueStore.Reset();
            Guid catalogueGuid = new Guid("{8CF1172E-476C-46A5-AECF-A7A8BC5ACE30}");
            PolicyCatalogue policyCatalogue = new PolicyCatalogue(catalogueGuid, languageId, catalogueStore);

            RoutingItemCollection addressCollection = new RoutingItemCollection(new Guid("{8E915159-5F01-41B3-9FFF-20731544ADFA}"), "{A2A6EA49-8CB2-4578-8BD5-EBCD57A1B424}");
            RoutingItem address = new RoutingItem(new Guid("{625C4BDE-907F-4751-BDA1-0E59EDBBCE5C}"), "James", "[email protected]");
            address["custom1"] = new TranslateableLanguageItem("{EBF8443B-4912-44F2-89BE-A0A055332D1B}");
            address["custom2"] = new TranslateableLanguageItem("{8053E60C-EED7-464D-84EA-ECB51C291237}");
            addressCollection.Add(address);

            IPolicyCatalogueWriter policyCatalogueWriter = catalogueStore.GetWriter(catalogueGuid, languageId);
            policyCatalogueWriter.WriteName("Test catalogue");
            policyCatalogueWriter.WriteLocation(address);
            policyCatalogueWriter.WriteLocationCollection(addressCollection);
            policyCatalogueWriter.Close();

            TestHelpers.CompareXml(m_testPath + "ExpectedWriteAddressAttributes.xml", catalogueStore.GetXMLRepresentation(catalogueGuid));
        }