Unit test product with license file

Ive started work on a product that uses license files. These files must be read (and verified) for the application to work. This causes some problems in unit tests, without the right license they throw exceptions.

We are using NUnit and I need to do the following:

  • Copy the license file to the copied shadow directory before running the test.
  • Set the working directory to the original output folder so that the file names are still valid in the temporary folder of the test.

I know that in unit tests you should generally avoid accessing files, but before starting refactoring we need unit tests, so I need this to work.

+3
source share
5 answers

NUnit , . ( ). , imo, .

+1

, , . , , . , , , .

+1

mock , . MOQ .

+1

:

, . , , , .

, , , , , , , , , , , .

Then, as soon as you have some tests around this class, you can reset the method and subclass in favor of the correctly entered class.

(Edited to answer that verification is complex).

+1
source

You do not need to answer your question, but usually, when we buy a license for a software product, it usually comes with some support. It might be a good idea to just call and see if the provider has a solution that they recommend.

0
source

Source: https://habr.com/ru/post/1721499/


All Articles