public void RethrowInTry() { TestRethrow tr = new TestRethrow(); TestTryCatch root = new TestTryCatch("parent TryCatch") { Try = new TestSequence { Activities = { new TestProductWriteline("W1"), new TestThrow <TAC.ApplicationException> { ExceptionExpression = (context => new TAC.ApplicationException("abcd")), }, tr } }, Catches = { new TestCatch <TAC.ApplicationException> { Body = new TestRethrow() } }, }; TestRuntime.ValidateInstantiationException(root, string.Format(ErrorStrings.RethrowNotInATryCatch, tr.DisplayName)); }
public void SameActivityMultipleTimesInSameSequence() { // Test case description: // Add same activity multiple times to same sequence TestSequence sequence = new TestSequence("ContainerSequence"); TestSequence sequence2 = new TestSequence("Seq"); TestWriteLine writeLine1 = new TestWriteLine("Hello One"); writeLine1.Message = "Hello world!"; TestWriteLine writeLine2 = new TestWriteLine("Hello Two"); writeLine2.Message = "Hello world!"; //begin:same sequence object with default name in a sequence sequence.Activities.Add(sequence2); sequence.Activities.Add(sequence2); //end:same sequence object with default name in a sequence TestRuntime.ValidateInstantiationException(sequence, string.Format(ErrorStrings.ActivityCannotBeReferencedWithoutTarget, sequence2.DisplayName, sequence.DisplayName, sequence.DisplayName)); }
public void TryOROnIncompatibleTypes() { TestOr <int, string, int> intOr = new TestOr <int, string, int> { Right = "3" }; TestRuntime.ValidateInstantiationException(intOr, TestExpressionTracer.GetExceptionMessage <int, string, int>(System.Linq.Expressions.ExpressionType.Or)); }
public void TryAccessPrivatePropertyOnAnObject() { PublicType myObj = new PublicType(); TestPropertyValue <PublicType, int> propertyValue = new TestPropertyValue <PublicType, int>(myObj, "PrivateProperty"); TestRuntime.ValidateInstantiationException(propertyValue, string.Format(ErrorStrings.MemberNotFound, "PrivateProperty", typeof(PublicType).Name)); }
public void AddFlowchartToItself() { TestFlowchart flow = new TestFlowchart(); flow.AddLink(new TestWriteLine("w1", "w1"), flow); TestRuntime.ValidateInstantiationException(flow, string.Format(ErrorStrings.ActivityCannotReferenceItself, flow.DisplayName)); }
public void TryNotEqualsOnIncompatibleTypes() { TestNotEqual <int, string, int> notEq = new TestNotEqual <int, string, int> { Right = "3" }; TestRuntime.ValidateInstantiationException(notEq, TestExpressionTracer.GetExceptionMessage <int, string, int>(System.Linq.Expressions.ExpressionType.NotEqual)); }
public void PropertyNameNull() { TestPropertyReference <PublicType, int> propRef = new TestPropertyReference <PublicType, int> { Operand = new PublicType() }; TestRuntime.ValidateInstantiationException(propRef, string.Format(ErrorStrings.ActivityPropertyMustBeSet, "PropertyName", propRef.DisplayName)); }
public void TryGettingValueOfPropertyNameNull() { TestPropertyValue <PublicType, int> propertyValue = new TestPropertyValue <PublicType, int> { Operand = new PublicType() }; TestRuntime.ValidateInstantiationException(propertyValue, string.Format(ErrorStrings.ActivityPropertyMustBeSet, "PropertyName", propertyValue.DisplayName)); }
public void TryANDOnIncompatibleTypes() { TestAnd <bool, string, bool> and = new TestAnd <bool, string, bool> { Left = true, Right = "true" }; TestRuntime.ValidateInstantiationException(and, TestExpressionTracer.GetExceptionMessage <bool, string, bool>(exp.ExpressionType.And)); }
public void TryEqualsOnIncompatibleTypes() { TestEqual <int, string, string> eq = new TestEqual <int, string, string> { Left = 12, Right = "12" }; TestRuntime.ValidateInstantiationException(eq, TestExpressionTracer.GetExceptionMessage <int, string, string>(System.Linq.Expressions.ExpressionType.Equal)); }
public void SubtractTwoIncompatibleTypes() { TestSubtract <int, string, string> sub = new TestSubtract <int, string, string> { Left = 12, Right = "12" }; TestRuntime.ValidateInstantiationException(sub, TestExpressionTracer.GetExceptionMessage <int, string, string>(exp.ExpressionType.Subtract)); }
public void AddTwoIncompatibleTypes() { TestAdd <int, string, string> add = new TestAdd <int, string, string> { Left = 12, Right = "12" }; TestRuntime.ValidateInstantiationException(add, TestExpressionTracer.GetExceptionMessage <int, string, string>(exp.ExpressionType.Add)); }
public void SameVariableAddedTwiceOnSameSequence() { TestSequence sequence = new TestSequence("Sequence"); Variable <int> intVariable = VariableHelper.Create <int>("some integer"); sequence.Variables.Add(intVariable); sequence.Variables.Add(intVariable); TestRuntime.ValidateInstantiationException(sequence, string.Format(ErrorStrings.VariableAlreadyInUseOnActivity, intVariable.Name, sequence.DisplayName, sequence.DisplayName)); }
public void TryAccessingFieldNotProperty() { PublicType myObj = new PublicType { publicField = "10" }; TestPropertyValue <PublicType, int> propertyValue = new TestPropertyValue <PublicType, int>(myObj, "publicField"); TestRuntime.ValidateInstantiationException(propertyValue, ""); }
public void MultiplyTwoIncompatibleTypes() { TestMultiply <int, string, string> multiply = new TestMultiply <int, string, string> { Left = 12, Right = "12" }; TestRuntime.ValidateInstantiationException(multiply, TestExpressionTracer.GetExceptionMessage <int, string, string>(exp.ExpressionType.Multiply)); }
public void TryAccessingPropertyWithoutGetter() { PublicType myObj = new PublicType { WriteOnlyProperty = 1 }; TestPropertyValue <PublicType, int> propertyValue = new TestPropertyValue <PublicType, int>(myObj, "WriteOnlyProperty"); TestRuntime.ValidateInstantiationException(propertyValue, ""); }
public void ConditionExpressionSetToNull() { TestFlowConditional conditional = new TestFlowConditional(); conditional.ProductFlowConditional.Condition = null; TestFlowchart flowchart = new TestFlowchart(); flowchart.AddConditionalLink(null, conditional, new TestWriteLine("True", "True"), new TestWriteLine("False", "False")); TestRuntime.ValidateInstantiationException(flowchart, string.Format(ErrorStrings.FlowDecisionRequiresCondition, flowchart.DisplayName)); }
public void WhileConditionNull() { // Test case description: // Set condition to null TestWhile whileAct = new TestWhile("while act") { Body = new TestSequence("innerseq"), HintIterationCount = 0, }; ((System.Activities.Statements.While)whileAct.ProductActivity).Condition = null; TestRuntime.ValidateInstantiationException(whileAct, String.Format(ErrorStrings.WhileRequiresCondition, whileAct.DisplayName)); }
public void LinkFromNestedFlowchartToParent() { TestFlowchart parent = new TestFlowchart("Parent"); TestFlowchart child = new TestFlowchart("Child"); TestWriteLine w1 = new TestWriteLine("w1", "w1"); TestWriteLine w2 = new TestWriteLine("w2", "w2"); TestWriteLine w3 = new TestWriteLine("w3", "w3"); parent.AddLink(w1, w2); parent.AddLink(w2, child); child.AddLink(w3, w2); TestRuntime.ValidateInstantiationException(parent, string.Format(ErrorStrings.ActivityCannotBeReferencedWithoutTarget, w2.DisplayName, child.DisplayName, parent.DisplayName)); }
public void CreateFlowlinkToActivityInNestedFlowchart() { // This testCase is a pair for: LinkFromNestedFlowchartToParent() TestFlowchart parentFlowchart = new TestFlowchart("Parent"); TestFlowchart childFlowchart = new TestFlowchart("Child"); TestWriteLine writeLine1 = new TestWriteLine("hello1", "Hello1"); TestWriteLine writeLine2 = new TestWriteLine("hello2", "Hello2"); parentFlowchart.AddLink(childFlowchart, writeLine1); parentFlowchart.AddLink(writeLine1, writeLine2); childFlowchart.AddStartLink(writeLine2); TestRuntime.ValidateInstantiationException(parentFlowchart, string.Format(ErrorStrings.ActivityCannotBeReferencedWithoutTarget, writeLine2.DisplayName, childFlowchart.DisplayName, parentFlowchart.DisplayName)); }
public void DoWhileConditionNull() { // Test case description: // Set condition to null TestDoWhile doWhile = new TestDoWhile("dowhile") { Condition = true, Body = new TestSequence("inner seq"), HintIterationCount = 0, }; Microsoft.CoreWf.Statements.DoWhile productDoWhile = (Microsoft.CoreWf.Statements.DoWhile)doWhile.ProductActivity; productDoWhile.Condition = null; TestRuntime.ValidateInstantiationException(doWhile, String.Format("Condition must be set before DoWhile activity '{0}' can be used.", doWhile.DisplayName)); }
public void TryAccessVariableInNestedFlowchartFromParent() { TestFlowchart parent = new TestFlowchart(); TestFlowchart child = new TestFlowchart(); Variable <int> counter = VariableHelper.CreateInitialized <int>(0); child.Variables.Add(counter); parent.AddLink(new TestIncrement { IncrementCount = 1, CounterVariable = counter, ExpectedOutcome = Outcome.UncaughtException() }, child); child.AddStartLink(new TestWriteLine("Wont execute", "Will not execute")); TestRuntime.ValidateInstantiationException(parent, string.Format(ErrorStrings.VariableNotVisible, counter.Name)); }
public void FlowStepActionToNestedActivityInSequence() { TestFlowchart flowchart = new TestFlowchart(); TestWriteLine w1 = new TestWriteLine("w1", "w1"); TestWriteLine w2 = new TestWriteLine("w2", "w2"); TestWriteLine w3 = new TestWriteLine("w3", "w3"); TestSequence seq = new TestSequence(); seq.Activities.Add(w2); flowchart.AddLink(w1, seq); flowchart.AddLink(seq, w3); flowchart.AddLink(w3, w2); TestRuntime.ValidateInstantiationException(flowchart, string.Format(ErrorStrings.ActivityCannotBeReferencedWithoutTarget, w2.DisplayName, seq.DisplayName, flowchart.DisplayName)); }
public void OneTriggerNotSet() { TestPick pick = new TestPick() { DisplayName = "PickActivity", Branches = { new TestPickBranch() { DisplayName = "Branch1", Trigger = new TestWriteLine("Trigger1") { Message = "Trigger1", }, Action = new TestWriteLine("Action1") { Message = "Action1", }, }, new TestPickBranch() { DisplayName = "Branch2", Action = new TestWriteLine("Action2") { Message = "Action2", }, }, new TestPickBranch() { DisplayName = "Branch3", Trigger = new TestWriteLine("Trigger3") { Message = "Trigger3", }, Action = new TestWriteLine("Action3") { Message = "Action3", }, }, } }; TestRuntime.ValidateInstantiationException(pick, String.Format(ErrorStrings.PickBranchRequiresTrigger, pick.Branches[1].DisplayName)); }
public void AddSameElementToParentAndChild() { TestFlowchart flowchart1 = new TestFlowchart("flowChart1"); TestFlowchart flowchart2 = new TestFlowchart("flowChart2"); TestWriteLine w1 = new TestWriteLine("W1", "Executing W1"); TestFlowElement fStep = new TestFlowStep(w1); flowchart2.Elements.Add(fStep); Variable <int> margin = VariableHelper.CreateInitialized <int>("Margin", 10); flowchart1.Variables.Add(margin); TestFlowConditional flowDecision = new TestFlowConditional(HintTrueFalse.True); flowDecision.ConditionExpression = (context => margin.Get(context) > 0); TestFlowElement tCond = flowchart1.AddConditionalLink(null, flowDecision, fStep, flowchart2); TestRuntime.ValidateInstantiationException(flowchart1, string.Format(ErrorStrings.FlowNodeCannotBeShared, flowchart1.DisplayName, flowchart2.DisplayName)); }
public void RethrowOutSideOfTryCatch() { TestRethrow tr = new TestRethrow(); TestSequence seq = new TestSequence { Activities = { tr, new TestWriteLine { ExpectedOutcome = Outcome.None, Message = "this should not run", HintMessage = "nothing" } } }; TestRuntime.ValidateInstantiationException(seq, string.Format(ErrorStrings.RethrowNotInATryCatch, tr.DisplayName)); }
public void RethrowFromCatchHandlerOfPrivateActivity() { string message = "this is expected uncaught exception"; TestCustomActivity <TestRethrowInPrivateChildren> rethrowAct = new TestCustomActivity <TestRethrowInPrivateChildren>() { ExpectedOutcome = Outcome.UncaughtException(), }; rethrowAct.CustomActivityTraces.Add(new ActivityTrace("Rethrow", CoreWf.ActivityInstanceState.Executing)); rethrowAct.CustomActivityTraces.Add(new ActivityTrace("Rethrow", CoreWf.ActivityInstanceState.Faulted)); TestTryCatch ttc = new TestTryCatch("parent TryCatch") { Try = new TestSequence { Activities = { new TestProductWriteline("W1"), new TestThrow <TestCaseException> { ExceptionExpression = (context => new TestCaseException(message)), ExpectedOutcome = Outcome.CaughtException(typeof(TestCaseException)), } } }, Catches = { new TestCatch <TestCaseException> { Body = rethrowAct } } }; //The validation error has a prefix: string validationError = string.Format(ErrorStrings.ValidationErrorPrefixForHiddenActivity, "2: " + rethrowAct.DisplayName) + string.Format(ErrorStrings.RethrowMustBeAPublicChild, "Rethrow"); TestRuntime.ValidateInstantiationException(ttc, validationError); }
public void RethrowInFinally() { TestRethrow tr = new TestRethrow(); TestTryCatch root = new TestTryCatch("parent TryCatch") { Try = new TestSequence { Activities = { new TestProductWriteline("W1"), new TestThrow <TAC.ApplicationException> { ExceptionExpression = (context => new TAC.ApplicationException("abcd")), ExpectedOutcome = Outcome.CaughtException(typeof(TAC.ApplicationException)), } } }, Catches = { new TestCatch <TAC.ApplicationException>() }, Finally = new TestSequence { Activities = { new TestSequence { Activities = { tr } } } } }; TestRuntime.ValidateInstantiationException(root, string.Format(ErrorStrings.RethrowNotInATryCatch, tr.DisplayName)); }
public void FlowSwitchWithExpressionNull() { TestFlowchart flowchart1 = new TestFlowchart("flowChart1"); TestWriteLine start1 = new TestWriteLine("Start", "Executing Start"); TestWriteLine w1 = new TestWriteLine("W1", "Executing W1"); TestWriteLine w2 = new TestWriteLine("W2", "Executing W2"); TestWriteLine wDefault = new TestWriteLine("wDefault", "Executing wDefault"); Dictionary <object, TestActivity> cases = new Dictionary <object, TestActivity>(); cases.Add("One", w1); cases.Add("Two", w2); List <int> hints = new List <int>(); hints.Add(-1); TestFlowSwitch <object> fSwitch = (TestFlowSwitch <object>)flowchart1.AddSwitchLink <object>(start1, cases, hints, (object)null, wDefault); ((FlowSwitch <object>)fSwitch.GetProductElement()).Expression = null; // I had to use the product to set a null value to Expression TestRuntime.ValidateInstantiationException(flowchart1, string.Format(ErrorStrings.FlowSwitchRequiresExpression, flowchart1.DisplayName)); }
public void SubtractTwoIncompatibleTypes() { TestDivide <int, double, double> divide = new TestDivide <int, double, double>(4, 4.2); TestRuntime.ValidateInstantiationException(divide, TestExpressionTracer.GetExceptionMessage <int, double, double>(System.Linq.Expressions.ExpressionType.Divide)); }