mirror of
https://github.com/chylex/.NET-Community-Toolkit.git
synced 2024-11-24 07:42:45 +01:00
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);
|
|
}
|
|
}
|