DeleteFile fails in DotCover and MSTest

I am using teamcity 8.1.1  mstest 11, dotCover

        [TestMethod, TestCategory("Recycle Bin")]
        public void TestDeleteFile()
        {
            var testFileName = Path.GetTempFileName();
            using (TextWriter textWriter = File.CreateText(testFileName))
            {
                textWriter.WriteLine("This is a recycled Text from " + MethodBase.GetCurrentMethod().Name);
            }

            FileSystem.DeleteFile(testFileName, UIOption.OnlyErrorDialogs, RecycleOption.SendToRecycleBin);

            Assert.IsFalse(File.Exists(testFileName), "File must be deleted");
        }

Running this test in VS2012 using dotCover succeeds AND the file is sent to the recycling bin

Running this tes under teamcity mstest and dotCover succeeds but the file is NOT sent to the recycling bin.

If I use an interop to access SHFileOperation and delete with
FileOperationFlags.FOF_NOCONFIRMATION | FileOperationFlags.FOF_NOERRORUI | FileOperationFlags.FOF_SILENT | FileOperationFlags.FOF_ALLOWUNDO

Both the delete and send to recycle bin works under teamcity and vs2012.

Any idea what is happening here?

Thank you

Please sign in to leave a comment.