mirror of
https://github.com/chylex/.NET-Community-Toolkit.git
synced 2025-08-16 23:31:47 +02:00
.github
CommunityToolkit.Common
CommunityToolkit.Diagnostics
CommunityToolkit.HighPerformance
CommunityToolkit.Mvvm
CommunityToolkit.Mvvm.SourceGenerators
build
tests
CommunityToolkit.Common.UnitTests
CommunityToolkit.Diagnostics.UnitTests
CommunityToolkit.HighPerformance.UnitTests
Buffers
Enumerables
Extensions
Helpers
Memory
Streams
Test_IBufferWriterStream.cs
Test_IMemoryOwnerStream.cs
Test_MemoryStream.ThrowExceptions.cs
Test_MemoryStream.cs
CommunityToolkit.HighPerformance.UnitTests.csproj
Test_Box{T}.cs
Test_NullableReadOnlyRef{T}.cs
Test_NullableRef{T}.cs
Test_ReadOnlyRef{T}.cs
Test_Ref{T}.cs
CommunityToolkit.Mvvm.DisableINotifyPropertyChanging.UnitTests
CommunityToolkit.Mvvm.ExternalAssembly
CommunityToolkit.Mvvm.Internals.UnitTests
CommunityToolkit.Mvvm.SourceGenerators.UnitTests
CommunityToolkit.Mvvm.UnitTests
.editorconfig
.git-blame-ignore-revs
.gitattributes
.gitignore
.runsettings
CODE_OF_CONDUCT.md
Contributing.md
Directory.Build.props
Directory.Build.targets
License.md
README.md
ThirdPartyNotices.txt
azure-pipelines.yml
dotnet Community Toolkit.sln
toolkit.snk
version.json
33 lines
974 B
C#
33 lines
974 B
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 CommunityToolkit.HighPerformance.Buffers;
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
|
|
namespace CommunityToolkit.HighPerformance.UnitTests.Streams;
|
|
|
|
[TestClass]
|
|
public class Test_IMemoryOwnerStream
|
|
{
|
|
[TestMethod]
|
|
public void Test_IMemoryOwnerStream_Lifecycle()
|
|
{
|
|
MemoryOwner<byte> buffer = MemoryOwner<byte>.Allocate(100);
|
|
|
|
Stream stream = buffer.AsStream();
|
|
|
|
Assert.IsTrue(stream.CanRead);
|
|
Assert.IsTrue(stream.CanSeek);
|
|
Assert.IsTrue(stream.CanWrite);
|
|
Assert.AreEqual(stream.Length, buffer.Length);
|
|
Assert.AreEqual(stream.Position, 0);
|
|
|
|
stream.Dispose();
|
|
|
|
_ = Assert.ThrowsException<ObjectDisposedException>(() => buffer.Memory);
|
|
}
|
|
}
|