BaseTestWithExistingSolution won't load "csproj.DotSettings" Follow
My scenario: I use BaseTestWithExistingSolution in a test project to load a solution, which includes a csproj project, which has a csproj.DotSettings file.
My problem is that the settings contained within the DotSettings file aren't applied.
Is this the expected behavior of BaseTestWithExistingSolution? Can I force BaseTestWithExistingSolution to load the csproj.DotSettings?
Please sign in to leave a comment.
As far as I can tell, the BaseTest classes don't load any settings files at all. Instead, you just get the default values. You can set specific settings programmatically, using the ExecuteWithinSettingsTransaction. This takes in an action, creates a temporary settings layer, calls the action and then destroys the layer. In your action, you can set some settings. Something like:
Hi Matt,
OK. Changing the settings programmatically the unit tests is what I'm doing already (+ scoping it to a project DataContext). As I'm using the same solution for my manual tests, I thought it would be cool to use the same settings in both the manual tests and the integration tests, which come from the project's DotSettigs file. But if this isn't possible easily, I'lll stay with the current solution.
Many thanks for you help!
> "As far as I can tell, the BaseTest classes don't load any settings files at all"
Would this have a chance as feature request / Should I make a YouTrack issue?
Yes, that would be useful. But you should also be able to implement this yourself. Here's an example of how to load a settings file programmatically: https://github.com/xunit/resharper-xunit/blob/xunit2/resharper/src/xunitcontrib.runner.resharper.provider/Settings/SettingsLoader.cs. (It's a partial class to allow for different implementations for different ReSharper versions. The other part is here.
It creates an xml settings storage for the file, creates a descriptor for the layer, and injects the layer into the list of known settings layers. The descriptor has a host ID which dictates where the layer is added - you can use GlobalSettings.AllProductsLayerId or GlobalSettings.ProductGlobalLayerId to apply settings at the product level, or SolutionSettings.SolutionSharedLayerId and SolutionSettings.SolutionPersonalLayerId for solution level settings.
Hello,
A complete sample could also be found here: https://reshsettingsdiscover.codeplex.com/SourceControl/latest#FindAndLoadSettings.cs
—
Serge Baltic
JetBrains, Inc — http://www.jetbrains.com
“Develop with pleasure!”
Hi Matt/Serge,
I created https://youtrack.jetbrains.com/issue/RSRP-428445.
Thanks for the hint with the settings layer. At the moment, its easier for me to change just the settings I need programmatically.