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
59 lines
2.1 KiB
C#
59 lines
2.1 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 Microsoft.Win32.SafeHandles;
|
|
using System;
|
|
using System.IO;
|
|
using Xunit;
|
|
|
|
namespace System.IO.Tests
|
|
{
|
|
public class FileStream_IsAsync : FileSystemTest
|
|
{
|
|
[Fact]
|
|
public void IsAsyncConstructorArg()
|
|
{
|
|
using (FileStream fs = new FileStream(GetTestFilePath(), FileMode.Create, FileAccess.ReadWrite, FileShare.Read, 4096, true))
|
|
{
|
|
Assert.True(fs.IsAsync);
|
|
}
|
|
|
|
using (FileStream fs = new FileStream(GetTestFilePath(), FileMode.Create, FileAccess.ReadWrite, FileShare.Read, 4096, false))
|
|
{
|
|
Assert.False(fs.IsAsync);
|
|
}
|
|
}
|
|
|
|
[Fact]
|
|
public void FileOptionsAsynchronousConstructorArg()
|
|
{
|
|
using (FileStream fs = new FileStream(GetTestFilePath(), FileMode.Create, FileAccess.ReadWrite, FileShare.Read, 4096, FileOptions.Asynchronous))
|
|
{
|
|
Assert.True(fs.IsAsync);
|
|
}
|
|
|
|
using (FileStream fs = new FileStream(GetTestFilePath(), FileMode.Create, FileAccess.ReadWrite, FileShare.Read, 4096, FileOptions.None))
|
|
{
|
|
Assert.False(fs.IsAsync);
|
|
}
|
|
}
|
|
|
|
[Fact]
|
|
public void AsyncDiscoveredFromHandle()
|
|
{
|
|
using (FileStream fs = new FileStream(GetTestFilePath(), FileMode.Create, FileAccess.ReadWrite, FileShare.Read, 4096, true))
|
|
using (FileStream fsh = new FileStream(fs.SafeFileHandle, FileAccess.ReadWrite))
|
|
{
|
|
Assert.True(fsh.IsAsync);
|
|
}
|
|
|
|
using (FileStream fs = new FileStream(GetTestFilePath(), FileMode.Create, FileAccess.ReadWrite, FileShare.Read, 4096, false))
|
|
using (FileStream fsh = new FileStream(fs.SafeFileHandle, FileAccess.ReadWrite))
|
|
{
|
|
Assert.False(fsh.IsAsync);
|
|
}
|
|
}
|
|
}
|
|
}
|