Good day.

I'm just starting to understand unit testing, and I have a question about creating unit tests.

The question is more on logic, I guess.

I will have 4 methods:

  1. Loading the matrix from the file into the two-dimensional array GetMatrix(string filename) ;
  2. The method by which the matrix is ​​rotated 90 degrees - void RotateMatrix() ;
  3. Matrix output method on the screen - void ToScreen() ;
  4. Saving matrix to file.

I need to write 2 unit tests in this project.

Question: how best to implement tests? What logic to use? What to check?

Thank!

  • > What to check? Well, actually, what you want to implement, then check - that the matrix successfully loaded, that it correctly turns, that saving it to the file is successful. - DreamChild
  • Is it possible to be a little more specific? I just understand how to do a check in load / save methods using try / catch. But with the help of unit tests - while not very. - Telsystems
  • four
    @Telsystems, more specifically you should read some unit testing guidelines. Not that this is a very voluminous topic, but still it is beyond the scope of a single answer, or even less a comment. In brief: you create a test project with classes for tests, in each specific method of these classes you check with asserts (and / or some kind of your own logic) the suitability of your business logic to the tasks assigned to this logic. Run tests with different data, both correct and incorrect. - DreamChild

0