示例#1
0
        public void Reader_Is_Enabled(StandardQueryStringParameters parametersDisabled, bool allowOverride, bool expectIsEnabled)
        {
            // Arrange
            var options = new JsonApiOptions
            {
                AllowQueryStringOverrideForSerializerDefaultValueHandling = allowOverride
            };

            var reader = new DefaultsQueryStringParameterReader(options);

            // Act
            var isEnabled = reader.IsEnabled(new DisableQueryStringAttribute(parametersDisabled));

            // Assert
            isEnabled.Should().Be(allowOverride && expectIsEnabled);
        }
示例#2
0
        public void Reader_Outcome(string queryStringParameterValue, DefaultValueHandling optionsDefaultValue, bool optionsAllowOverride, DefaultValueHandling expected)
        {
            // Arrange
            var options = new JsonApiOptions
            {
                SerializerSettings = { DefaultValueHandling = optionsDefaultValue },
                AllowQueryStringOverrideForSerializerDefaultValueHandling = optionsAllowOverride
            };

            var reader = new DefaultsQueryStringParameterReader(options);

            // Act
            if (reader.IsEnabled(DisableQueryStringAttribute.Empty))
            {
                reader.Read("defaults", queryStringParameterValue);
            }

            // Assert
            reader.SerializerDefaultValueHandling.Should().Be(expected);
        }