コード例 #1
0
		public void PropertySet()
		{
			//setup
			IActionWrapperClass wrapper = new IActionWrapperClass(new UserAction());

			//execute
			ActionPropertySet set = wrapper.PropertySet;

			Assert.IsNull(set, "Default set should be null");
		}
コード例 #2
0
		public void SupportsMime()
		{
			IActionWrapperClass wrapper = new IActionWrapperClass(new UserAction());
			IActionWrapperClass w2 = new IActionWrapperClass(new MimeOnlyAction());

			Assert.IsTrue(wrapper.Capabilities.SupportsMime, "{0} should support email", wrapper.GetType().ToString());
			Assert.IsTrue(w2.Capabilities.SupportsMime, "{0} should support email", w2.GetType().ToString());
			Assert.IsFalse(wrapper.Capabilities.SupportsContainers, "{0} shouldnt support email", wrapper.GetType().ToString());
		}
コード例 #3
0
		public void ExecuteMime()
		{
			//setup
			IActionWrapperClass wrapper = new IActionWrapperClass(new MimeOnlyAction());
			ActionData testData = new ActionData();
			testData.AttachmentFiles = new Collection<IRequestAttachment>();
			ActionPropertySet props = new ActionPropertySet();
			//execute
			Stream output = wrapper.ExecuteMime(testData, props);

			//verify
			StreamReader sr = new StreamReader(output);
			string exeOutput = sr.ReadToEnd().TrimEnd('\r', '\n');

			Assert.AreEqual(typeof(MimeOnlyAction).FullName, exeOutput, "Expecting full typename to be written to the stream");
			Assert.AreEqual(1, int.Parse(testData.Properties["ExecuteCalled"]), "Execute should be called only once");
		}
コード例 #4
0
		public void ExecuteMime_Abort()
		{
			IActionWrapperClass wrapper = new IActionWrapperClass(new MimeOnlyAction());
			ActionData testData = new ActionData();
			testData.AttachmentFiles = new Collection<IRequestAttachment>();
			ActionPropertySet props = new ActionPropertySet();

			testData.Properties[IActionWrapperClass.ABORT] = bool.FalseString;

			Stream output = wrapper.ExecuteMime(testData, props);

			Assert.IsNotNull(output, "Although abort property was present, the value was not true.  Hence no exception expected.");

			testData.Properties[IActionWrapperClass.ABORT] = bool.TrueString;

			try
			{
				//execute
				output = wrapper.ExecuteMime(testData, props);
			}
			catch (AbortActionException)
			{
				Assert.IsTrue(true, "Expecting to arrive here when abort property was added");
				return;
			}

			Assert.Fail("Should have thrown an abort exception");
		}
コード例 #5
0
		public void Execute()
		{
			//setup
			IActionWrapperClass wrapper = new IActionWrapperClass(new BasicAction());
			ActionData testData = new ActionData();
			//testData.Content = new MemoryStream();
			testData.Tag = "Execute.txt";
			testData.DisplayName = "Execute.txt";
			string file = CreateFile("Execute.txt");
			testData.FileName = file;
			testData.Properties["DisplayName"] = "Execute.txt";

			ActionPropertySet props = new ActionPropertySet();
			
			//execute
			string output = wrapper.Execute(testData, props);
			Assert.IsTrue(output == file, "Input file and output file should be the same.");
			Assert.IsTrue(!String.IsNullOrEmpty(output) && System.IO.File.Exists(output));			
			Assert.AreEqual(1, int.Parse(testData.Properties["ExecuteCalled"]), "Execute should be called only once");
		}
