mirror of
https://github.com/BepInEx/dotnet-runtime.git
synced 2026-11-23 03:39:35 -10:00
Commit migrated from https://github.com/dotnet/corefx/commit/7cad8486cbabbce0236bdf530e30db7036335524
49 lines
1.4 KiB
C#
49 lines
1.4 KiB
C#
// Licensed to the .NET Foundation under one or more agreements.
|
|
// The .NET Foundation licenses this file to you under the MIT license.
|
|
// See the LICENSE file in the project root for more information.
|
|
|
|
using System;
|
|
using System.IO;
|
|
using Xunit;
|
|
|
|
namespace System.IO.Tests
|
|
{
|
|
public class FileStream_CanRead : FileSystemTest
|
|
{
|
|
[Fact]
|
|
public void CanReadTrueForReadableStream()
|
|
{
|
|
string fileName = GetTestFilePath();
|
|
using (FileStream fs = new FileStream(fileName, FileMode.Create, FileAccess.ReadWrite))
|
|
{
|
|
Assert.True(fs.CanRead);
|
|
}
|
|
|
|
using (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read))
|
|
{
|
|
Assert.True(fs.CanRead);
|
|
}
|
|
}
|
|
|
|
[Fact]
|
|
public void CanReadFalseForWriteOnlyStream()
|
|
{
|
|
using (FileStream fs = new FileStream(GetTestFilePath(), FileMode.Create, FileAccess.Write))
|
|
{
|
|
Assert.False(fs.CanRead);
|
|
}
|
|
}
|
|
|
|
[Fact]
|
|
public void CanReadFalseForDisposedStream()
|
|
{
|
|
using (FileStream fs = new FileStream(GetTestFilePath(), FileMode.Create))
|
|
{
|
|
Assert.True(fs.CanRead);
|
|
fs.Dispose();
|
|
Assert.False(fs.CanRead);
|
|
}
|
|
}
|
|
}
|
|
}
|