public void Fail(AssertionException assertion) { AssertCount++; foreach (var s in ExcludeFromStack) { assertion.ExcludeFromStackTrace.Add(s); } throw assertion; }
public void FailGivenInnerExceptionsShouldThrowAggregateAssertionException() { var exception = new AssertionException(); try { Specify.Failure(new[] { exception }); } catch (AggregateAssertionException e) { Assert.AreSame(exception, e.InnerException); Assert.AreSame(exception, e.InnerExceptions.FirstOrDefault()); return; } Assert.Fail("Specify.Failure did not throw an AggregateAssertFailedException"); }
public void FailGivenInnerExceptionsAndMessageShouldThrowAggregateAssertionExceptionWithMessage() { var message = "Test Message"; var exception = new AssertionException(); try { Specify.Failure(new[] { exception }, message); } catch (AggregateAssertionException e) { Assert.StartsWith(e.Message, message, StringComparison.Ordinal); Assert.AreSame(exception, e.InnerException); Assert.AreSame(exception, e.InnerExceptions.FirstOrDefault()); return; } Assert.Fail("Specify.Failure did not throw an AggregateAssertFailedException"); }
private void AvoidUnusedVariableCompilerWarning(AssertionException e) { string msg = e.Message; }
private static AssertionException CreateException(string message = null) { var assertion = new AssertionException(); if (message != null) assertion = new AssertionException(message); return assertion; }
private void RethrowException(AssertionException ex, DataRow row) { throw new AssertionException(string.Format("[{0}]\n{1}", row.Name, ex.Message), ex); }
public void Submit(QuantumChessMove move) { if (move.ActorPlayer != ActivePlayer_) { MoveProcessException.Throw("Waiting for another player's move"); } if (move is CapitulateMove) { QuantumChessboard_.RegisterVictory(PlayerUtils.InvertPlayer(ActivePlayer_)); LastMovePositions_ = new Position[0]; } else if (move is AgreeToTieMove) { QuantumChessboard_.RegisterTie(); LastMovePositions_ = new Position[0]; } else if (move is OrdinaryMove) { var omove = move as OrdinaryMove; if (QuantumChessboard_.CheckOrdinaryMoveApplicable(omove)) { QuantumChessboard_.ApplyOrdinaryMove(omove); ActivePlayer_ = PlayerUtils.InvertPlayer(ActivePlayer_); LastMovePositions_ = new Position[] { omove.Source, omove.Target }; } else { MoveProcessException.Throw("Move is inapplicable on all harmonics"); } } else if (move is QuantumMove) { var qmove = move as QuantumMove; if (QuantumChessboard_.CheckQuantumMoveApplicable(qmove)) { QuantumChessboard_.ApplyQuantumMove(qmove); ActivePlayer_ = PlayerUtils.InvertPlayer(ActivePlayer_); if (qmove.Middle.HasValue) { LastMovePositions_ = new Position[] { qmove.Source, qmove.Middle.Value, qmove.Target } } ; else { LastMovePositions_ = new Position[] { qmove.Source, qmove.Target } }; } else { MoveProcessException.Throw("Quantum move is inapplicable on all harmonics"); } } else if (move is CastleMove) { var cmove = move as CastleMove; if (QuantumChessboard_.CheckCastleMoveApplicable(cmove)) { QuantumChessboard_.ApplyCastleMove(cmove); ActivePlayer_ = PlayerUtils.InvertPlayer(ActivePlayer_); int c = cmove.ActorPlayer == Player.White ? 0 : 7; LastMovePositions_ = new Position[2]; LastMovePositions_[0] = Position.FromCoords(4, c); if (cmove.CastleType == CastleType.Left) { LastMovePositions_[1] = Position.FromCoords(0, c); } else { LastMovePositions_[1] = Position.FromCoords(7, c); } } else { MoveProcessException.Throw("Castle is inapplicable on all harmonics"); } } else { AssertionException.Assert(false, $"Unsupported move type: {move.GetType().Name}"); } }
protected override void When() { _exception = Assert.Throws <AssertionException>(() => SUT.ShouldContain(s => s.EndsWith("98"))); }
public static TestStepResult FailureResultWithTestRetry(AssertionException assertionException, int testRetryAttempts, TimeSpan testRetryStandOffPeriod, object actionToReturnToOnTestFailure) { return(new TestStepResult(TestStepOutcome.Failed, assertionException, actionToReturnToOnTestFailure, testRetryAttempts, testRetryStandOffPeriod)); }
public static TestStepResult FailureResult(AssertionException assertionException) { return(new TestStepResult(TestStepOutcome.Failed, assertionException, null, null, null)); }
public static TestStepResult NonCriticalFailureResult(AssertionException assertionException) { return(new TestStepResult(TestStepOutcome.NonCrucialFailure, assertionException, null, null, null)); }
protected override string CreateExpectedMessage(string expectedLambda, AssertionException expectedException) { return(expectedLambda + expectedException.Message); }