コード例 #6
0
		public void Execute_Abort()
		{
			IActionWrapperClass wrapper = new IActionWrapperClass(new BasicAction());
			ActionData testData = new ActionData();
			testData.Tag = "Execute_Abort.txt";
			testData.DisplayName = "Execute_Abort.txt";
			string file = CreateFile("Execute_Abort.txt");
			testData.FileName = file;
			testData.Properties["DisplayName"] = "Execute_Abort.txt";

			ActionPropertySet props = new ActionPropertySet();

			testData.Properties[IActionWrapperClass.ABORT] = bool.FalseString;
			string output = wrapper.Execute(testData, props);
			Assert.IsTrue(!String.IsNullOrEmpty(output) &&  System.IO.File.Exists(output) , "Although abort property was present, the value was not true.  Hence no exception expected.");
			testData.Properties[IActionWrapperClass.ABORT] = bool.TrueString;
			try
			{
				//execute
				testData.FileName = CreateFile("Execute_Abort.txt");
				output = wrapper.Execute(testData, props);
			}
			catch (AbortActionException)
			{
				Assert.IsTrue(true, "Expecting to arrive here when abort property was added");
				return;
			}

			Assert.Fail("Should have thrown an abort exception");
		}
コード例 #7
0
		public void ClientActionControl()
		{
			//setup
			IActionWrapperClass basicActionWrapper = new IActionWrapperClass(new BasicAction());
			IActionWrapperClass userActionWrapper = new IActionWrapperClass(new UserAction());

			//execute & verify
			Assert.IsNull(basicActionWrapper.ClientActionControl, "ClientControl should be null for plain IAction");            
			Assert.IsInstanceOf(typeof(ClientActionControl), userActionWrapper.ClientActionControl, "UserControl be a ClientActionControl IUserAction");
		}
コード例 #8
0
		public void ActionIcon()
		{
			//setup
			IActionWrapperClass basicActionWrapper = new IActionWrapperClass(new BasicAction());
			IActionWrapperClass userActionWrapper = new IActionWrapperClass(new UserAction());

			//execute & verify
			Assert.IsNull(basicActionWrapper.ActionIcon, "Icon should be null for plain IAction");
			Assert.IsInstanceOf(typeof(Bitmap), userActionWrapper.ActionIcon, "Icon should be a Bitmap for IUserAction");                        
		}
コード例 #9
0
		public void MergeProperties()
		{
			//setup
			IActionWrapperClass wrapper = new IActionWrapperClass(new UserAction());

			//execute
			ActionPropertySet result = wrapper.MergeProperties(
				new ActionPropertySet[] { new ActionPropertySet(), new ActionPropertySet() });
			//verify
			Assert.IsNotNull(result, "A merged set of properties should be returned");
			Assert.IsTrue(result.ContainsKey("ThisWasMerged"), "Merged set of properties should contain ThisWasMerged key");
			Assert.AreEqual("sisterhood", result["ThisWasMerged"].Value.ToString(), "Incorrect property value returned in merged set");
		}
コード例 #10
0
		public void SupportedFileCollection()
		{
			//setup
			MimeOnlyAction action = new MimeOnlyAction();
			IActionWrapperClass wrapper = new IActionWrapperClass(action);
			//execute
			ISupportedFilesSet fileset = wrapper.SupportedFileCollection;

			//verify
			Assert.AreEqual(1, fileset.SupportedFiles().Length, "Only expected support for .email");
			Assert.AreEqual(0, fileset.UnsupportedFiles().Length, "Unsupported file list should be zero");
			Assert.IsTrue(fileset.Supports(".email"), "Action should support for .email");
			Assert.IsFalse(fileset.Supports(".ppt"), "Not expecting support for .ppt");
		}
コード例 #11
0
		public void LanguageSupport()
		{
			//setup
			BasicAction basic = new BasicAction();
			IActionWrapperClass wrapper = new IActionWrapperClass(basic);

			//execute
			ILanguageExtension languages = wrapper.LanguageSupport;

			//verify
			Assert.IsTrue(languages.Supports("CZ"), "The action doesnt support CZ");
			Assert.IsTrue(languages.Supports("XZ"), "The action doesnt support XZ");
			Assert.AreEqual("XZ", languages.DefaultTwoLetterISOLanguageName, "Expecting default language to be XZ");
			Assert.AreEqual(1, languages.Languages.Count, "Expecting only one item in the languages dictionary");
		}