hvanbakel / CsprojToVs2017

Tooling for converting pre 2017 project to the new Visual Studio 2017 format.
MIT License
1.08k stars 120 forks source link

ValidateFileisWritable test fails after first run #175

Closed mungojam closed 6 years ago

mungojam commented 6 years ago

I guess it should just delete the file if it exists prior to running the test or something like that

Test Name: ValidatesFileIsWritable Test FullName: Project2015To2017Tests.ProjectWriterTest.ValidatesFileIsWritable Test Source: C:\Users\mark\source\repos\CsprojToVs2017\Project2015To2017Tests\ProjectWriterTest.cs : line 21 Test Outcome: Failed Test Duration: 0:00:00.0627415

Result StackTrace:
at System.IO.Win32FileSystem.CopyFile(String sourceFullPath, String destFullPath, Boolean overwrite) at System.IO.File.InternalCopy(String sourceFileName, String destFileName, Boolean overwrite) at System.IO.File.Copy(String sourceFileName, String destFileName) at Project2015To2017Tests.ProjectWriterTest.ValidatesFileIsWritable() in C:\Users\mark\source\repos\CsprojToVs2017\Project2015To2017Tests\ProjectWriterTest.cs:line 32 Result Message: Test method Project2015To2017Tests.ProjectWriterTest.ValidatesFileIsWritable threw exception: System.IO.IOException: The file 'C:\Users\mark\source\repos\CsprojToVs2017\Project2015To2017Tests\bin\Debug\netcoreapp2.0\TestFiles\OtherTestProjects\ValidatesFileIsWritable.readonly' already exists.

hvanbakel commented 6 years ago

That only happens on failing tests as far as I know. A clean and then build will fix that. The setup is not ideal but given that what we're doing is so linked to files being on disk I guess this is something to 'deal with'.

The only real solution that I can see is to abstract away file access so we can mock that but that seems like overkill to me.

mungojam commented 6 years ago

I reckon I can fix it, by deleting the file at the start of the test if if already exists. Busy week at work this week (just back from hols), so probably at weekend for this and trying to tidy up other issues I've raised