Skip to content

Commit def2a34

Browse files
committed
no need to throw to report errors
1 parent 956975b commit def2a34

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

docs/source/Configuration-validation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,4 @@ To skip validation altogether for this map, use `MemberList.None`. That's the de
5555

5656
## Custom validations
5757

58-
You can add custom validations through an extension point. See [here](https://github.com/AutoMapper/AutoMapper/blob/bdc0120497d192a2741183415543f6119f50a982/src/UnitTests/CustomValidations.cs#L42).
58+
You can add custom validations through an extension point. See [here](https://github.com/AutoMapper/AutoMapper/blob/master/src/UnitTests/CustomValidations.cs).

src/UnitTests/CustomValidations.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public void Should_call_the_validator()
3838
cfg.CreateMap<Source, Dest>();
3939
});
4040

41-
config.AssertConfigurationIsValid();
41+
new Action(config.AssertConfigurationIsValid).ShouldThrow<AutoMapperConfigurationException>().Message.ShouldBe(nameof(When_using_custom_validation));
4242

4343
_calledForRoot.ShouldBeTrue();
4444
_calledForValues.ShouldBeTrue();
@@ -55,6 +55,7 @@ private void Validator(ValidationContext context)
5555
context.Types.DestinationType.ShouldBe(typeof(Dest));
5656
context.ObjectMapper.ShouldBeNull();
5757
context.MemberMap.ShouldBeNull();
58+
context.Exceptions.Add(new AutoMapperConfigurationException(nameof(When_using_custom_validation)));
5859
}
5960
else
6061
{

0 commit comments

Comments
 (0)