Files
Sergio Pedri e88c524c3e Refactor unit tests to use expected-first Assert.AreEqual
Updated all unit tests to consistently use the expected value as the first argument in Assert.AreEqual calls. This improves readability and aligns with best practices for test assertions.
2025-11-09 18:33:21 -08:00

33 lines
972 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(0, stream.Position);
stream.Dispose();
_ = Assert.ThrowsExactly<ObjectDisposedException>(() => buffer.Memory);
}
}