public void TestSkipVerified_GetPolicyResponse()
		{
			Workshare.PolicyContent.Policy @in = new Workshare.PolicyContent.Policy();
			IPolicyResponse @out = PolicyAdaptor.GetIPolicyResponse(@in);
			Assert.IsFalse(@out.SkipVerifiedMessages, "By default assume that skipverified is false.");

			CustomProperty skipVerified = new CustomProperty(PolicyConstants.SkipVerifiedMessages, bool.TrueString);
			@in.Properties = new CustomProperty[] { skipVerified };
			@out = PolicyAdaptor.GetIPolicyResponse(@in);
			Assert.IsTrue(@out.SkipVerifiedMessages, "The value should correspond to the custom property.");

			@in.Properties[0].Value = bool.FalseString;
			@out = PolicyAdaptor.GetIPolicyResponse(@in);
			Assert.IsFalse(@out.SkipVerifiedMessages, "The value should correspond to the custom property.");
		}
示例#2
0
		internal static Workshare.PolicyContent.Policy GetPolicy(IPolicyResponse policyResponse)
		{
			if (null == policyResponse)
				throw new ArgumentNullException("policyResponse");

			Workshare.PolicyContent.Policy policy = new Workshare.PolicyContent.Policy();

			policy.Audit = policyResponse.Audit;
			policy.Description = policyResponse.Description;
			policy.Name = policyResponse.Name;
			policy.Triggered = policyResponse.Triggered;

			if ( policyResponse.Routing != null)
				policy.Routing = RoutingAdaptor.GetRouting(policyResponse.Routing);

			int index = 0;
			//policy.Properties = new CustomProperty[0];
			List<CustomProperty> customProps = new List<CustomProperty>();

			/// bonafide properties
			if (policyResponse.Properties != null && policyResponse.Properties.Count > 0)
			{
				foreach (KeyValuePair<string, string> kvp in policyResponse.Properties)
				{
					customProps.Add(new CustomProperty(kvp.Key, kvp.Value));
				}
			}
			/// add blockOnExecution as a property cause we cant change contracts. same goes for skipVerifiedMessages
			/// 
			PolicyResponse pr = policyResponse as PolicyResponse;
			if (pr != null)
			{
				customProps.Add(new CustomProperty(PolicyAdaptor.ExecuteBlockProp, pr.BlockOnException.ToString()));

				customProps.Add(new CustomProperty(PolicyConstants.SkipVerifiedMessages, pr.SkipVerifiedMessages.ToString()));
			}

			policy.Properties = customProps.ToArray();


			policy.Actions = new Workshare.PolicyContent.Action[0];
			if (policyResponse.ActionCollection != null && policyResponse.ActionCollection.Count > 0)
			{
				policy.Actions = new Workshare.PolicyContent.Action[policyResponse.ActionCollection.Count];
				index = 0;
				foreach (IPolicyResponseAction action in policyResponse.ActionCollection)
				{
					policy.Actions[index++] = ActionAdaptor.GetAction(action);
				}
			}

			policy.Expressions = new Expression[0];
			if (policyResponse.ExpressionCollection != null && policyResponse.ExpressionCollection.Count > 0)
			{
				index = 0;
				policy.Expressions = new Expression[policyResponse.ExpressionCollection.Count];
				foreach (IExpressionResponse response in policyResponse.ExpressionCollection)
				{
					Expression exp = ExpressionAdaptor.GetExpression(response);
					exp.Audit = policy.Audit;
					policy.Expressions[index++] = exp;
				}
			}
			
			
			return policy;
		}