Beispiel #1
0
 /// <summary>
 /// BusinessRuleViolationExceptionProblemDetails
 /// </summary>
 /// <param name="exception"></param>
 public BusinessRuleViolationExceptionProblemDetails(BusinessRuleViolationException exception)
 {
     this.Title  = "Business rule validation error";
     this.Status = StatusCodes.Status409Conflict;
     this.Detail = exception.ExceptionMessage;
     this.Type   = "https://elektra.appointments.api/business-rule-validation-error";
 }
Beispiel #2
0
        public void EmailAddress_initialization_throws_business_rule_violation_exception_when_email_address_is_null()
        {
            //arrange
            string invalidEmail = null;
            var    expectedBusinessRuleViolationException = new BusinessRuleViolationException(new EmailMustBeValid(invalidEmail));

            //act
            var actualException = Record.Exception(() => new EmailAddress(invalidEmail));

            //assert
            Assert.IsType <BusinessRuleViolationException>(actualException);
            Assert.Equal(expectedBusinessRuleViolationException.Message, actualException.Message);
        }
        public void Name_initialization_throws_business_rule_violation_exception_when_name_is_null()
        {
            //arrange
            string invalidName = null;
            var    expectedBusinessRuleViolationException = new BusinessRuleViolationException(new NameLengthMustBeAtLeast5Characters(invalidName));

            //act
            var actualException = Record.Exception(() => new Name(invalidName));

            //assert
            Assert.IsType <BusinessRuleViolationException>(actualException);
            Assert.Equal(expectedBusinessRuleViolationException.Message, actualException.Message);
        }
        public void Address_initialization_throws_business_rule_violation_exception_when_address_length_is_less_than_10()
        {
            //arrange
            string invalidAddress = InvalidAddress();
            var    expectedBusinessRuleViolationException = new BusinessRuleViolationException(new AddressLengthMustBeAtLeast10Characters(invalidAddress));

            //act
            var actualException = Record.Exception(() => new Address(invalidAddress));

            //assert
            Assert.IsType <BusinessRuleViolationException>(actualException);
            Assert.Equal(expectedBusinessRuleViolationException.Message, actualException.Message);
        }
        public void Age_initialization_throws_business_rule_violation_exception_when_age_is_not_between_20_to_60()
        {
            //arrange
            var invalidAge = InvalidAge();
            var expectedBusinessRuleViolationException = new BusinessRuleViolationException(new AgeMustBeBetween20To60(invalidAge));

            //act
            var actualException = Record.Exception(() => new Age(invalidAge));

            //assert
            Assert.IsType <BusinessRuleViolationException>(actualException);
            Assert.Equal(expectedBusinessRuleViolationException.Message, actualException.Message);
        }
 private BusinessRuleViolationException CreateAndLogRuleViolationException(BusinessRuleViolationException exception)
 {
     _loggingBroker.LogCritical(exception);
     return(exception);
 }