public void Null_argument_tests()
        {
            ILambdaItem lambdaItem = null;

            Assert.Throws <ArgumentNullException>(() => lambdaItem.Result());
            Assert.Throws <ArgumentNullException>(() => lambdaItem.Result <int>());
            Assert.Throws <ArgumentNullException>(() => lambdaItem.HasCompleted());
            Assert.Throws <ArgumentNullException>(() => lambdaItem.HasFailed());
            Assert.Throws <ArgumentNullException>(() => lambdaItem.HasTimedout());
        }
Exemplo n.º 2
0
        /// <summary>
        /// Access completed result of lambda function as dynamic object. If completed result is JSON object then you can directly access its properties.
        /// Throws exception when last event is not lambda completed event.
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public static dynamic Result(this ILambdaItem item)
        {
            Ensure.NotNull(item, nameof(item));
            var completedEvent = item.LastEvent() as LambdaCompletedEvent;

            if (completedEvent == null)
            {
                throw new InvalidOperationException(Resources.Lambda_result_can_not_be_accessed);
            }
            return(completedEvent.Result());
        }
Exemplo n.º 3
0
 private bool EveryOneAgree(ILambdaItem arg)
 {
     return(arg.ParentLambda("ApplyToCouncil").IsSignalled("CApproved") &&
            arg.ParentLambda("ApplyToFireDept").IsSignalled("FApproved") &&
            arg.ParentLambda("ApplyToForestDept").IsSignalled("FrApproved"));
 }
Exemplo n.º 4
0
 private bool AnyOneDisagree(ILambdaItem arg)
 {
     return(arg.ParentLambda("ApplyToCouncil").IsSignalled("CRejected") ||
            arg.ParentLambda("ApplyToFireDept").IsSignalled("FRejected") ||
            arg.ParentLambda("ApplyToForestDept").IsSignalled("FrRejected"));
 }
Exemplo n.º 5
0
 /// <summary>
 ///  Retruns the <see cref="LambdaTimedoutEvent"/> and if it is the last event, otherwise null is returned.
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public static LambdaTimedoutEvent LastTimedoutEvent(this ILambdaItem item)
 {
     Ensure.NotNull(item, nameof(item));
     return(item.LastEvent() as LambdaTimedoutEvent);
 }
Exemplo n.º 6
0
 /// <summary>
 /// Returns true if the last event of lambda is <see cref="LambdaTimedoutEvent"/>.
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public static bool HasTimedout(this ILambdaItem item) => item.LastTimedoutEvent() != null;
Exemplo n.º 7
0
 /// <summary>
 /// Returns true if the last event of lambda is <see cref="LambdaFailedEvent"/>.
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public static bool HasFailed(this ILambdaItem item)
 => item.LastFailedEvent() != null;
Exemplo n.º 8
0
 /// <summary>
 /// Returns true if the last event of lambda is <see cref="LambdaCompletedEvent"/>.
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public static bool HasCompleted(this ILambdaItem item)
 => item.LastCompletedEvent() != null;
Exemplo n.º 9
0
 /// <summary>
 /// Retruns the <see cref="LambdaCompletedEvent"/> and if it is the last event, otherwise null is returned.
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public static LambdaCompletedEvent LastCompletedEvent(this ILambdaItem item)
 {
     Ensure.NotNull(item, nameof(item));
     return(item.LastEvent() as LambdaCompletedEvent);
 }