hi, I am writing an unit test to test a very simple application. The application is very simple. It only have two public APIs:
- OpenFile API: copy an existing binary file to a new created temp file and read it.
- CloseFile API: close both files and delete the temp file created in OpenFile API.
While running/debugging the application, both APIs work fine. CloseFile API can delete the temp file without any issue. While I created an Unit test project to try to test the application's two APIs. In my test case, I just call both APIs 100 times (repeat open file and close file). But while calling CloseFile API, it always throw exceptions at the point deleting temp file by saying the file is being opened by other program. To test it further, I wrote another console app to call the two APIs 100 time (same logic as unit test). No issue at all.
Do you know why?