public CollectingAssertionStrategy(IAssertionStrategy parent) { if (parent != null) { failureMessages.AddRange(parent.FailureMessages); } }
/// <summary> /// Creates a nested scope used during chaining. /// </summary> internal AssertionScope(AssertionScope sourceScope, bool sourceSucceeded) { assertionStrategy = sourceScope.assertionStrategy; contextData = sourceScope.contextData; reason = sourceScope.reason; useLineBreaks = sourceScope.useLineBreaks; parent = sourceScope.parent; expectation = sourceScope.expectation; evaluateCondition = sourceSucceeded; }
/// <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; } }
public void When_custom_strategy_is_null_it_should_throw() { // Arrange IAssertionStrategy strategy = null; // Arrange / Act Action act = () => new AssertionScope(strategy); // Assert act.Should().ThrowExactly <ArgumentNullException>() .Which.ParamName.Should().Be("assertionStrategy"); }
/// <summary> /// Starts a new scope based on the given assertion strategy and parent assertion scope /// </summary> /// <param name="assertionStrategy">The assertion strategy for this scope.</param> /// <param name="parent">The parent assertion scope for this scope.</param> /// <exception cref="ArgumentNullException">Thrown when trying to use a null strategy.</exception> internal AssertionScope(IAssertionStrategy assertionStrategy, AssertionScope parent) { this.assertionStrategy = assertionStrategy ?? throw new ArgumentNullException(nameof(assertionStrategy)); this.parent = parent; }
private AssertionScope(IAssertionStrategy _assertionStrategy) { assertionStrategy = _assertionStrategy; parent = null; }
/// <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) { assertionStrategy = _assertionStrategy ?? throw new ArgumentNullException(nameof(_assertionStrategy)); parent = null; }
/// <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 = assertionStrategy ?? throw new ArgumentNullException(nameof(assertionStrategy)); parent = null; }