RandomEngy / UnitTestBoilerplateGenerator

An extension for Visual Studio that generates a unit test boilerplate from a given class, setting up mocks for all dependencies. Supports NUnit, Visual Studio Test, XUnit and many mock frameworks.
https://marketplace.visualstudio.com/items?itemName=RandomEngy.UnitTestBoilerplateGenerator
MIT License
64 stars 17 forks source link

Preselect test project based on project name template #25

Closed gleb-osokin closed 3 years ago

gleb-osokin commented 3 years ago

This PR tries to slightly improve the user experience by pre-selecting a test project in the "Create Unit Test Boilerplate..." dialog based on the new setting: Test project name format

NewSetting

The default value for the Test project name format is $ProjectName$.Test

The new strategy for pre-selecting the test project is as follows: 1) first try to select a test project if it exactly matches the template 2) if none found, try to get latest selected/cached test project 3) if none found, try to get project that has 'test' in its name 4) if none found, take first of available test projects

Steps 2-4 were there before, but I moved them to dedicated Strategy classes. Users that want to ignore step 1 can clear out the Test project name format setting.

Another adjustment: as the new setting now makes the setting window slightly larger than the available height, I've also added the ScrollViewer to the corresponding view XAML.

Also, I've added a new token: $ProjectName$, which is only used in a single context. Hope that's okay, otherwise let me know how to make it better.

PS. Thanks for a great project, it really saves us a lot of time!

RandomEngy commented 3 years ago

Elegant solution and good refactoring. Thanks!

RandomEngy commented 3 years ago

There's another PR in the works and I'll see if I can release a new version in a few days with both.