示例#1
0
        public void When_Sending_A_Command_That_Should_Retry_Failure()
        {
            Catch.Exception(() => _commandProcessor.Send(_myCommand));

            //_should_send_the_command_to_the_command_handler
            Assert.True(MyFailsWithDivideByZeroHandler.ShouldReceive(_myCommand));
            //_should_retry_three_times
            Assert.AreEqual(3, _retryCount);
        }
示例#2
0
        public void When_Sending_A_Command_That_Should_Retry_Failure()
        {
            Catch.Exception(() => _commandProcessor.Send(_myCommand));

            //_should_send_the_command_to_the_command_handler
            MyFailsWithDivideByZeroHandler.ShouldReceive(_myCommand).Should().BeTrue();
            //_should_retry_three_times
            _retryCount.Should().Be(3);
        }
        public void When_Sending_A_Command_That_Repeatedely_Fails_Break_The_Circuit()
        {
            //First two should be caught, and increment the count
            _firstException  = Catch.Exception(() => _commandProcessor.Send(_myCommand));
            _secondException = Catch.Exception(() => _commandProcessor.Send(_myCommand));
            //this one should tell us that the circuit is broken
            _thirdException = Catch.Exception(() => _commandProcessor.Send(_myCommand));

            //_should_send_the_command_to_the_command_handler
            MyFailsWithDivideByZeroHandler.ShouldReceive(_myCommand).Should().BeTrue();
            //_should_bubble_up_the_first_exception
            _firstException.Should().BeOfType <DivideByZeroException>();
            //_should_bubble_up_the_second_exception
            _secondException.Should().BeOfType <DivideByZeroException>();
            //_should_break_the_circuit_after_two_fails
            _thirdException.Should().BeOfType <BrokenCircuitException>();
        }