unit testing Code Clean-up module with various options?

Hi,
I would like to unit test a code clean-up module with various options. Basically, my module has 1 associated Descriptor of type CodeCleanupEnumOptionDescriptor<MyOptions>. MyOptions is an enum with 3 values (None, All, ObjectsOnly). I would like to write a unit test (well, 3 really) that will test 1 or more files with each of the 3 settings.
Should I use DoTestFilesWithProfile()? if so, how? From what I see the .profile file associated with it just has a boolean for the class name of the module. Can I use it for setting my options?
I do see a ChangeSettingsTemporarily() on the CodeCleanupTestBase, but it takes a LifeTime and I have no idea how to get a LifeTime at this point.

Thanks in advance for the help. It's been a great adventure working the SDK.

Regards,

Eric.
P.S. I am working with the latest version of the 6.x SDK.

1 comment
Comment actions Permalink

Hi,

In order to test a particular profile, your test method should simply call

DoTestFilesWithProfile
— there’s actually an example of this in the SDK under
SamplePlugin\SamplePlugin.Tests\testStc\CodeCleanup
. Essentially, the first parameter is the name of the profile to test with, the second parameter is the name of the actual file to test.
As far as
ChangeSettingsTemporarily()
is concerned, you can write the following:
Lifetime.Using(lifetime =>
   {
     // use 'lifetime' here
   });

Hope this helps,
Dmitri

0

Please sign in to leave a comment.