public async Task Test___Method_Start___Status_Created___not_Empty() { var value = new AnyVariable <string>(); var to = new AnyVariable <string>(); var testee = new ForEachActivity() { Enumerable = new AnyVariable <IEnumerable>() { Value = new List <string>() { "foo", "bar", "baz" } }, Value = value, Activity = new AssignActivity() { To = to, Value = value } }; await testee.Start(); Assert.AreEqual(ActivityStatus.Completed, testee.Status); Assert.AreEqual("baz", to.GetValueAsObject()); }
public async Task Test___Method_Reset___Status_Completed() { var to = new AnyVariable <int>() { Value = 0 }; var value = new AnyVariable <int>() { Value = 10 }; var testee = new AssignActivity() { To = to, Value = value }; await testee.Start(); Assert.AreEqual(ActivityStatus.Completed, testee.Status); Assert.AreEqual(10, to.GetValueAsObject()); testee.Reset(); Assert.AreEqual(ActivityStatus.Created, testee.Status); }
public void Test___Method_Reset___Status_Stopped() { var to = new AnyVariable <int>() { Value = 0 }; var value = new AnyVariable <int>() { Value = 10 }; var testee = new AssignActivity() { To = to, Value = value }; testee.Stop(); Assert.AreEqual(ActivityStatus.Stopped, testee.Status); Assert.AreEqual(0, to.GetValueAsObject()); testee.Reset(); Assert.AreEqual(ActivityStatus.Created, testee.Status); }
public async Task Test___Method_Start___Status_Created() { var variable1 = new AnyVariable <int>(); var variable2 = new AnyVariable <int>(); var testee = new SequenceActivity() { Activities = new List <IActivity>() { new AssignActivity() { To = variable1, Value = new AnyVariable <int>() { Value = 10 } }, new AssignActivity() { To = variable2, Value = new AnyVariable <int>() { Value = 20 } } } }; await testee.Start(); Assert.AreEqual(ActivityStatus.Completed, testee.Status); Assert.AreEqual(10, variable1.GetValueAsObject()); Assert.AreEqual(20, variable2.GetValueAsObject()); }
public void Test___Method_Stop___Status_Created() { var variable1 = new AnyVariable <int>(); var variable2 = new AnyVariable <int>(); var testee = new SequenceActivity() { Activities = new List <IActivity>() { new AssignActivity() { To = variable1, Value = new AnyVariable <int>() { Value = 10 } }, new AssignActivity() { To = variable2, Value = new AnyVariable <int>() { Value = 20 } } } }; testee.Stop(); Assert.AreEqual(ActivityStatus.Stopped, testee.Status); Assert.IsNull(variable1.GetValueAsObject()); Assert.IsNull(variable2.GetValueAsObject()); }
public void Test___Method_Reset___Status_Stopped() { var to = new AnyVariable <int>() { Value = 0 }; var testee = new IfActivity() { Condition = new TrueCondition(), Then = new AssignActivity() { To = to, Value = new AnyVariable <int>() { Value = 1 } }, Else = new AssignActivity() { To = to, Value = new AnyVariable <int>() { Value = 2 } } }; testee.Stop(); Assert.AreEqual(ActivityStatus.Stopped, testee.Status); Assert.AreEqual(0, to.GetValueAsObject()); testee.Reset(); Assert.AreEqual(ActivityStatus.Created, testee.Status); }
public async Task Test___Method_Start___Status_Created___Else_Completed() { var to = new AnyVariable <int>() { Value = 0 }; var testee = new IfActivity() { Condition = new FalseCondition(), Then = new AssignActivity() { To = to, Value = new AnyVariable <int>() { Value = 1 } }, Else = new AssignActivity() { To = to, Value = new AnyVariable <int>() { Value = 2 } } }; await testee.Start(); Assert.AreEqual(ActivityStatus.Completed, testee.Status); Assert.AreEqual(2, to.GetValueAsObject()); }
public async Task Test___Method_Start___Status_Created___Empty() { var value = new AnyVariable <object>(); var to = new AnyVariable <int>() { Value = 0 }; var testee = new ForEachActivity() { Enumerable = new AnyVariable <IEnumerable>() { Value = new List <object>() }, Value = value, Activity = new AssignActivity() { To = to, Value = value } }; await testee.Start(); Assert.AreEqual(ActivityStatus.Completed, testee.Status); Assert.AreEqual(0, to.GetValueAsObject()); }
public void Test___Method_Stop___Status_Created() { var value = new AnyVariable <string>(); var to = new AnyVariable <string>(); var testee = new ForEachActivity() { Enumerable = new AnyVariable <IEnumerable>() { Value = new List <object>() { "foo", "bar", "baz" } }, Value = value, Activity = new AssignActivity() { To = to, Value = value } }; testee.Stop(); Assert.AreEqual(ActivityStatus.Stopped, testee.Status); Assert.IsNull(to.GetValueAsObject()); }
public async Task Test___Method_Reset___Status_Completed() { var elapsed = new AnyVariable <long>() { Value = 0 }; var testee = new StopwatchActivity() { Activity = new DelayActivity() { Duration = new AnyVariable <int>() { Value = 1000 } }, Elapsed = elapsed }; await testee.Start(); Assert.AreEqual(ActivityStatus.Completed, testee.Status); Assert.AreNotEqual(0, elapsed.GetValueAsObject()); testee.Reset(); Assert.AreEqual(ActivityStatus.Created, testee.Status); }
public async Task Test___Method_Stop___Status_Executing() { var elapsed = new AnyVariable <long>() { Value = 0 }; var testee = new StopwatchActivity() { Activity = new DelayActivity() { Duration = new AnyVariable <int>() { Value = 1000 } }, Elapsed = elapsed }; var task = testee.Start(); testee.Stop(); await task; Assert.AreEqual(ActivityStatus.Stopped, testee.Status); Assert.AreNotEqual(0, elapsed.GetValueAsObject()); }
public void Test___Method_GetValue___without_Converter() { var testee = new AnyVariable <int>() { Value = 10 }; Assert.AreEqual(10, testee.GetValueAsObject()); }
public void Test___Method_GetValue___Generic_Class() { var testee = new AnyVariable <int>() { Value = 10 }; Assert.AreEqual(10, testee.GetValueAsObject()); }
public void Test___Method_SetValue() { var testee = new AnyVariable <int>() { Value = 10 }; testee.SetValue(20); Assert.AreEqual(20, testee.GetValueAsObject()); }
public async Task Test___Method_Stop___Status_Executing___Try() { var variable1 = new AnyVariable <int>() { Value = 0 }; var variable2 = new AnyVariable <int>() { Value = 10 }; var duration = new AnyVariable <int>() { Value = 1000 }; var testee = new TryCatchActivity() { Try = new DelayActivity() { Duration = duration }, Catch = new AssignActivity() { To = variable1, Value = new AnyVariable <int>() { Value = 30 } }, Finally = new AssignActivity() { To = variable2, Value = variable1 } }; using (var task = testee.Start()) { Assert.AreEqual(ActivityStatus.Executing, testee.Status); testee.Stop(); await task; } Assert.AreEqual(ActivityStatus.Completed, testee.Status); Assert.AreEqual(30, variable1.GetValueAsObject()); Assert.AreEqual(30, variable2.GetValueAsObject()); }
public async Task Test___Method_Reset___Status_Completed() { var variable1 = new AnyVariable <int>() { Value = 0 }; var variable2 = new AnyVariable <int>() { Value = 10 }; var testee = new TryCatchActivity() { Try = new AssignActivity() { To = variable1, Value = new AnyVariable <int>() { Value = 20 } }, Catch = new AssignActivity() { To = variable1, Value = new AnyVariable <int>() { Value = 30 } }, Finally = new AssignActivity() { To = variable2, Value = variable1 } }; await testee.Start(); Assert.AreEqual(ActivityStatus.Completed, testee.Status); Assert.AreEqual(20, variable1.GetValueAsObject()); Assert.AreEqual(20, variable2.GetValueAsObject()); testee.Reset(); Assert.AreEqual(ActivityStatus.Created, testee.Status); }
public async Task Test___Method_Stop___Status_Executing___Finally() { var variable1 = new AnyVariable <int>() { Value = 0 }; var duration = new AnyVariable <int>() { Value = 1000 }; var testee = new TryCatchActivity() { Try = new AssignActivity() { To = variable1, Value = new AnyVariable <int>() { Value = 20 } }, Catch = new NullActivity(), Finally = new DelayActivity() { Duration = duration } }; var task = testee.Start(); Assert.AreEqual(ActivityStatus.Executing, testee.Status); testee.Stop(); await task; Assert.AreEqual(ActivityStatus.Stopped, testee.Status); Assert.AreEqual(20, variable1.GetValueAsObject()); }