-
Notifications
You must be signed in to change notification settings - Fork 455
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix / refactor FunctionsHostingConfigOptionsTest #10890
base: dev
Are you sure you want to change the base?
Conversation
// Note: For legacy purposes (we used to call Configuration.Bind() on this object), some properties whose ScmHostingConfig key and | ||
// property name match exactly need to support "True/False". | ||
// It is recommended that new properties only look at "1/0" for their setting. | ||
yield return new object[] { nameof(FunctionsHostingConfigOptions.DisableLinuxAppServiceExecutionDetails), "DisableLinuxExecutionDetails=1", true }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use collection expressions here to reduce some of the verbosity (e.g. yield return [nameof(FunctionsHostingConfigOptions.DisableLinuxAppServiceExecutionDetails), "DisableLinuxExecutionDetails=1", true];
)
} | ||
|
||
[Fact] | ||
public void Inject_Succeded() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spelling: (previous issue) -> Inject_Succeeded
{ | ||
(nameof(FunctionsHostingConfigOptions.DisableLinuxAppServiceExecutionDetails), "DisableLinuxExecutionDetails=1", true), | ||
(nameof(FunctionsHostingConfigOptions.DisableLinuxAppServiceLogBackoff), "DisableLinuxLogBackoff=1", true), | ||
// make sure all props are internal to prevent inadverntent binding in the future |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spelling: inadvertent
.Where(p => p.Name != nameof(FunctionsHostingConfigOptions.Features)); | ||
|
||
foreach (var prop in props) | ||
var prop = AllProperties.Select(x => x[0] as PropertyInfo).Single(p => p.Name == propertyName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
p.Name == propertyName
-> string.Equals
with an explicit string comparison.
[InlineData("feature1", "value1")] | ||
[InlineData("featuree1", null)] | ||
public async Task Case_Insensitive(string key, string expectedValue) | ||
public static IEnumerable<object[]> AllProperties |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we replace this with:
public static IEnumerable<PropertyInfo> AllProperties =>
typeof(FunctionsHostingConfigOptions).GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
.Where(p => p.Name != nameof(FunctionsHostingConfigOptions.Features));
public static IEnumerable<object[]> AllPropertiesInput => AllProperties.Select(p => new[] { p });
Doing so would enable you to use AllPropertiesInput
in the MemberData
while changing the property match in line 151 with:
var prop = AllProperties.Single(p => string.Equals( p.Name, propertyName, StringComparison.Ordinal));
Issue describing the changes in this PR
resolves #10889
Pull request checklist
IMPORTANT: Currently, changes must be backported to the
in-proc
branch to be included in Core Tools and non-Flex deployments.in-proc
branch is not required -- TODOrelease_notes.md
Additional information
Refactors
FunctionsHostingConfigOptionsTest
to stabilize and improve the tests.ConfigureDefaultTestWebScriptHost
usageProperty_Validation
test into two, one for validating access and another for validating expectations. Also converts these into a theory usingMemberData
.