Exemplo n.º 1
0
		public void EnsureContentItemDetailsArePropagatedOnActionException()
		{
			#region setup
			MockUserAction.MockActionInitializer configuration = Utilities.ThreadSafeLazyLoadSingletonT<MockUserAction.MockActionInitializer>.Instance;
			configuration.ExecuteMethod = new MockUserAction.ExecuteMethod(delegate(IActionData3 input, ActionPropertySet set)
			{
				throw new DataMisalignedException("A rather esoteric exception");
			}
			);
			configuration.SupportedFiles = SupportedFileSet.CreateFileCollection(".*", "");

			List<string> attachments = new List<string>();
			attachments.Add(Path.Combine(TEST_FOLDER, "TestProfanity.doc"));

			ReturnData retValue = SetupMockActionTest(attachments);
			IContainer container = retValue.Container;

			Workshare.Policy.Engine.Tests.TestUroPolicyEngine.MockProgressCallback policyEvents =
				new Workshare.Policy.Engine.Tests.TestUroPolicyEngine.MockProgressCallback();

			ActionExecuter executer = new ActionExecuter(policyEvents);
			#endregion

			try
			{
				executer.ExecuteActions(retValue.Pro, ref container);
			}
			catch (System.Exception e)
			{
				Assert.IsInstanceOf(typeof(PolicyActionException), e);
				PolicyActionException paeThrown = e as PolicyActionException;

				Assert.IsTrue(paeThrown.Action.StartsWith("MockUser"), "Action name in exception incorrect {0}, expecting MockUser action", paeThrown.Action);
				Assert.AreEqual(Path.GetFileName(attachments[0]), paeThrown.ContentId, "Expected filename in exception details");

			}
		}
Exemplo n.º 2
0
		public void ExecuteEventsRaised()
		{
			int count = 0;
			#region setup
			MockUserAction.MockActionInitializer configuration = Utilities.ThreadSafeLazyLoadSingletonT<MockUserAction.MockActionInitializer>.Instance;
			configuration.ExecuteMethod = new MockUserAction.ExecuteMethod(delegate(IActionData3 input, ActionPropertySet set)
			{
				count++;
				return input.FileName;
			}
			);
			configuration.SupportedFiles = SupportedFileSet.CreateFileCollection(".*", "");

			List<string> attachments = new List<string>();
			attachments.Add(Path.Combine(TEST_FOLDER, "TestProfanity.doc"));
			attachments.Add(Path.Combine(TEST_FOLDER, "Dirty.doc"));
			attachments.Add(Path.Combine(TEST_FOLDER, "TestDoc.ppt"));
			attachments.Add(Path.Combine(TEST_FOLDER, "Test folder\\Sub Folder\\TestDoc.doc"));

			ReturnData retValue = SetupMockActionTest(attachments);
			IContainer container = retValue.Container;

			Workshare.Policy.Engine.Tests.TestUroPolicyEngine.MockProgressCallback policyEvents =
				new Workshare.Policy.Engine.Tests.TestUroPolicyEngine.MockProgressCallback();

			ActionExecuter executer = new ActionExecuter(policyEvents);

			#endregion

			//execute            
			IUniversalRequestObject outputUro = executer.ExecuteActions(retValue.Pro, ref container);

			Assert.AreEqual(outputUro.Attachments.Count, policyEvents.AfterExecuteEventArgs.Count, "{0} before execute events should have been fired", outputUro.Attachments.Count);
			Assert.AreEqual(outputUro.Attachments.Count, policyEvents.BeforeExecuteEventArgs.Count, "{0} before execute events should have been fired", outputUro.Attachments.Count);
			Assert.AreEqual(outputUro.Attachments.Count, count, "Expected {0} files to be processed", outputUro.Attachments.Count);
		}
Exemplo n.º 3
0
		public void ActionBlowsUpButAllowsUserPrompt()
		{
			#region setup
			MockUserAction.MockActionInitializer configuration = Utilities.ThreadSafeLazyLoadSingletonT<MockUserAction.MockActionInitializer>.Instance;
			configuration.ExecuteMethod = new MockUserAction.ExecuteMethod(delegate(IActionData3 input, ActionPropertySet set)
			{
				throw new DataMisalignedException("A rather esoteric exception");
			}
			);
			configuration.SupportedFiles = SupportedFileSet.CreateFileCollection(".*", "");

			List<string> attachments = new List<string>();
			attachments.Add(Path.Combine(TEST_FOLDER, "TestProfanity.doc"));

			ReturnData retValue = SetupMockActionTest(attachments);
			IContainer container = retValue.Container;

			Workshare.Policy.Engine.Tests.TestUroPolicyEngine.MockProgressCallback policyEvents =
				new Workshare.Policy.Engine.Tests.TestUroPolicyEngine.MockProgressCallback();

			ActionExecuter executer = new ActionExecuter(policyEvents);



			// set(enforce) block on exception to false on all policies
			foreach (ContentItem ci in retValue.Pro.ContentCollection)
			{
				foreach (PolicySetResponse psr in ci.PolicySetCollection)
				{
					foreach (PolicyResponse p in psr.PolicyReportCollection)
					{
						if (p.Triggered)
						{
							p.BlockOnException = false;
						}
					}
				}
			}
			#endregion

			try
			{
				executer.ExecuteActions(retValue.Pro, ref container);
			}
			catch (System.Exception e)
			{
				Assert.IsInstanceOf(typeof(PolicyActionException), e);
				PolicyActionException paeThrown = e as PolicyActionException;

				Assert.IsTrue(paeThrown.Action.StartsWith("MockUser"), "Action name in exception incorrect {0}, expecting MockUser action", paeThrown.Action);
				Assert.AreEqual(ActionExceptionHandling.Prompt, paeThrown.ExceptionHandling, "This exception should result in a block");
			}
		}