public void ValidationExceptionConstructResponseTestReturnsObject(string message) { ValidationResult result = BuildValidationResult(); var exception = new ValidationException(message, result.Errors); var responseObject = exception.ConstructResponse(); responseObject.Should().NotBeNull(); responseObject.Message.Should().Be(exception.Message); responseObject.Status.Should().Be(400); ValidateErrors(exception.Errors, responseObject); }
public async Task CreateContactValidationExceptionReturnsBadResult() { // Arrange var contactRequest = _fixture.Create <ContactDetailsRequestObject>(); var exception = new ValidationException("Test Exception"); _mockCreateContactUseCase.Setup(x => x.ExecuteAsync(contactRequest, It.IsAny <Token>())).ThrowsAsync(exception); // Act var response = await _classUnderTest.CreateContact(contactRequest).ConfigureAwait(false); // Assert response.Should().BeOfType(typeof(BadRequestObjectResult)); (response as BadRequestObjectResult).Value.Should().BeEquivalentTo(exception.ConstructResponse()); }