public void it_throws_the_exception_created_by_the_user() { var ex = new UserDefinedException(); var wf = new StatefulWorkflow <Entity>() .When(x => true).Fail(f => f.With(x => ex)) .Yield("end"); try { wf.Start(new Entity()); Assert.Fail("an exception should have been thrown"); } catch (UserDefinedException e) { Assert.That(e, Is.SameAs(ex)); } }
private UserDefinedException CreateException(IEnumerable <IdentityError> errors) { var exception = new UserDefinedException(); exception.UserDefinedMessage = new ExceptionMessage(); exception.UserDefinedMessage.Details = new List <ExceptionMessage>(); foreach (var error in errors) { exception.UserDefinedMessage.Details.Add(new ExceptionMessage { Message = error.Description }); } exception.UserDefinedMessage.Message = exception.UserDefinedMessage.Details.First().Message; return(exception); }
static void Main(string[] args) { Console.WriteLine("-- ArrayList --"); ArrayListDemo AlDemo = new ArrayListDemo(); AlDemo.AddNew(); AlDemo.Display(); AlDemo.Sort(); Console.WriteLine("Sorted List."); AlDemo.Display(); Console.WriteLine("-- Stack --"); StackDemo st = new StackDemo(); QueueDemo Q = new QueueDemo(); Console.WriteLine("-- Generic List --"); MyGeneric <string> gen = new MyGeneric <string>(); gen.AddItem("abc"); gen.AddItem("xyz"); Console.WriteLine(gen.GetItem()); Console.WriteLine(gen.GetItem(1)); Console.WriteLine("-- Exceptions --"); //UserDefinedException uexp = new UserDefinedException(); try { UserDefinedException.ThrowUserDefinedException(); } catch (UserDefinedException ex) { Console.WriteLine("Exception : " + ex.Message); } try { UserDefinedException.ThrowUserDefinedException("New Message"); } catch (UserDefinedException ex) { Console.WriteLine("Exception : " + ex.Message); } Console.WriteLine("\n-- Format Deemo --"); FormattingDemo.Display(); DisplayXMLContents(); MyList list = new MyList(); Console.WriteLine(list.ToString()); Console.WriteLine("-- AbstractClass static methos--"); Console.WriteLine(AbstractClass.Display("Hello")); Console.WriteLine("-- Yield Example --"); foreach (int i in YieldExample.Power(2, 8)) { Console.Write("{0} ", i); } //// Single Thread Example. Console.WriteLine("\n\nSingle Thread Example.\n"); ThreadDemo thread1 = new ThreadDemo(); ThreadDemo thread2 = new ThreadDemo("FromMain"); Console.WriteLine("Single Thread Ended"); //// Single Thread Example. Console.WriteLine("\n\nTwo Threads Example.\n"); TwoThreads twoThreads = new TwoThreads("Child#1", "Child#2"); Console.WriteLine("Two Threads Ended"); Console.ReadKey(); }
public static void messageWarningBox(UserDefinedException ex, string nombreVentana) //muestra una ventana con icono de advertencia { MessageBox.Show(ex.mensaje, nombreVentana, MessageBoxButtons.OK, MessageBoxIcon.Warning); }
public static void messageErrorBox(UserDefinedException ex, string nombreVentana) //muestra una ventana con icono de error { MessageBox.Show(ex.mensaje, nombreVentana, MessageBoxButtons.OK, MessageBoxIcon.Error); }
public void it_throws_the_exception_created_by_the_user() { var ex = new UserDefinedException(); var wf = new StatefulWorkflow<Entity>() .When(x => true).Fail(f => f.With(x => ex)) .Yield("end"); try { wf.Start(new Entity()); Assert.Fail("an exception should have been thrown"); } catch (UserDefinedException e) { Assert.That(e, Is.SameAs(ex)); } }