本文整理汇总了C#中EventStore.Core.Services.Transport.Tcp.TcpPackage.AsArraySegment方法的典型用法代码示例。如果您正苦于以下问题:C# TcpPackage.AsArraySegment方法的具体用法?C# TcpPackage.AsArraySegment怎么用?C# TcpPackage.AsArraySegment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EventStore.Core.Services.Transport.Tcp.TcpPackage
的用法示例。
在下文中一共展示了TcpPackage.AsArraySegment方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: not_authorized_with_empty_data_should_serialize_and_deserialize_correctly
public void not_authorized_with_empty_data_should_serialize_and_deserialize_correctly()
{
var corrId = Guid.NewGuid();
var refPkg = new TcpPackage(TcpCommand.BadRequest, TcpFlags.None, corrId, null, null, new byte[0]);
var bytes = refPkg.AsArraySegment();
var pkg = TcpPackage.FromArraySegment(bytes);
Assert.AreEqual(TcpCommand.BadRequest, pkg.Command);
Assert.AreEqual(TcpFlags.None, pkg.Flags);
Assert.AreEqual(corrId, pkg.CorrelationId);
Assert.AreEqual(null, pkg.Login);
Assert.AreEqual(null, pkg.Password);
Assert.AreEqual(0, pkg.Data.Count);
}
示例2: authorized_with_data_should_serialize_and_deserialize_correctly
public void authorized_with_data_should_serialize_and_deserialize_correctly()
{
var corrId = Guid.NewGuid();
var refPkg = new TcpPackage(TcpCommand.BadRequest, TcpFlags.Authenticated, corrId, "login", "pa$$", new byte[] { 1, 2, 3 });
var bytes = refPkg.AsArraySegment();
var pkg = TcpPackage.FromArraySegment(bytes);
Assert.AreEqual(TcpCommand.BadRequest, pkg.Command);
Assert.AreEqual(TcpFlags.Authenticated, pkg.Flags);
Assert.AreEqual(corrId, pkg.CorrelationId);
Assert.AreEqual("login", pkg.Login);
Assert.AreEqual("pa$$", pkg.Password);
Assert.AreEqual(3, pkg.Data.Count);
Assert.AreEqual(1, pkg.Data.Array[pkg.Data.Offset + 0]);
Assert.AreEqual(2, pkg.Data.Array[pkg.Data.Offset + 1]);
Assert.AreEqual(3, pkg.Data.Array[pkg.Data.Offset + 2]);
}