Browse Source

fix test filesystem to prevent it breaking existing tests

af/merge-core
Scott Williams 9 years ago
parent
commit
acd51cc64f
  1. 15
      tests/ImageSharp.Tests/TestFileSystem.cs

15
tests/ImageSharp.Tests/TestFileSystem.cs

@ -36,29 +36,28 @@ namespace ImageSharp.Tests
public Stream Create(string path) public Stream Create(string path)
{ {
MemoryStream stream = new MemoryStream(); // if we have injected a fake file use it instead
lock (fileSystem) lock (fileSystem)
{ {
if (fileSystem.ContainsKey(path)) if (fileSystem.ContainsKey(path))
{ {
fileSystem[path] = stream; Stream stream = fileSystem[path];
} stream.Position = 0;
else return stream;
{
fileSystem.Add(path, stream);
} }
} }
return stream;
return File.Create(path);
} }
public Stream OpenRead(string path) public Stream OpenRead(string path)
{ {
// if we have injected a fake file use it instead
lock (fileSystem) lock (fileSystem)
{ {
if (fileSystem.ContainsKey(path)) if (fileSystem.ContainsKey(path))
{ {
Stream stream = fileSystem[path]; Stream stream = fileSystem[path];
stream.Position = 0; stream.Position = 0;
return stream; return stream;

Loading…
Cancel
Save