Exemple #1
0
        public void IMMPxApplication_IsValidTransition_IsFalse()
        {
            IMMPxState state = base.PxApplication.GetState("In Progress");
            bool       valid = base.PxApplication.Transitions.IsValidTransition(base.PxApplication.User, state, state);

            Assert.IsFalse(valid);
        }
Exemple #2
0
        /// <summary>
        /// Determines whether the specified <paramref name="state" /> exists in the enumeration of <paramref name="source" />.
        /// </summary>
        /// <param name="source">The enumeration of states.</param>
        /// <param name="state">The state.</param>
        /// <returns>
        /// Returns a <see cref="bool" /> representing <c>true</c> if the state exists; otherwise, <c>false</c>.
        /// </returns>
        /// <exception cref="ArgumentNullException">state</exception>
        public static bool Contains(this IMMEnumPxState source, IMMPxState state)
        {
            if (source == null)
            {
                return(false);
            }
            if (state == null)
            {
                throw new ArgumentNullException("state");
            }

            return(source.AsEnumerable().Any(testState => testState.Name == state.Name && testState.NodeType == state.NodeType));
        }
Exemple #3
0
        /// <summary>
        ///     Creates an <see cref="IEnumerable{T}" /> from an <see cref="IMMEnumPxState" />
        /// </summary>
        /// <param name="source">An <see cref="IMMEnumPxState" /> to create an <see cref="IEnumerable{T}" /> from.</param>
        /// <returns>An <see cref="IEnumerable{T}" /> that contains the fields from the input source.</returns>
        public static IEnumerable <IMMPxState> AsEnumerable(this IMMEnumPxState source)
        {
            if (source != null)
            {
                source.Reset();
                IMMPxState state = source.Next();
                while (state != null)
                {
                    yield return(state);

                    state = source.Next();
                }
            }
        }
Exemple #4
0
        public void IMMPxApplication_GetStateByName_IsNotNull()
        {
            IMMPxState state = base.PxApplication.GetState("In Progress");

            Assert.IsNotNull(state);
        }
Exemple #5
0
        public void IMMPxApplication_GetStateByID_IsNotNull()
        {
            IMMPxState state = base.PxApplication.GetState(1);

            Assert.IsNotNull(state);
        }
Exemple #6
0
        /// <summary>
        /// Determines if a transition exists between the <paramref name="fromState" /> and
        /// the <paramref name="toState" /> states for the specified <paramref name="user" />.
        /// </summary>
        /// <param name="source">The transitions.</param>
        /// <param name="user">The user.</param>
        /// <param name="fromState">The From state.</param>
        /// <param name="toState">The To state.</param>
        /// <returns>
        /// Returns a <see cref="bool" /> representing <c>true</c> if there exists a transition; otherwise, <c>false</c>.
        /// </returns>
        /// <exception cref="ArgumentNullException">
        /// user
        /// or
        /// fromState
        /// or
        /// toState
        /// </exception>
        public static bool IsValidTransition(this IMMEnumPxTransition source, IMMPxUser user, IMMPxState fromState, IMMPxState toState)
        {
            if (source == null)
            {
                return(false);
            }
            if (user == null)
            {
                throw new ArgumentNullException("user");
            }
            if (fromState == null)
            {
                throw new ArgumentNullException("fromState");
            }
            if (toState == null)
            {
                throw new ArgumentNullException("toState");
            }

            return(source.AsEnumerable().Any(transition => transition.IsValidTransition(user, fromState, toState)));
        }
Exemple #7
0
        /// <summary>
        /// Determines if a transition exists between the <paramref name="fromState" /> and
        /// the <paramref name="toState" /> states for the specified <paramref name="user" />.
        /// </summary>
        /// <param name="source">The transitions.</param>
        /// <param name="user">The user.</param>
        /// <param name="fromState">The From state.</param>
        /// <param name="toState">The To state.</param>
        /// <returns>
        /// Returns a <see cref="bool" /> representing <c>true</c> if there exists a transition; otherwise, <c>false</c>.
        /// </returns>
        /// <exception cref="ArgumentNullException">
        /// user
        /// or
        /// fromState
        /// or
        /// toState
        /// </exception>
        public static bool IsValidTransition(this IMMPxTransition source, IMMPxUser user, IMMPxState fromState, IMMPxState toState)
        {
            if (source == null)
            {
                return(false);
            }
            if (user == null)
            {
                throw new ArgumentNullException("user");
            }
            if (fromState == null)
            {
                throw new ArgumentNullException("fromState");
            }
            if (toState == null)
            {
                throw new ArgumentNullException("toState");
            }

            // Compare the from and to states from the enumerations.
            if (source.FromStates.Contains(fromState) && source.ToStates.Contains(toState))
            {
                // Found a transition with matching To/From states, now check to see
                // if the user has the proper role assigned to run the transition.
                if (user.AnyRoleForTransition(source))
                {
                    return(true);
                }
            }

            return(false);
        }