mirror of https://github.com/SixLabors/ImageSharp
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.2 KiB
50 lines
1.2 KiB
// Copyright (c) Six Labors.
|
|
// Licensed under the Apache License, Version 2.0.
|
|
|
|
using System;
|
|
using System.IO;
|
|
using SixLabors.ImageSharp.IO;
|
|
using Xunit;
|
|
|
|
namespace SixLabors.ImageSharp.Tests.IO
|
|
{
|
|
public class LocalFileSystemTests
|
|
{
|
|
[Fact]
|
|
public void OpenRead()
|
|
{
|
|
string path = Path.GetTempFileName();
|
|
string testData = Guid.NewGuid().ToString();
|
|
File.WriteAllText(path, testData);
|
|
|
|
var fs = new LocalFileSystem();
|
|
|
|
using (var r = new StreamReader(fs.OpenRead(path)))
|
|
{
|
|
string data = r.ReadToEnd();
|
|
|
|
Assert.Equal(testData, data);
|
|
}
|
|
|
|
File.Delete(path);
|
|
}
|
|
|
|
[Fact]
|
|
public void Create()
|
|
{
|
|
string path = Path.GetTempFileName();
|
|
string testData = Guid.NewGuid().ToString();
|
|
var fs = new LocalFileSystem();
|
|
|
|
using (var r = new StreamWriter(fs.Create(path)))
|
|
{
|
|
r.Write(testData);
|
|
}
|
|
|
|
string data = File.ReadAllText(path);
|
|
Assert.Equal(testData, data);
|
|
|
|
File.Delete(path);
|
|
}
|
|
}
|
|
}
|