-
-
Notifications
You must be signed in to change notification settings - Fork 9
Closed
Labels
Description
Hi found one more issue in the mock system where if create file then run replace to move its content to other. Then do it again cause the second replace to throw error. Here is test code sample of the problem
[TestMethod]
public void Test() // this throw System.IO.IOException: The process cannot access the file 'C:\Test\Test.json' because it is being used by another process
{
var fs = new MockFileSystem();
var d = fs.Directory.CreateDirectory("Test");
var file1 = fs.FileInfo.New(Path.Combine(d.FullName, "Test.json"));
var file2 = fs.FileInfo.New(Path.Combine(d.FullName, "Test.json.atomic"));
using (var stream = file2.Create())
{
stream.WriteByte(9);
}
using (var stream = file1.Create())
{
stream.WriteByte(3);
}
file2.Replace(file1.FullName, null);
var file3 = fs.FileInfo.New(Path.Combine(d.FullName, "Test.json.atomic")); // change name here and it works
using (var stream = file3.Create())
{
stream.WriteByte(3);
}
file3.Replace(file1.FullName, null);
}
This works on normal file system. Not 100% sure that this is the problem but it looks like Destination container gets replace source container but inside the container it also has location that still points to old place -> https://github.com/Testably/Testably.Abstractions/blob/main/Source/Testably.Abstractions.Testing/Storage/InMemoryContainer.cs#L20