Пример #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AssertionScope"/> class.
        /// </summary>
        public AssertionScope() : this(new CollectingAssertionStrategy((current != null) ? current.assertionStrategy : null))
        {
            parent  = current;
            current = this;

            if (parent != null)
            {
                contextData.Add(parent.contextData);
            }
        }
Пример #2
0
        /// <summary>
        /// Starts a new scope based on the given assertion strategy.
        /// </summary>
        /// <param name="assertionStrategy">The assertion strategy for this scope.</param>
        /// <exception cref="ArgumentNullException">Thrown when trying to use a null strategy.</exception>
        public AssertionScope(IAssertionStrategy assertionStrategy)
            : this(assertionStrategy, GetCurrentAssertionScope())
        {
            SetCurrentAssertionScope(this);

            if (parent != null)
            {
                contextData.Add(parent.contextData);
                Context = parent.Context;
            }
        }
Пример #3
0
        /// <summary>
        /// Starts an unnamed scope within which multiple assertions can be executed
        /// and which will not throw until the scope is disposed.
        /// </summary>
        public AssertionScope()
            : this(new CollectingAssertionStrategy())
        {
            parent = GetCurrentAssertionScope();
            SetCurrentAssertionScope(this);

            if (parent != null)
            {
                contextData.Add(parent.contextData);
                Context = parent.Context;
            }
        }