Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add stream conformance tests for standalone streams #44069

Merged
merged 3 commits into from
Nov 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,620 changes: 1,272 additions & 348 deletions src/libraries/Common/tests/Tests/System/IO/StreamConformanceTests.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<Compile Include="CompressionStreamUnitTests.ZLib.cs" />
Expand Down

This file was deleted.

47 changes: 0 additions & 47 deletions src/libraries/System.IO.FileSystem/tests/FileStream/CanRead.cs

This file was deleted.

60 changes: 0 additions & 60 deletions src/libraries/System.IO.FileSystem/tests/FileStream/CanSeek.cs

This file was deleted.

25 changes: 0 additions & 25 deletions src/libraries/System.IO.FileSystem/tests/FileStream/CanTimeout.cs

This file was deleted.

51 changes: 0 additions & 51 deletions src/libraries/System.IO.FileSystem/tests/FileStream/CanWrite.cs

This file was deleted.

20 changes: 0 additions & 20 deletions src/libraries/System.IO.FileSystem/tests/FileStream/CopyToAsync.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Microsoft.Win32.SafeHandles;
using System.Collections.Generic;
using System.IO.Pipes;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using Xunit;
Expand Down Expand Up @@ -174,22 +171,5 @@ public override Task<int> ReadAsync(byte[] buffer, int offset, int count, Cancel
return base.ReadAsync(buffer, offset, count, cancellationToken);
}
}

#region Windows P/Invokes
// We need to P/Invoke to test the named pipe async behavior with FileStream
// because NamedPipeClientStream internally binds the created handle,
// and that then prevents FileStream's constructor from working with the handle
// when trying to set isAsync to true.

[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool WaitNamedPipeW(string name, int timeout);

[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
internal static extern SafeFileHandle CreateFileW(
string lpFileName, int dwDesiredAccess, FileShare dwShareMode,
IntPtr securityAttrs, FileMode dwCreationDisposition, int dwFlagsAndAttributes, IntPtr hTemplateFile);

#endregion
}
}
16 changes: 0 additions & 16 deletions src/libraries/System.IO.FileSystem/tests/FileStream/Dispose.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ namespace System.IO.Tests
{
public class FileStream_Dispose : FileSystemTest
{
[Fact]
public void CanDispose()
{
new FileStream(GetTestFilePath(), FileMode.Create).Dispose();
}

[Fact]
public void DisposeClosesHandle()
{
Expand All @@ -30,16 +24,6 @@ public void DisposeClosesHandle()
Assert.True(handle.IsClosed);
}

[Fact]
public void HandlesMultipleDispose()
{
using (FileStream fs = new FileStream(GetTestFilePath(), FileMode.Create))
{
fs.Dispose();
fs.Dispose();
} // disposed as we leave using
}

private class MyFileStream : FileStream
{
public MyFileStream(string path, FileMode mode)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@ namespace System.IO.Tests
{
public class FileStream_DisposeAsync : FileSystemTest
{
[Fact]
public void CanDisposeAsync()
{
Assert.True(new FileStream(GetTestFilePath(), FileMode.Create).DisposeAsync().IsCompletedSuccessfully);
}

[Fact]
public async Task DisposeAsyncClosesHandle()
{
Expand All @@ -25,15 +19,6 @@ public async Task DisposeAsyncClosesHandle()
Assert.True(handle.IsClosed);
}

[Fact]
public async Task HandlesMultipleDisposeAsync()
{
var fs = new FileStream(GetTestFilePath(), FileMode.Create);
await fs.DisposeAsync();
fs.Dispose();
await fs.DisposeAsync();
}

[Fact]
public async Task DisposeAsyncFlushes()
{
Expand Down
Loading