1
0
mirror of https://github.com/chylex/.NET-Community-Toolkit.git synced 2024-10-17 06:42:48 +02:00
.NET-Community-Toolkit/tests/CommunityToolkit.HighPerformance.UnitTests/Extensions/Test_ReadOnlyMemoryExtensions.cs
2021-11-04 21:48:54 +01:00

38 lines
1.0 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 System;
using System.IO;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace CommunityToolkit.HighPerformance.UnitTests.Extensions;
[TestClass]
public class Test_ReadOnlyMemoryExtensions
{
[TestMethod]
public void Test_ReadOnlyMemoryExtensions_EmptyMemoryStream()
{
ReadOnlyMemory<byte> memory = default;
Stream stream = memory.AsStream();
Assert.IsNotNull(stream);
Assert.AreEqual(stream.Length, memory.Length);
Assert.IsFalse(stream.CanWrite);
}
[TestMethod]
public void Test_ReadOnlyMemoryExtensions_MemoryStream()
{
ReadOnlyMemory<byte> memory = new byte[1024];
Stream stream = memory.AsStream();
Assert.IsNotNull(stream);
Assert.AreEqual(stream.Length, memory.Length);
Assert.IsFalse(stream.CanWrite);
}
}