Beispiel #1
0
        /// <summary>
        /// Creates an assert router to manage asserts. The specified behaviour will be applied for the lifetime of the object.
        /// </summary>
        /// <param name="assertRoutingBehaviour">The assert reouting behaviour required.</param>
        public AssertRouter(AssertUIBehaviour assertRoutingBehaviour)
        {
            bool disableAssertUI = assertRoutingBehaviour.HasFlag(AssertUIBehaviour.DisableUI);
            bool throwExceptions = assertRoutingBehaviour.HasFlag(AssertUIBehaviour.ThrowExceptions);

            Disable(disableAssertUI, throwExceptions);
        }
Beispiel #2
0
        /// <summary>
        /// Reroutes asserts according to the specified behaviour for the duration of the provided action.
        /// </summary>
        /// <param name="assertRoutingBehaviour">The routing behaviour to apply.</param>
        /// <param name="routedAction">The action to disable asserts over.</param>
        public static void Reroute(AssertUIBehaviour assertRoutingBehaviour, Action routedAction)
        {
            bool disableAssertUI = assertRoutingBehaviour.HasFlag(AssertUIBehaviour.DisableUI);
            bool throwExceptions = assertRoutingBehaviour.HasFlag(AssertUIBehaviour.ThrowExceptions);

            AssertRouter router = new AssertRouter(assertRoutingBehaviour);
            try
            {
                routedAction();
            }
            finally
            {
                router.Restore();
            }
        }