public void BeforeCall_Call_Logger_And_Throw_Exception_Using_ErrorMessageGenerator_ReturnValue_When_Validator_Returns_ValidationResult()
        {
            const string errorMessage = "something really bad";

            var validationResults = new List <ValidationResult> {
                new ValidationResult("something bad", new[] { "test" })
            };

            _singleValidatorMock.Setup(x => x.Validate(It.IsAny <object>())).Returns(validationResults);

            _errorMessageGeneratorMock.Setup(x => x.GenerateErrorMessage(OperationName, validationResults)).Returns(errorMessage);

            var loggerMock = new Mock <IValidationResultsLogger>();

            loggerMock.Setup(x => x.LogValidationResults(OperationName, MoqParameter.ShouldBeEquivalentTo(validationResults)));

            var inspector = new ValidatingParameterInspector(new[] { _singleValidatorMock.Object, _secondValidatorMock.Object, new NullCheckObjectValidator() }, _errorMessageGeneratorMock.Object, loggerMock.Object, _defaultParameterDetailsInfo);

            Assert.Throws <FaultException>(() => inspector.BeforeCall(OperationName, new[] { new object() }));
            loggerMock.Verify(x => x.LogValidationResults(OperationName, MoqParameter.ShouldBeEquivalentTo(validationResults)), Times.Once());
        }
        public void BeforeCall_Calls_ErrorMessageGenerator_When_Validator_Returns_ValidationResult()
        {
            var validationResults = new List <ValidationResult> {
                new ValidationResult("something bad", new[] { "test" })
            };

            _singleValidatorMock.Setup(x => x.Validate(It.IsAny <object>())).Returns(validationResults);

            try {
                _singleValidatorParameterInspector.BeforeCall(OperationName, new[] { new object() });
            }
            catch {
                // suppress
            }

            _errorMessageGeneratorMock.Verify(x => x.GenerateErrorMessage(OperationName, MoqParameter.ShouldBeEquivalentTo(validationResults)), Times.Once());
        }