mirror of
https://github.com/Azure/DotNetty.git
synced 2026-10-19 06:31:20 +08:00
31 lines
1.0 KiB
C#
31 lines
1.0 KiB
C#
// Copyright (c) Microsoft. All rights reserved.
|
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
|
|
namespace DotNetty.Codecs.Redis.Tests
|
|
{
|
|
using System;
|
|
using System.Globalization;
|
|
using System.Text;
|
|
using DotNetty.Buffers;
|
|
|
|
static class RedisCodecTestUtil
|
|
{
|
|
internal static byte[] BytesOf(long value) => Encoding.ASCII.GetBytes(Convert.ToString(value, CultureInfo.InvariantCulture));
|
|
|
|
internal static byte[] BytesOf(string value) => Encoding.UTF8.GetBytes(value);
|
|
|
|
internal static byte[] BytesOf(IByteBuffer byteBuffer)
|
|
{
|
|
var data = new byte[byteBuffer.ReadableBytes];
|
|
byteBuffer.ReadBytes(data);
|
|
return data;
|
|
}
|
|
|
|
internal static string StringOf(IByteBuffer buf) => Encoding.UTF8.GetString(BytesOf(buf));
|
|
|
|
internal static IByteBuffer ByteBufOf(string s) => ByteBufOf(BytesOf(s));
|
|
|
|
internal static IByteBuffer ByteBufOf(byte[] data) => Unpooled.WrappedBuffer(data);
|
|
}
|
|
}
|