public void TestConstructor()
        {
            Workshare.Policy.Routing.InternalExternalRouter router = new Workshare.Policy.Routing.InternalExternalRouter();

            Assert.AreEqual("Internal/External Router", router.DefaultDisplayName);
            Assert.AreEqual(1, router.SupportedChannels.Length);
            Assert.AreEqual(Workshare.Policy.ChannelType.SMTP, router.SupportedChannels[0]);
        }
        public void TestIsMatch()
        {
            //set up activation context here so that the real code doesn't try to read the manifest from the nunit shadow cache
			using (WsActivationContext wsac = new WsActivationContext())
            {
                //test setup
                Workshare.Policy.Routing.InternalExternalRouter router = new Workshare.Policy.Routing.InternalExternalRouter();

                UniversalRoutingEntity sourceEntity1 = new UniversalRoutingEntity();
                sourceEntity1.PolicyType = PolicyType.ClientEmail;
                sourceEntity1.RoutingType = Workshare.Policy.Routing.RoutingTypes.Source;
                sourceEntity1.Properties.Add(SMTPPropertyKeys.RequestChannel, RequestChannels.Outlook);
                RoutingItem smtpRoutingItem1 = new RoutingItem("*****@*****.**");
                smtpRoutingItem1.Properties[SMTPItemPropertyKeys.Internal] = true.ToString();
                sourceEntity1.Items.Add(smtpRoutingItem1);

                UniversalRoutingEntity smtpTargetEntity = new UniversalRoutingEntity();
                smtpTargetEntity.PolicyType = PolicyType.ClientEmail;
                smtpTargetEntity.RoutingType = Workshare.Policy.Routing.RoutingTypes.Source;
                smtpTargetEntity.Properties.Add(SMTPPropertyKeys.RequestChannel, RequestChannels.Outlook);
                RoutingItem smtpTargetRoutingItem = new RoutingItem("Recipients:Internal");
                smtpTargetEntity.Items.Add(smtpTargetRoutingItem);

                //test null data
                Assert.IsFalse(router.IsMatch(sourceEntity1, null), "Expected null data to return false");
                Assert.IsFalse(router.IsMatch(null, smtpTargetEntity), "Expected null data to return false");
                Assert.IsFalse(router.IsMatch(null, null), "Expected null data to return false");

                //nominal case - includes internal only
                Assert.IsTrue(router.IsMatch(sourceEntity1, smtpTargetEntity), "Expected nominal internal address to return true");

                // mixture of internal and external
                UniversalRoutingEntity sourceEntity2 = new UniversalRoutingEntity();
                sourceEntity2.PolicyType = PolicyType.ClientEmail;
                sourceEntity2.RoutingType = Workshare.Policy.Routing.RoutingTypes.Source;
                sourceEntity2.Properties.Add(SMTPPropertyKeys.RequestChannel, RequestChannels.Outlook);
                RoutingItem smtpRoutingItem2 = new RoutingItem("*****@*****.**");
                sourceEntity2.Items.Add(smtpRoutingItem2);
                RoutingItem smtpRoutingItem3 = new RoutingItem("*****@*****.**");
                sourceEntity2.Items.Add(smtpRoutingItem3);

                Assert.IsFalse(router.IsMatch(sourceEntity2, smtpTargetEntity), "Expected mixture of internal and external address to return false");

                //external only
                UniversalRoutingEntity sourceEntity3 = new UniversalRoutingEntity();
                sourceEntity3.PolicyType = PolicyType.ClientEmail;
                sourceEntity3.RoutingType = Workshare.Policy.Routing.RoutingTypes.Source;
                sourceEntity3.Properties.Add(SMTPPropertyKeys.RequestChannel, RequestChannels.Outlook);
                RoutingItem smtpRoutingItem4 = new RoutingItem("*****@*****.**");
                sourceEntity3.Items.Add(smtpRoutingItem4);

                Assert.IsFalse(router.IsMatch(sourceEntity3, smtpTargetEntity), "Expected external address to return false");

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

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

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

                //no routing items in target
                smtpTargetEntity.Items.Clear();
                Assert.IsFalse(router.IsMatch(sourceEntity1, smtpTargetEntity), "Expected no routing items in destination to return false");

                //no request channel property
                sourceEntity1.Properties.Remove(SMTPPropertyKeys.RequestChannel);
                Assert.IsFalse(router.IsMatch(sourceEntity1, smtpTargetEntity), "Expected missing requestchannel property to return false");
            }
        }