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"); }
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"); }