I'm using c# in visual studio 2017.
When performing my unit tests, do i need to call the dispose() method to dispose the connection with the database? Or are opened connections automatically closed?
Thanks in advance
I'm using c# in visual studio 2017.
When performing my unit tests, do i need to call the dispose() method to dispose the connection with the database? Or are opened connections automatically closed?
Thanks in advance
This is too general because oyu do not provide a specific example. There are many ways to write a unit test.
if you open a connection WITHIN a unit test, either directly or indirectly (EF) then obviously you close it. If you rely on wrapping start and stop methods and have the connection per test prepared, you obviously do so in the wrapping methods.
It really depends. General rule: Dispose in a test what you create in a test.