Ejemplo n.º 1
0
        /// <summary>
        /// Init
        /// </summary>
        /// <param name="policyResponse"></param>
        /// <param name="policy"></param>
        public PolicyService(IPolicyResponse policyResponse, IPolicy policy)
        {
            if (policyResponse == null)
            {
                throw new ArgumentNullException(nameof(policyResponse));
            }
            if (policy == null)
            {
                throw new ArgumentNullException(nameof(policy));
            }

            _policyResponse = policyResponse;
            _policy         = policy;
        }
Ejemplo n.º 2
0
		/// <summary>
		/// Asserts the IPolicyResponse data for the Test policy in ComplexPolicySet
		/// </summary>
		/// <param name="policyResponse">The IPolicyResponse object to evaluate</param>
		/// <param name="expectedTriggered">The expected value of the Triggered property on the IPolicyResponse object</param>
		/// <param name="expectedDocumentContext">The expected document context. This differs depending on the document that has triggered the policy.</param>
		public void AssertTestPolicyResponse_ComplexPolicySet(IPolicyResponse policyResponse, bool expectedTriggered, RunAt runAt, string expectedDocumentContext)
		{
			//data on PolicyResponse
			Assert.AreEqual("Test", policyResponse.Name, "Incorrect name on policy response");
			Assert.AreEqual("", policyResponse.Description, "Incorrect description on policy response");
			Assert.AreEqual(expectedTriggered, policyResponse.Triggered, "Incorrect triggered on policy response");
			Assert.AreEqual(false, policyResponse.Audit, "Incorrect audit on policy response");
			Assert.AreEqual(1, policyResponse.ExpressionCollection.Count, "Incorrect number of expression responses on policy response");

			//data on PolicyResponse.ExpressionCollection[0]
			IExpressionResponse expressionResponse = policyResponse.ExpressionCollection[0];
			Assert.AreEqual("", expressionResponse.Description, "Incorrect description on expression response");
			Assert.AreEqual("test detected", expressionResponse.Name, "Incorrect name on expression response");
			Assert.AreEqual("Medium", expressionResponse.Rating, "Incorrect rating on expression response");
			Assert.AreEqual(expectedTriggered, expressionResponse.Triggered, "Incorrect triggered on expression response");
			Assert.AreEqual(0, expressionResponse.Properties.Count, "Incorrect properties on expressionResponse");

			//data on PolicyResponse.ExpressionCollection[0].ExpressionDetailCollection            
			if (expectedTriggered)
			{
				Assert.AreEqual(2, expressionResponse.ExpressionDetailCollection.Count, "Incorrect expression detail object on expression response");
				IExpressionDetail expressionDetail = expressionResponse.ExpressionDetailCollection[0];
				Assert.AreEqual(expectedDocumentContext, expressionDetail.Name, "Incorrect name on expression detail");
				Assert.AreEqual("test", expressionDetail.Value, "Incorrect value on expression detail");
				expressionDetail = expressionResponse.ExpressionDetailCollection[1];
				Assert.AreEqual(expectedDocumentContext, expressionDetail.Name, "Incorrect name on expression detail");
				Assert.AreEqual("test", expressionDetail.Value, "Incorrect value on expression detail");
			}
			else
			{
				Assert.AreEqual(0, expressionResponse.ExpressionDetailCollection.Count, "Incorrect expression detail object on expression response");
			}

			//data on PolicyResponse.Routing
			IRoutingResponse routingResponse = policyResponse.Routing;
			if (expectedTriggered)
			{
				Assert.AreEqual(null, routingResponse.Description, "Incorrect description on routing response"); //ok, as this is an optional property
				Assert.AreEqual("Sent to External Recipients", routingResponse.Name, "Incorrect name on routing response");
				Assert.AreEqual("Low", routingResponse.Rating, "Incorrect rating on routing response");
				Assert.AreEqual(0, routingResponse.Properties.Count, "Incorrect number of properties on routing response");
			}
			else
			{
				Assert.IsNull(routingResponse, "Incorrect routing response on policy response");
			}

			//data on PolicyResponse.ActionCollection
			if (expectedTriggered)
			{
				if (RunAt.Client == runAt)
				{
					//only expect actions if running on client
					Assert.AreEqual(2, policyResponse.ActionCollection.Count, "Incorrect number of policy response action objects on policy response");

					IPolicyResponseAction policyResponseAction = policyResponse.ActionCollection[0];
					Assert.AreEqual("Alert Action", policyResponseAction.Name, "Incorrect name on policy response action");
					Assert.AreEqual("Alert", policyResponseAction.Type, "Incorrect type on policy response action");
					Assert.AreEqual(false, policyResponseAction.Overridden, "Incorrect overridden on policy response action");
					Assert.AreEqual(false, policyResponseAction.Processed, "Incorrect processed on policy response action");
					Assert.AreEqual(1, policyResponseAction.Properties.Count, "Incorrect number of properties on policy response action");
					Assert.AreEqual("False", policyResponseAction.Properties["ExceptionAction"], "Incorrect number of properties on policy response action");

					//data on PolicyResponse.ActionCollection[0].ActionPropertyCollection
					Assert.AreEqual(2, policyResponseAction.ActionPropertyCollection.Count, "Incorrect number of properties on policy response action");
					IActionPropertyResponse actionPropertyResponse = policyResponseAction.ActionPropertyCollection[0];
					Assert.AreEqual("EXECUTE", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[1];
					Assert.AreEqual("Description", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("Alert description", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");

					policyResponseAction = policyResponse.ActionCollection[1];
					Assert.AreEqual("Block Action", policyResponseAction.Name, "Incorrect name on policy response action");
					Assert.AreEqual("Block", policyResponseAction.Type, "Incorrect type on policy response action");
					Assert.AreEqual(false, policyResponseAction.Overridden, "Incorrect overridden on policy response action");
					Assert.AreEqual(false, policyResponseAction.Processed, "Incorrect processed on policy response action");
					Assert.AreEqual(1, policyResponseAction.Properties.Count, "Incorrect number of properties on policy response action");
					Assert.AreEqual("True", policyResponseAction.Properties["ExceptionAction"], "Incorrect number of properties on policy response action");

					//data on PolicyResponse.ActionCollection[1].ActionPropertyCollection
					Assert.AreEqual(2, policyResponseAction.ActionPropertyCollection.Count, "Incorrect number of properties on policy response action");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[0];
					Assert.AreEqual("EXECUTE", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[1];
					Assert.AreEqual("Description", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("Exception action", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
				}
				else
				{
					//only expect actions if running on client
					Assert.AreEqual(0, policyResponse.ActionCollection.Count, "Incorrect number of policy response action objects on policy response");
				}
			}
			else
			{
				Assert.IsNull(policyResponse.ActionCollection, "Incorrect number of policy response action objects on policy response");
			} 
		}
Ejemplo n.º 3
0
		/// <summary>
		/// Asserts the IPolicyResponse data for the ZipBigFile policy in ComplexPolicySet
		/// </summary>
		/// <param name="policyResponse">The IPolicyResponse object to evaluate</param>
		/// <param name="expectedTriggered">The expected value of the Triggered property on the IPolicyResponse object</param>
		private void AssertZipBigFilePolicyResponse_ComplexPolicySet(IPolicyResponse policyResponse, bool expectedTriggered, RunAt runAt)
		{
			//data on PolicyResponse
			Assert.AreEqual("Zip big files", policyResponse.Name, "Incorrect name on policy response");
			Assert.AreEqual("", policyResponse.Description, "Incorrect description on policy response");
			Assert.AreEqual(expectedTriggered, policyResponse.Triggered, "Incorrect triggered on policy response");
			Assert.AreEqual(false, policyResponse.Audit, "Incorrect audit on policy response");
			Assert.AreEqual(1, policyResponse.ExpressionCollection.Count, "Incorrect number of expression responses on policy response");

			//data on PolicyResponse.ExpressionCollection[0]
			IExpressionResponse expressionResponse = policyResponse.ExpressionCollection[0];
			Assert.AreEqual("", expressionResponse.Description, "Incorrect description on expression response");
			Assert.AreEqual("File > 200k", expressionResponse.Name, "Incorrect name on expression response");
			Assert.AreEqual("Medium", expressionResponse.Rating, "Incorrect rating on expression response");
			Assert.AreEqual(expectedTriggered, expressionResponse.Triggered, "Incorrect triggered on expression response");
			Assert.AreEqual(0, expressionResponse.Properties.Count, "Incorrect number of properties on expression response");

			//data on PolicyResponse.ExpressionCollection[0].ExpressionDetailCollection[0]
			if (expectedTriggered)
			{
				Assert.AreEqual(1, expressionResponse.ExpressionDetailCollection.Count, "Incorrect number of expression details on expression response");
				IExpressionDetail expressionDetail = expressionResponse.ExpressionDetailCollection[0];
				Assert.AreEqual("ConditionSummary", expressionDetail.Name, "Incorrect name on expression detail");
				Assert.AreEqual("File size is greater than 200Kb", expressionDetail.Value, "Incorrect value on expression detail");
			}
			else
			{
				if ((null != policyResponse.ActionCollection) && !HasZipAction(policyResponse.ActionCollection))
				{
					Assert.Fail("Incorrect number of policy response action objects on policy response");
				}
			}

			//data on PolicyResponse.Routing
			IRoutingResponse routingResponse = policyResponse.Routing;
			if (expectedTriggered)
			{
				Assert.AreEqual(null, routingResponse.Description, "Incorrect description on routing response"); //ok, as this is an optional property
				Assert.AreEqual("Sent to External Recipients", routingResponse.Name, "Incorrect name on routing response");
				Assert.AreEqual("Low", routingResponse.Rating, "Incorrect rating on routing response");
				Assert.AreEqual(0, routingResponse.Properties.Count, "Incorrect number of properties on routing response");
			}
			else
			{
				if ((null != policyResponse) && (null != policyResponse.ActionCollection) && !HasZipAction(policyResponse.ActionCollection))
				{
					Assert.Fail("Incorrect routing response on policy response");
				}
			}

			//data on PolicyResponse.ActionCollection
			if (expectedTriggered)
			{
				if (RunAt.Client == runAt)
				{
					//only expect actions if running on client
					Assert.AreEqual(2, policyResponse.ActionCollection.Count, "Incorrect number of policy response action objects on policy response");

					IPolicyResponseAction policyResponseAction = policyResponse.ActionCollection[0];
					Assert.AreEqual("Zip Action", policyResponseAction.Name, "Incorrect name on policy response action");
					Assert.AreEqual("Zip", policyResponseAction.Type, "Incorrect type on policy response action");
					Assert.AreEqual(false, policyResponseAction.Overridden, "Incorrect overridden on policy response action");
					Assert.AreEqual(false, policyResponseAction.Processed, "Incorrect processed on policy response action");
					Assert.AreEqual(1, policyResponseAction.Properties.Count, "Incorrect number of properties on policy response action");
					Assert.AreEqual("False", policyResponseAction.Properties["ExceptionAction"], "Incorrect number of properties on policy response action");

					//data on PolicyResponse.ActionCollection[0].ActionPropertyCollection
					Assert.AreEqual(7, policyResponseAction.ActionPropertyCollection.Count, "Incorrect number of properties on policy response action");
					IActionPropertyResponse actionPropertyResponse = policyResponseAction.ActionPropertyCollection[0];
					Assert.AreEqual("EXECUTE", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[1];
					Assert.AreEqual("PasswordRequired", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("False", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[2];
					Assert.AreEqual("EnforceStrongPassword", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("False", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[3];
					Assert.AreEqual("Password", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[4];
					Assert.AreEqual("ZIPAttachedFiles", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("False", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[5];
					Assert.AreEqual("AES128", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("False", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");

					policyResponseAction = policyResponse.ActionCollection[1];
					Assert.AreEqual("Block Action", policyResponseAction.Name, "Incorrect name on policy response action");
					Assert.AreEqual("Block", policyResponseAction.Type, "Incorrect type on policy response action");
					Assert.AreEqual(false, policyResponseAction.Overridden, "Incorrect overridden on policy response action");
					Assert.AreEqual(false, policyResponseAction.Processed, "Incorrect processed on policy response action");
					Assert.AreEqual(1, policyResponseAction.Properties.Count, "Incorrect number of properties on policy response action");
					Assert.AreEqual("True", policyResponseAction.Properties["ExceptionAction"], "Incorrect number of properties on policy response action");

					//data on PolicyResponse.ActionCollection[1].ActionPropertyCollection
					Assert.AreEqual(2, policyResponseAction.ActionPropertyCollection.Count, "Incorrect number of properties on policy response action");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[0];
					Assert.AreEqual("EXECUTE", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[1];
					Assert.AreEqual("Description", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("Exception action", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
				}
				else
				{
					//only expect actions if running on client
					Assert.AreEqual(0, policyResponse.ActionCollection.Count, "Incorrect number of policy response action objects on policy response");
				}
			}
			else
			{
				if ((null != policyResponse.ActionCollection) && !HasZipAction(policyResponse.ActionCollection))
				{
					Assert.Fail("Incorrect number of policy response action objects on policy response");
				}
			}        
		}
Ejemplo n.º 4
0
		/// <summary>
		/// Asserts the IPolicyResponse data for the ConvertWordToPdf policy in ComplexPolicySet
		/// </summary>
		/// <param name="policyResponse">The IPolicyResponse object to evaluate</param>
		/// <param name="expectedTriggered">The expected value of the Triggered property on the IPolicyResponse object</param>
		private void AssertConvertWordToPdfPolicyResponse_ComplexPolicySet(IPolicyResponse policyResponse, bool expectedTriggered, RunAt runAt)
		{
			//data on PolicyResponse
			Assert.AreEqual("PDF word docs", policyResponse.Name, "Incorrect name on policy response");
			Assert.AreEqual("All word documents should be converted to PDF", policyResponse.Description, "Incorrect description on policy response");
			Assert.AreEqual(expectedTriggered, policyResponse.Triggered, "Incorrect triggered on policy response");
			Assert.AreEqual(false, policyResponse.Audit, "Incorrect audit on policy response");
			Assert.AreEqual(1, policyResponse.ExpressionCollection.Count, "Incorrect number of expression responses on policy response");

			//data on PolicyResponse.ExpressionCollection[0]
			IExpressionResponse expressionResponse = policyResponse.ExpressionCollection[0];
			Assert.AreEqual("", expressionResponse.Description, "Incorrect description on expression response");
			Assert.AreEqual("File is word document", expressionResponse.Name, "Incorrect name on expression response");
			Assert.AreEqual("Medium", expressionResponse.Rating, "Incorrect rating on expression response");
			Assert.AreEqual(expectedTriggered, expressionResponse.Triggered, "Incorrect triggered on expression response");
			Assert.AreEqual(0, expressionResponse.Properties.Count, "Incorrect number of properties on expression response");

			//data on PolicyResponse.ExpressionCollection[0].ExpressionDetailCollection[0]
			if (expectedTriggered)
			{
				Assert.AreEqual(1, expressionResponse.ExpressionDetailCollection.Count, "Incorrect number of expression details on expression response");
				IExpressionDetail expressionDetail = expressionResponse.ExpressionDetailCollection[0];
				Assert.AreEqual("ConditionSummary", expressionDetail.Name, "Incorrect name on expression detail");
				Assert.AreEqual("File type is Word (.doc)", expressionDetail.Value, "Incorrect value on expression detail");
			}
			else
			{
				Assert.AreEqual(0, expressionResponse.ExpressionDetailCollection.Count, "Incorrect number of expression details on expression response");
			}

			//data on PolicyResponse.Routing
			IRoutingResponse routingResponse = policyResponse.Routing;
			if (expectedTriggered)
			{
				Assert.AreEqual(null, routingResponse.Description, "Incorrect description on routing response"); //ok, as this is an optional property
				Assert.AreEqual("Sent to External Recipients", routingResponse.Name, "Incorrect name on routing response");
				Assert.AreEqual("Low", routingResponse.Rating, "Incorrect rating on routing response");
				Assert.AreEqual(0, routingResponse.Properties.Count, "Incorrect number of properties on routing response");
			}
			else
			{
				Assert.IsNull(routingResponse, "Incorrect routing response on policy response");
			}

			//data on PolicyResponse.ActionCollection
			if (expectedTriggered)
			{
				if (RunAt.Client == runAt)
				{
					//only expect actions if running on client
					Assert.AreEqual(2, policyResponse.ActionCollection.Count, "Incorrect number of policy response action objects on policy response");

					IPolicyResponseAction policyResponseAction = policyResponse.ActionCollection[0];
					Assert.AreEqual("PDF Action", policyResponseAction.Name, "Incorrect name on policy response action");
					Assert.AreEqual("PDF", policyResponseAction.Type, "Incorrect type on policy response action");
					Assert.AreEqual(false, policyResponseAction.Overridden, "Incorrect overridden on policy response action");
					Assert.AreEqual(false, policyResponseAction.Processed, "Incorrect processed on policy response action");
					Assert.AreEqual(1, policyResponseAction.Properties.Count, "Incorrect number of properties on policy response action");
					Assert.AreEqual("False", policyResponseAction.Properties["ExceptionAction"], "Incorrect number of properties on policy response action");

					//data on PolicyResponse.ActionCollection[0].ActionPropertyCollection
					Assert.AreEqual(12, policyResponseAction.ActionPropertyCollection.Count, "Incorrect number of properties on policy response action");
					IActionPropertyResponse actionPropertyResponse = policyResponseAction.ActionPropertyCollection[0];
					Assert.AreEqual("EXECUTE", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[1];
					Assert.AreEqual("ProhibitPrinting", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[2];
					Assert.AreEqual("ProhibitEdit", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[3];
					Assert.AreEqual("ProhibitCopy", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[4];
					Assert.AreEqual("ProhibitComments", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[5];
					Assert.AreEqual("PasswordRequired", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("False", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[6];
					Assert.AreEqual("EnforceStrongPassword", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("False", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[7];
					Assert.AreEqual("Password", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");

					policyResponseAction = policyResponse.ActionCollection[1];
					Assert.AreEqual("Block Action", policyResponseAction.Name, "Incorrect name on policy response action");
					Assert.AreEqual("Block", policyResponseAction.Type, "Incorrect type on policy response action");
					Assert.AreEqual(false, policyResponseAction.Overridden, "Incorrect overridden on policy response action");
					Assert.AreEqual(false, policyResponseAction.Processed, "Incorrect processed on policy response action");
					Assert.AreEqual(1, policyResponseAction.Properties.Count, "Incorrect number of properties on policy response action");
					Assert.AreEqual("True", policyResponseAction.Properties["ExceptionAction"], "Incorrect number of properties on policy response action");

					//data on PolicyResponse.ActionCollection[1].ActionPropertyCollection
					Assert.AreEqual(2, policyResponseAction.ActionPropertyCollection.Count, "Incorrect number of properties on policy response action");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[0];
					Assert.AreEqual("EXECUTE", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[1];
					Assert.AreEqual("Description", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("Exception action", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
				}
				else
				{
					//only expect actions if running on client
					Assert.AreEqual(0, policyResponse.ActionCollection.Count, "Incorrect number of policy response action objects on policy response");
				}
			}
			else
			{
				Assert.IsNull(policyResponse.ActionCollection, "Incorrect number of policy response action objects on policy response");
			}        
		}
Ejemplo n.º 5
0
		/// <summary>
		/// Asserts the IPolicyResponse data for the Swearing policy in ComplexPolicySet
		/// </summary>
		/// <param name="policyResponse">The IPolicyResponse object to evaluate</param>
		/// <param name="expectedTriggered">The expected value of the Triggered property on the IPolicyResponse object</param>
		private void AssertSwearingPolicyResponse_ComplexPolicySet(IPolicyResponse policyResponse, bool expectedTriggered, RunAt runAt)
		{
			//data on PolicyResponse
			Assert.AreEqual("Don't swear", policyResponse.Name, "Incorrect name on policy response");
			Assert.AreEqual("Any document containing swearing will be blocked.", policyResponse.Description, "Incorrect description on policy response");
			Assert.AreEqual(expectedTriggered, policyResponse.Triggered, "Incorrect triggered on policy response");
			Assert.AreEqual(false, policyResponse.Audit, "Incorrect audit on policy response");
			Assert.AreEqual(1, policyResponse.ExpressionCollection.Count, "Incorrect number of expression responses on policy response");

			//data on PolicyResponse.ExpressionCollection[0]
			IExpressionResponse expressionResponse = policyResponse.ExpressionCollection[0];
			Assert.AreEqual("You shouldn't swear.", expressionResponse.Description, "Incorrect description on expression response");
			Assert.AreEqual("Swearing detected", expressionResponse.Name, "Incorrect name on expression response");
			Assert.AreEqual("Medium", expressionResponse.Rating, "Incorrect rating on expression response");
			Assert.AreEqual(expectedTriggered, expressionResponse.Triggered, "Incorrect triggered on expression response");
			Assert.AreEqual(0, expressionResponse.Properties.Count, "Incorrect number of properties on expression response");

			//data on PolicyReposponse.ExpressionCollection[0].ExpressionDetailCollection[0]
			if (expectedTriggered)
			{
				Assert.AreEqual(1, expressionResponse.ExpressionDetailCollection.Count, "Incorrect number of expression details on expression response");
				IExpressionDetail expressionDetail = expressionResponse.ExpressionDetailCollection[0];
				Assert.AreEqual("Paragraph", expressionDetail.Name, "Incorrect name on expression detail");
				Assert.AreEqual("swearing", expressionDetail.Value, "Incorrect value on expression detail");
			}
			else
			{
				Assert.AreEqual(0, expressionResponse.ExpressionDetailCollection.Count, "Incorrect number of expression details on expression response");
			}

			//data on PolicyResponse.Routing
			IRoutingResponse routingResponse = policyResponse.Routing;
			if (expectedTriggered)
			{
				Assert.AreEqual(null, routingResponse.Description, "Incorrect description on routing response"); //ok, as this is an optional property
				Assert.AreEqual("Sent to External Recipients", routingResponse.Name, "Incorrect name on routing response");
				Assert.AreEqual("Low", routingResponse.Rating, "Incorrect rating on routing response");
				Assert.AreEqual(0, routingResponse.Properties.Count, "Incorrect number of properties on routing response");
			}
			else
			{
				Assert.IsNull(routingResponse, "Incorrect routing response on policy response");
			}

			//data on PolicyResponse.ActionCollection
			if (expectedTriggered)
			{
				if (RunAt.Client == runAt)
				{
					//only expect actions if running on client
					Assert.AreEqual(2, policyResponse.ActionCollection.Count, "Incorrect number of policy response action objects on policy response");

					IPolicyResponseAction policyResponseAction = policyResponse.ActionCollection[0];
					Assert.AreEqual("Block Action", policyResponseAction.Name, "Incorrect name on policy response action");
					Assert.AreEqual("Block", policyResponseAction.Type, "Incorrect type on policy response action");
					Assert.AreEqual(false, policyResponseAction.Overridden, "Incorrect overridden on policy response action");
					Assert.AreEqual(true, policyResponseAction.Processed, "Incorrect processed on policy response action");
					Assert.AreEqual(1, policyResponseAction.Properties.Count, "Incorrect number of properties on policy response action");
					Assert.AreEqual("False", policyResponseAction.Properties["ExceptionAction"], "Incorrect number of properties on policy response action");

					//data on PolicyResponse.ActionCollection[0].ActionPropertyCollection
					Assert.AreEqual(2, policyResponseAction.ActionPropertyCollection.Count, "Incorrect number of properties on policy response action");
					IActionPropertyResponse actionPropertyResponse = policyResponseAction.ActionPropertyCollection[0];
					Assert.AreEqual("EXECUTE", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[1];
					Assert.AreEqual("Description", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("Can't send because of searing", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");

					policyResponseAction = policyResponse.ActionCollection[1];
					Assert.AreEqual("Block Action", policyResponseAction.Name, "Incorrect name on policy response action");
					Assert.AreEqual("Block", policyResponseAction.Type, "Incorrect type on policy response action");
					Assert.AreEqual(false, policyResponseAction.Overridden, "Incorrect overridden on policy response action");
					Assert.AreEqual(false, policyResponseAction.Processed, "Incorrect processed on policy response action");
					Assert.AreEqual(1, policyResponseAction.Properties.Count, "Incorrect number of properties on policy response action");
					Assert.AreEqual("True", policyResponseAction.Properties["ExceptionAction"], "Incorrect number of properties on policy response action");

					//data on PolicyResponse.ActionCollection[1].ActionPropertyCollection
					Assert.AreEqual(2, policyResponseAction.ActionPropertyCollection.Count, "Incorrect number of properties on policy response action");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[0];
					Assert.AreEqual("EXECUTE", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[1];
					Assert.AreEqual("Description", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("Exception action", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
				}
				else
				{
					//only expect actions if running on client
					Assert.AreEqual(0, policyResponse.ActionCollection.Count, "Incorrect number of policy response action objects on policy response");
				}
			}
			else
			{
				Assert.IsNull(policyResponse.ActionCollection, "Incorrect number of policy response action objects on policy response");
			}
		}
Ejemplo n.º 6
0
		/// <summary>
		/// Asserts the IPolicyResponse data for the CleanOfficeDoc policy in ComplexPolicySet
		/// </summary>
		/// <param name="policyResponse">The IPolicyResponse object to evaluate</param>
		/// <param name="expectedTriggered">The expected value of the Triggered property on the IPolicyResponse object</param>
		private void AssertCleanOfficeDocPolicyResponse_ComplexPolicySet(IPolicyResponse policyResponse, bool expectedTriggered, RunAt runAt)
		{
			//data on PolicyResponse
			Assert.AreEqual("Clean office docs", policyResponse.Name, "Incorrect name on policy response");
			Assert.AreEqual("All office docs must be cleaned", policyResponse.Description, "Incorrect description on policy response");
			Assert.AreEqual(expectedTriggered, policyResponse.Triggered, "Incorrect triggered on policy response");
			Assert.AreEqual(false, policyResponse.Audit, "Incorrect audit on policy response");
			Assert.AreEqual(1, policyResponse.ExpressionCollection.Count, "Incorrect number of expression responses on policy response");

			//data on PolicyResponse.ExpressionCollection[0]
			IExpressionResponse expressionResponse = policyResponse.ExpressionCollection[0];
			Assert.AreEqual("The files is either a word document, excel spreadsheet or powerpoint slideshow", expressionResponse.Description, "Incorrect description on expression response");
			Assert.AreEqual("File is an office document", expressionResponse.Name, "Incorrect name on expression response");
			Assert.AreEqual("Medium", expressionResponse.Rating, "Incorrect rating on expression response");
			Assert.AreEqual(expectedTriggered, expressionResponse.Triggered, "Incorrect triggered on expression response");
			Assert.AreEqual(0, expressionResponse.Properties.Count, "Incorrect number of properties on expression response");

			//data on PolicyResponse.ExpressionCollection[0].ExpressionDetailCollection[0]
			if (expectedTriggered)
			{
				Assert.AreEqual(1, expressionResponse.ExpressionDetailCollection.Count, "Incorrect number of expression details on expression response");
				IExpressionDetail expressionDetail = expressionResponse.ExpressionDetailCollection[0];
				Assert.AreEqual("ConditionSummary", expressionDetail.Name, "Incorrect name on expression detail");
				Assert.AreEqual("File type is Word (.doc), Excel Spreadsheet (.xls), PowerPoint (.ppt)", expressionDetail.Value, "Incorrect value on expression detail");
			}
			else
			{
				Assert.AreEqual(0, expressionResponse.ExpressionDetailCollection.Count, "Incorrect number of expression details on expression response");
			}

			//data on PolicyResponse.Routing
			IRoutingResponse routingResponse = policyResponse.Routing;
			if (expectedTriggered)
			{
				Assert.AreEqual(null, routingResponse.Description, "Incorrect description on routing response"); //ok, as this is an optional property
				Assert.AreEqual("Sent to External Recipients", routingResponse.Name, "Incorrect name on routing response");
				Assert.AreEqual("Low", routingResponse.Rating, "Incorrect rating on routing response");
				Assert.AreEqual(0, routingResponse.Properties.Count, "Incorrect number of properties on routing response");
			}
			else
			{
				Assert.IsNull(routingResponse, "Incorrect routing response on policy response");
			}

			//data on PolicyResponse.ActionCollection
			if (expectedTriggered)
			{
				if (RunAt.Client == runAt)
				{
					//only expect actions if running on client
					Assert.AreEqual(2, policyResponse.ActionCollection.Count, "Incorrect number of policy response action objects on policy response");

					//data on PolicyResponse.ActionCollection[0]
					IPolicyResponseAction policyResponseAction = policyResponse.ActionCollection[0];
					Assert.AreEqual("Clean Action", policyResponseAction.Name, "Incorrect name on policy response action");
					Assert.AreEqual("Clean", policyResponseAction.Type, "Incorrect type on policy response action");
					Assert.AreEqual(false, policyResponseAction.Overridden, "Incorrect overridden on policy response action");
					Assert.AreEqual(false, policyResponseAction.Processed, "Incorrect processed on policy response action");
					Assert.AreEqual(1, policyResponseAction.Properties.Count, "Incorrect number of properties on policy response action");
					Assert.AreEqual("False", policyResponseAction.Properties["ExceptionAction"], "Incorrect number of properties on policy response action");

					//data on PolicyResponse.ActionCollection[0].ActionPropertyCollection
					Assert.AreEqual(29, policyResponseAction.ActionPropertyCollection.Count, "Incorrect number of properties on policy response action");
					IActionPropertyResponse actionPropertyResponse = policyResponseAction.ActionPropertyCollection[0];
					Assert.AreEqual("EXECUTE", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[1];
					Assert.AreEqual("AllowOverride", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[2];
					Assert.AreEqual("Footnotes", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[3];
					Assert.AreEqual("DocumentStatistics", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[4];
					Assert.AreEqual("BuiltInProperties", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[5];
					Assert.AreEqual("Headers", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[6];
					Assert.AreEqual("Footers", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[7];
					Assert.AreEqual("SmartTags", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[8];
					Assert.AreEqual("Template", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[9];
					Assert.AreEqual("CustomProperties", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[10];
					Assert.AreEqual("DocumentVariables", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[11];
					Assert.AreEqual("Fields", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[12];
					Assert.AreEqual("Macros", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[13];
					Assert.AreEqual("RoutingSlip", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[14];
					Assert.AreEqual("SpeakerNotes", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[15];
					Assert.AreEqual("Links", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[16];
					Assert.AreEqual("Reviewers", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[17];
					Assert.AreEqual("TrackChanges", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[18];
					Assert.AreEqual("Comments", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[19];
					Assert.AreEqual("SmallText", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[20];
					Assert.AreEqual("WhiteText", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[21];
					Assert.AreEqual("HiddenText", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[22];
					Assert.AreEqual("Authors", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[23];
					Assert.AreEqual("HiddenSlides", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[24];
					Assert.AreEqual("AutoVersion", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[25];
					Assert.AreEqual("Versions", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");

					//data on PolicyResponse.ActionCollection[1]
					policyResponseAction = policyResponse.ActionCollection[1];
					Assert.AreEqual("Block Action", policyResponseAction.Name, "Incorrect name on policy response action");
					Assert.AreEqual("Block", policyResponseAction.Type, "Incorrect type on policy response action");
					Assert.AreEqual(false, policyResponseAction.Overridden, "Incorrect overridden on policy response action");
					Assert.AreEqual(false, policyResponseAction.Processed, "Incorrect processed on policy response action");
					Assert.AreEqual(1, policyResponseAction.Properties.Count, "Incorrect number of properties on policy response action");
					Assert.AreEqual("True", policyResponseAction.Properties["ExceptionAction"], "Incorrect number of properties on policy response action");

					//data on PolicyResponse.ActionCollection[1].ActionPropertyCollection
					Assert.AreEqual(2, policyResponseAction.ActionPropertyCollection.Count, "Incorrect number of properties on policy response action");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[0];
					Assert.AreEqual("EXECUTE", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("True", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
					actionPropertyResponse = policyResponseAction.ActionPropertyCollection[1];
					Assert.AreEqual("Description", actionPropertyResponse.Name, "Incorrect name on action property response");
					Assert.AreEqual("Exception action", actionPropertyResponse.Value, "Incorrect value on action property response");
					Assert.AreEqual(0, actionPropertyResponse.Properties.Count, "Incorrect number of properties on action property response");
				}
				else
				{
					//only expect actions if running on client
					Assert.AreEqual(0, policyResponse.ActionCollection.Count, "Incorrect number of policy response action objects on policy response");
				}
			}
			else
			{
				Assert.IsNull(policyResponse.ActionCollection, "Incorrect number of policy response action objects on policy response");
			}

		}
Ejemplo n.º 7
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;
		}
Ejemplo n.º 8
0
 internal static bool ShouldAudit(IPolicyResponse policyInfo)
 {
     return (policyInfo.Audit && policyInfo.Triggered);
 }