示例#1
0
        public void TestConstructor()
        {
            Workshare.Policy.Routing.LDAPRouter router = new Workshare.Policy.Routing.LDAPRouter();

            Assert.AreEqual("LDAP Router", router.DefaultDisplayName);
            Assert.AreEqual(1, router.SupportedChannels.Length);
            Assert.AreEqual(Workshare.Policy.ChannelType.SMTP, router.SupportedChannels[0]);
        }
示例#2
0
        public void TestIsMatch()
        {
            //setup
            Workshare.Policy.Routing.LDAPRouter router = new Workshare.Policy.Routing.LDAPRouter();

            UniversalRoutingEntity sourceEntity1 = new UniversalRoutingEntity();
            sourceEntity1.PolicyType = PolicyType.ClientEmail;
            sourceEntity1.RoutingType = Workshare.Policy.Routing.RoutingTypes.Source;
            RoutingItem smtpRoutingItem1 = new RoutingItem("[email protected]");
            sourceEntity1.Items.Add(smtpRoutingItem1);

            UniversalRoutingEntity sourceEntity2 = new UniversalRoutingEntity();
            sourceEntity2.PolicyType = PolicyType.ClientEmail;
            sourceEntity2.RoutingType = Workshare.Policy.Routing.RoutingTypes.Source;
            RoutingItem smtpRoutingItem2 = new RoutingItem("[email protected]");
            sourceEntity2.Items.Add(smtpRoutingItem2);
            RoutingItem smtpRoutingItem3 = new RoutingItem("*****@*****.**");
            sourceEntity2.Items.Add(smtpRoutingItem3);

            UniversalRoutingEntity sourceEntity3 = new UniversalRoutingEntity();
            sourceEntity3.PolicyType = PolicyType.ClientEmail;
            sourceEntity3.RoutingType = Workshare.Policy.Routing.RoutingTypes.Source;
            RoutingItem smtpRoutingItem4 = new RoutingItem("*****@*****.**");
            sourceEntity3.Items.Add(smtpRoutingItem4);

            UniversalRoutingEntity targetEntity1 = new UniversalRoutingEntity();
            targetEntity1.PolicyType = PolicyType.ClientEmail;
            targetEntity1.RoutingType = Workshare.Policy.Routing.RoutingTypes.Source;
            RoutingItem smtpTargetRoutingItem1 = new RoutingItem("[email protected]");
            targetEntity1.Items.Add(smtpTargetRoutingItem1);
            RoutingItem smtpTargetRoutingItem2 = new RoutingItem("c=US;a= ;p=WSDEV;o=Exchange;s=Pair;g=SF");
            targetEntity1.Items.Add(smtpTargetRoutingItem2);

            UniversalRoutingEntity targetEntity2 = new UniversalRoutingEntity();
            targetEntity1.PolicyType = PolicyType.ClientEmail;
            targetEntity1.RoutingType = Workshare.Policy.Routing.RoutingTypes.Source;

            //test invalid inputs
            Assert.IsFalse(router.IsMatch(sourceEntity1, null));
            Assert.IsFalse(router.IsMatch(null, targetEntity1));
            Assert.IsFalse(router.IsMatch(null, null));

            //nominal - all addresses are in target
            Assert.IsTrue(router.IsMatch(sourceEntity1, targetEntity1), "Expected all addresses in target to return true");

            //some, but not all, addresses are in target
            Assert.IsFalse(router.IsMatch(sourceEntity2, targetEntity1), "Expected some addresses in target to return false");

            //no addresses are in target
            Assert.IsFalse(router.IsMatch(sourceEntity3, targetEntity1), "Expected no addresses in target to return false");

            //test mismatching request type
            sourceEntity1.PolicyType = PolicyType.ClientRemovableMedia;
            Assert.IsFalse(router.IsMatch(sourceEntity1, targetEntity1), "Expected mismatching request types to return false");
            sourceEntity1.PolicyType = PolicyType.ClientEmail;

            //test mismatching routing type
            sourceEntity1.RoutingType = Workshare.Policy.Routing.RoutingTypes.Destination;
            Assert.IsFalse(router.IsMatch(sourceEntity1, targetEntity1), "Expected mismatching routing types to return false");
            sourceEntity1.RoutingType = Workshare.Policy.Routing.RoutingTypes.Source;

            //no target routing items
            Assert.IsFalse(router.IsMatch(sourceEntity1, targetEntity2), "Expected no target routing items to return false");

            //no source routing items
            sourceEntity1.Items.Clear();
            Assert.IsFalse(router.IsMatch(sourceEntity1, targetEntity1), "Expected no source routing items to return false");

        }