コード例 #1
0
ファイル: Assert.cs プロジェクト: jbtule/PclUnit
 public void Fail(AssertionException assertion)
 {
     AssertCount++;
     foreach (var s in ExcludeFromStack)
     {
         assertion.ExcludeFromStackTrace.Add(s);
     }
     throw assertion;
 }
コード例 #2
0
ファイル: SpecifyTests.cs プロジェクト: vmmitev/Specificity2
        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");
        }
コード例 #3
0
ファイル: SpecifyTests.cs プロジェクト: vmmitev/Specificity2
        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");
        }
コード例 #4
0
 private void AvoidUnusedVariableCompilerWarning(AssertionException e)
 {
     string msg = e.Message;
 }
コード例 #5
0
ファイル: Assert.cs プロジェクト: jbtule/PclUnit
 private static AssertionException CreateException(string message = null)
 {
     var assertion = new AssertionException();
     if (message != null)
         assertion = new AssertionException(message);
     return assertion;
 }
コード例 #6
0
 private void RethrowException(AssertionException ex, DataRow row)
 {
     throw new AssertionException(string.Format("[{0}]\n{1}", row.Name, ex.Message), ex);
 }
コード例 #7
0
ファイル: Engine.cs プロジェクト: yuzutan29/TrulyQuantumChess
        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}");
            }
        }
コード例 #8
0
 protected override void When()
 {
     _exception = Assert.Throws <AssertionException>(() => SUT.ShouldContain(s => s.EndsWith("98")));
 }
コード例 #9
0
 public static TestStepResult FailureResultWithTestRetry(AssertionException assertionException, int testRetryAttempts, TimeSpan testRetryStandOffPeriod, object actionToReturnToOnTestFailure)
 {
     return(new TestStepResult(TestStepOutcome.Failed, assertionException, actionToReturnToOnTestFailure, testRetryAttempts, testRetryStandOffPeriod));
 }
コード例 #10
0
 public static TestStepResult FailureResult(AssertionException assertionException)
 {
     return(new TestStepResult(TestStepOutcome.Failed, assertionException, null, null, null));
 }
コード例 #11
0
 public static TestStepResult NonCriticalFailureResult(AssertionException assertionException)
 {
     return(new TestStepResult(TestStepOutcome.NonCrucialFailure, assertionException, null, null, null));
 }
コード例 #12
0
 protected override string CreateExpectedMessage(string expectedLambda, AssertionException expectedException)
 {
     return(expectedLambda + expectedException.Message);
 }