-
Notifications
You must be signed in to change notification settings - Fork 267
Closed
Labels
state: in workIssues that are currently worked onIssues that are currently worked ontype: bugIssues that describe misbehaving functionalityIssues that describe misbehaving functionality
Description
Version 3.1.1
MockFileStream does not seem to be obeying the AllowedFileShare property. See the example below, I would expect to see an exception throw when trying to create the FileStream.
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Abstractions.TestingHelpers;
using System.Text;
namespace FileStreamTest
{
class Program
{
static void Main(string[] args)
{
IDictionary<string, MockFileData> files = new Dictionary<string, MockFileData>
{
{ "C:\\test\\file.txt", new MockFileData("contents") { AllowedFileShare = FileShare.None } }
};
var fs = new MockFileSystem(files);
// Does not throw exception
var stream = fs.FileStream.Create("C:\\test\\file.txt", FileMode.Open, FileAccess.Read, FileShare.Read);
using (stream)
{
using (var reader = new StreamReader(stream, Encoding.Default))
{
string line;
while ((line = reader.ReadLine()) != null)
{
Console.Write(line);
}
}
}
Console.Write(Environment.NewLine);
// Throws System.IO.IOException as expected
var text = fs.File.ReadAllText("C:\\test\\file.txt");
Console.WriteLine(text);
}
}
}Metadata
Metadata
Assignees
Labels
state: in workIssues that are currently worked onIssues that are currently worked ontype: bugIssues that describe misbehaving functionalityIssues that describe misbehaving functionality