Skip to content
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 configuration test #93786

Merged
merged 1 commit into from
Oct 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -736,47 +736,20 @@ public void GetCanReadInheritedProperties()
Assert.Equal("Derived:Sup", options.Virtual);
}

private static readonly object _syncLock = new object();

[Fact]
public void GetCanReadStaticProperty()
{
// The test uses ComplexOptions.StaticProperty which is possible to be changed by other tests.
lock (_syncLock)
{
var dic = new Dictionary<string, string>
{
{"StaticProperty", "stuff"},
};
var configurationBuilder = new ConfigurationBuilder();
configurationBuilder.AddInMemoryCollection(dic);
var config = configurationBuilder.Build();
var options = new ComplexOptions();
config.Bind(options);

Assert.Equal("stuff", ComplexOptions.StaticProperty);
}
}

[Fact]
public void BindCanReadStaticProperty()
{
// The test uses ComplexOptions.StaticProperty which is possible to be changed by other tests.
lock (_syncLock)
var dic = new Dictionary<string, string>
{
var dic = new Dictionary<string, string>
{
{"StaticProperty", "other stuff"},
};
var configurationBuilder = new ConfigurationBuilder();
configurationBuilder.AddInMemoryCollection(dic);
var config = configurationBuilder.Build();

var instance = new ComplexOptions();
config.Bind(instance);
{"StaticProperty", "stuff"},
};
var configurationBuilder = new ConfigurationBuilder();
configurationBuilder.AddInMemoryCollection(dic);
var config = configurationBuilder.Build();
var options = new ComplexOptions();
config.Bind(options);

Assert.Equal("other stuff", ComplexOptions.StaticProperty);
}
Assert.Equal("stuff", ComplexOptions.StaticProperty);
}

[Fact]
Expand Down