I'm writing some code that unblocks files that have the Zone.Identifier stream on them. The code works but I can't seem to get a unit test to work to test it. In the test I want to create a file which has the alternative data stream on it in a MockFileSystem. The problem is that the System.IO.Abstractions.TestingHelpers.MockFileSystem class doesn't support colons in the paths. This is the code I'm using:
public void AlternateDataStreamExistsTest()
{
var fileSystem = new MockFileSystem();
using (MemoryStream ms = new MemoryStream())
{
using (Stream fs = fileSystem.File.Create(@"a.txt:Zone:Identifier"))
{
using (var streamWriter = new StreamWriter(fs))
{
streamWriter.WriteLine("[ZoneTransfer]");
streamWriter.WriteLine("ZoneId=3");
}
}
}
FileUnblocker fileUnblocker = new FileUnblocker(fileSystem);
bool result = fileUnblocker.AlternateDataStreamExists(@"a.txt", "Zone.Identifier");
Assert.IsTrue(result);
}
Test method threw exception: System.NotSupportedException: The path is not of a legal form.
This is the error I get in return. I know the package Trinet.Core.IO.NTFS exists, but I can't use that for undisclosed reasons.