Ejemplo n.º 1
0
        public void CreateExceptionReturnsCorrectResult()
        {
            // Arrange
            var value    = Guid.NewGuid().ToString();
            var expected = new Exception();
            var cmd      = new DelegatingGuardClauseCommand {
                OnCreateException = v => value == v ? expected : new Exception()
            };
            var sut = new ReflectionExceptionUnwrappingCommand(cmd);
            // Act
            var result = sut.CreateException(value);

            // Assert
            Assert.Equal(expected, result);
        }
        public void CreateExceptionReturnsCorrectResult()
        {
            // Fixture setup
            var value    = Guid.NewGuid().ToString();
            var expected = new Exception();
            var cmd      = new DelegatingGuardClauseCommand {
                OnCreateException = v => value == v ? expected : new Exception()
            };
            var sut = new ReflectionExceptionUnwrappingCommand(cmd);
            // Exercise system
            var result = sut.CreateException(value);

            // Verify outcome
            Assert.Equal(expected, result);
            // Teardown
        }
        public void CreateExceptionWithFailureReasonReturnsCorrectResult()
        {
            // Arrange
            var value         = Guid.NewGuid().ToString();
            var failureReason = Guid.NewGuid().ToString();
            var inner         = new Exception();
            var expected      = new Exception();
            var cmd           = new DelegatingGuardClauseCommand
            {
                OnCreateExceptionWithFailureReason = (v, r, e) => v == value && r == failureReason && e == inner ? expected : new Exception()
            };
            var sut = new ReflectionExceptionUnwrappingCommand(cmd);
            // Act
            var result = sut.CreateException(value, failureReason, inner);

            // Assert
            Assert.Equal(expected, result);
        }