Files
Johnny Z 33b95cfe61 Buffer read/write/get/set strings. (#369)
Motivation:
Implement commonly used string-based operations (originally Netty CharSequence) for byte buffers.

Modifications:
Added read/write/get/set strings methods to byte buffers.
Also reduced unsafe pin/unpins for byte operations.

Result:
String-based operations are supported in DotNetty
2018-03-15 14:58:49 -07:00

41 lines
1.3 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.Transport.Tests.Channel
{
using DotNetty.Transport.Channels;
using Xunit;
public class DefaulChannelIdTest
{
[Fact]
public void TestShortText()
{
string text = DefaultChannelId.NewInstance().AsShortText();
Assert.Matches(@"^[0-9a-f]{8}$", text);
}
[Fact]
public void TestLongText()
{
string text = DefaultChannelId.NewInstance().AsLongText();
Assert.Matches(@"^[0-9a-f]{16}-[0-9a-f]{8}-[0-9a-f]{8}-[0-9a-f]{16}-[0-9a-f]{8}$", text);
}
[Fact]
public void TestIdempotentMachineId()
{
string a = DefaultChannelId.NewInstance().AsLongText().Substring(0, 8);
string b = DefaultChannelId.NewInstance().AsLongText().Substring(0, 8);
Assert.Equal(a, b);
}
[Fact]
public void TestIdempotentProcessId()
{
string a = DefaultChannelId.NewInstance().AsLongText().Substring(9, 4);
string b = DefaultChannelId.NewInstance().AsLongText().Substring(9, 4);
Assert.Equal(a, b);
}
}
}