Beispiel #1
0
        public void TestIsMatch()
        {
            IRouter deviceRouter = new Workshare.Policy.Routing.DeviceRouter.DeviceRouter();

            IUniversalRoutingEntity sourceEntity1 = new UniversalRoutingEntity();
            sourceEntity1.PolicyType = PolicyType.ClientRemovableMedia;
            sourceEntity1.RoutingType = Workshare.Policy.Routing.RoutingTypes.Source;
            IRoutingItem routingItem = new RoutingItem("MyDeviceType1");
            routingItem.Properties.Add(RemovableDeviceItemPropertyKeys.ContentType, RemovableDeviceItemContentTypes.DeviceType);
            sourceEntity1.Items.Add(routingItem); 
            routingItem = new RoutingItem("MyVolumeName1");
            routingItem.Properties.Add(RemovableDeviceItemPropertyKeys.ContentType, RemovableDeviceItemContentTypes.VolumeName);
            sourceEntity1.Items.Add(routingItem); 
            routingItem = new RoutingItem("MyVolumeId1");
            routingItem.Properties.Add(RemovableDeviceItemPropertyKeys.ContentType, RemovableDeviceItemContentTypes.VolumeID);
            sourceEntity1.Items.Add(routingItem);

            IUniversalRoutingEntity targetEntity1 = new UniversalRoutingEntity();
            targetEntity1.PolicyType = PolicyType.ClientRemovableMedia;
            targetEntity1.RoutingType = Workshare.Policy.Routing.RoutingTypes.Source;
            routingItem = new RoutingItem("MyDeviceType0");
            routingItem.Properties.Add(RemovableDeviceItemPropertyKeys.ContentType, RemovableDeviceItemContentTypes.DeviceType);
            targetEntity1.Items.Add(routingItem);
            routingItem = new RoutingItem("MyDeviceType1");
            routingItem.Properties.Add(RemovableDeviceItemPropertyKeys.ContentType, RemovableDeviceItemContentTypes.DeviceType);
            targetEntity1.Items.Add(routingItem);
            routingItem = new RoutingItem("MyVolumeName1");
            routingItem.Properties.Add(RemovableDeviceItemPropertyKeys.ContentType, RemovableDeviceItemContentTypes.VolumeName);
            targetEntity1.Items.Add(routingItem);
            routingItem = new RoutingItem("MyVolumeName2");
            routingItem.Properties.Add(RemovableDeviceItemPropertyKeys.ContentType, RemovableDeviceItemContentTypes.VolumeName);
            targetEntity1.Items.Add(routingItem);
            routingItem = new RoutingItem("MyVolumeId1");
            routingItem.Properties.Add(RemovableDeviceItemPropertyKeys.ContentType, RemovableDeviceItemContentTypes.VolumeID);
            targetEntity1.Items.Add(routingItem);

            IUniversalRoutingEntity targetEntity2 = new UniversalRoutingEntity();
            targetEntity2.PolicyType = PolicyType.ClientRemovableMedia;
            targetEntity2.RoutingType = Workshare.Policy.Routing.RoutingTypes.Source;
            routingItem = new RoutingItem("MyDeviceType1");
            routingItem.Properties.Add(RemovableDeviceItemPropertyKeys.ContentType, RemovableDeviceItemContentTypes.DeviceType);
            targetEntity2.Items.Add(routingItem);
            routingItem = new RoutingItem("MyVolumeId1");
            routingItem.Properties.Add(RemovableDeviceItemPropertyKeys.ContentType, RemovableDeviceItemContentTypes.VolumeID);
            targetEntity2.Items.Add(routingItem);

            IUniversalRoutingEntity targetEntity3 = new UniversalRoutingEntity();
            targetEntity3.PolicyType = PolicyType.ClientRemovableMedia;
            targetEntity3.RoutingType = Workshare.Policy.Routing.RoutingTypes.Source;
            routingItem = new RoutingItem("MyDeviceType1");
            routingItem.Properties.Add(RemovableDeviceItemPropertyKeys.ContentType, RemovableDeviceItemContentTypes.DeviceType);
            targetEntity3.Items.Add(routingItem);
            routingItem = new RoutingItem("MyVolumeName2");
            routingItem.Properties.Add(RemovableDeviceItemPropertyKeys.ContentType, RemovableDeviceItemContentTypes.VolumeName);
            targetEntity3.Items.Add(routingItem);
            routingItem = new RoutingItem("MyVolumeId1");
            routingItem.Properties.Add(RemovableDeviceItemPropertyKeys.ContentType, RemovableDeviceItemContentTypes.VolumeID);
            targetEntity3.Items.Add(routingItem);

            IUniversalRoutingEntity targetEntity4 = new UniversalRoutingEntity();
            targetEntity4.PolicyType = PolicyType.ClientRemovableMedia;
            targetEntity4.RoutingType = Workshare.Policy.Routing.RoutingTypes.Source;
            routingItem = new RoutingItem("MyDeviceType1");
            routingItem.Properties.Add(RemovableDeviceItemPropertyKeys.ContentType, RemovableDeviceItemContentTypes.DeviceType);
            targetEntity4.Items.Add(routingItem);

            IUniversalRoutingEntity targetEntity5 = new UniversalRoutingEntity();
            targetEntity5.PolicyType = PolicyType.ClientRemovableMedia;
            targetEntity5.RoutingType = Workshare.Policy.Routing.RoutingTypes.Source;
            routingItem = new RoutingItem("MyDeviceType1");
            routingItem.Properties.Add(RemovableDeviceItemPropertyKeys.ContentType, RemovableDeviceItemContentTypes.DeviceType);
            targetEntity5.Items.Add(routingItem);
            routingItem = new RoutingItem("MyVolumeId2");
            routingItem.Properties.Add(RemovableDeviceItemPropertyKeys.ContentType, RemovableDeviceItemContentTypes.VolumeID);
            targetEntity5.Items.Add(routingItem);

            IUniversalRoutingEntity targetEntity6 = new UniversalRoutingEntity();
            targetEntity6.PolicyType = PolicyType.ClientRemovableMedia;
            targetEntity6.RoutingType = Workshare.Policy.Routing.RoutingTypes.Source;
            routingItem = new RoutingItem("MyDeviceType2");
            routingItem.Properties.Add(RemovableDeviceItemPropertyKeys.ContentType, RemovableDeviceItemContentTypes.DeviceType);
            targetEntity6.Items.Add(routingItem);

            //invalid data
            Assert.IsFalse(deviceRouter.IsMatch(null, null), "Expected null data to return false");
            Assert.IsFalse(deviceRouter.IsMatch(sourceEntity1, null), "Expected null data to return false");
            Assert.IsFalse(deviceRouter.IsMatch(null, targetEntity1), "Expected null data to return false");

            //nominal case. Matching Type, Id and Name are explicitly listed in target
            Assert.IsTrue(deviceRouter.IsMatch(sourceEntity1, targetEntity1), "Expected nominal case to return true");

            //Matching, but no volume names explicitly listed in target
            Assert.IsTrue(deviceRouter.IsMatch(sourceEntity1, targetEntity2), "Expected unstated volume name to return true");

            //Not matching, as volume name is not listed in target
            Assert.IsFalse(deviceRouter.IsMatch(sourceEntity1, targetEntity3), "Expected incorrect volume name to return false");

            //Matching, but no volume name or id explicitly listed in target
            Assert.IsTrue(deviceRouter.IsMatch(sourceEntity1, targetEntity4), "Expected unstated volume id or name to return true");

            //Not matching, as volume id is not listed in target
            Assert.IsFalse(deviceRouter.IsMatch(sourceEntity1, targetEntity5), "Expected incorrect volume id to return false");

            //Not matching, as device type is not listed in target
            Assert.IsFalse(deviceRouter.IsMatch(sourceEntity1, targetEntity6), "Expected incorrect device type to return false");

            //different routing types on entities
            sourceEntity1.RoutingType = Workshare.Policy.Routing.RoutingTypes.Destination;
            Assert.IsFalse(deviceRouter.IsMatch(sourceEntity1, targetEntity1), "Expected mismatching routing types on entities to return false");

            //different request types on entities
            sourceEntity1.RoutingType = Workshare.Policy.Routing.RoutingTypes.Source;
            sourceEntity1.PolicyType = PolicyType.ActiveContent;
            Assert.IsFalse(deviceRouter.IsMatch(sourceEntity1, targetEntity1), "Expected mismatching request types on entities to return false");

        }
Beispiel #2
0
 public void TestIsEnabled()
 {
     IRouter deviceRouter = new Workshare.Policy.Routing.DeviceRouter.DeviceRouter();
     Assert.IsTrue(deviceRouter.IsEnabled(), "device router should be enabled");
 }