public void PostConfigure_SetProblemDetailsModelStateResponseFactory()
        {
            // Arrange
            var optionsSetup = new ApiBehaviorOptionsSetup();
            var options      = new ApiBehaviorOptions();

            // Act
            optionsSetup.Configure(options);
            optionsSetup.PostConfigure(string.Empty, options);

            // Assert
            Assert.Same(ApiBehaviorOptionsSetup.ProblemDetailsFactory, options.InvalidModelStateResponseFactory);
        }
        public void PostConfigure_DoesNotSetProblemDetailsFactory_IfValueWasModified()
        {
            // Arrange
            var optionsSetup = new ApiBehaviorOptionsSetup();
            var options      = new ApiBehaviorOptions();
            Func <ActionContext, IActionResult> expected = _ => null;

            // Act
            optionsSetup.Configure(options);
            // This is equivalent to user code updating the value via ConfigureOptions
            options.InvalidModelStateResponseFactory = expected;
            optionsSetup.PostConfigure(string.Empty, options);

            // Assert
            Assert.Same(expected, options.InvalidModelStateResponseFactory);
        }
        public void PostConfigure_SetProblemDetailsModelStateResponseFactory()
        {
            // Arrange
            var optionsSetup = new ApiBehaviorOptionsSetup(
                NullLoggerFactory.Instance,
                Options.Options.Create(new MvcCompatibilityOptions {
                CompatibilityVersion = CompatibilityVersion.Latest
            }));
            var options = new ApiBehaviorOptions();

            // Act
            optionsSetup.Configure(options);
            optionsSetup.PostConfigure(string.Empty, options);

            // Assert
            Assert.Same(ApiBehaviorOptionsSetup.ProblemDetailsFactory, options.InvalidModelStateResponseFactory);
        }