BaseTestWithExistingSolution won't load "csproj.DotSettings"

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?

Comment actions Permalink

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:

public void DoTest()
  ExecuteWithinSettingsTransaction(store => {
    store.SetValue((CSharpLanguageProjectSettings s) => s.LanguageLevel = CSharpLanguageLevel.CSharp50);

    // Do Test...

Comment actions Permalink

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!

Comment actions Permalink

> "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?

Comment actions Permalink

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: (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.

Comment actions Permalink


A complete sample could also be found here:

Serge Baltic
JetBrains, Inc —
“Develop with pleasure!”

Comment actions Permalink

Hi Matt/Serge,

I created

Thanks for the hint with the settings layer. At the moment, its easier for me to change just the settings I need programmatically.


Please sign in to leave a comment.