当前位置: 首页>>代码示例>>C#>>正文


C# PacketReader.Invoking方法代码示例

本文整理汇总了C#中PacketReader.Invoking方法的典型用法代码示例。如果您正苦于以下问题:C# PacketReader.Invoking方法的具体用法?C# PacketReader.Invoking怎么用?C# PacketReader.Invoking使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PacketReader的用法示例。


在下文中一共展示了PacketReader.Invoking方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TrySkipTo_Should_Throw_When_Offset_Is_Negative_In_Segment

        public void TrySkipTo_Should_Throw_When_Offset_Is_Negative_In_Segment()
        {
            var buffer = Helpers.GetRandomBytes(20);
            var reader = new PacketReader(buffer, 10, 10);

            reader
                .Invoking(r => r.TrySkipTo(-1))
                .ShouldThrow<ArgumentOutOfRangeException>();
        }
开发者ID:shoftee,项目名称:OpenStory,代码行数:9,代码来源:SafePacketReadingFixture.cs

示例2: TrySkipTo_Should_Throw_When_Offset_Is_Before_Current_Position

        public void TrySkipTo_Should_Throw_When_Offset_Is_Before_Current_Position()
        {
            var buffer = Helpers.GetRandomBytes(10);
            var reader = new PacketReader(buffer);

            reader.Skip(5);

            reader
                .Invoking(r => r.TrySkipTo(1))
                .ShouldThrow<ArgumentOutOfRangeException>();
        }
开发者ID:shoftee,项目名称:OpenStory,代码行数:11,代码来源:SafePacketReadingFixture.cs

示例3: ThrowsAndDoesNotMovePosition

        private static void ThrowsAndDoesNotMovePosition(PacketReader reader, Action<PacketReader> action)
        {
            int expected = reader.Remaining;
            reader.Invoking(action).ShouldThrow<PacketReadingException>();

            int actual = reader.Remaining;
            actual.Should().Be(expected);
        }
开发者ID:shoftee,项目名称:OpenStory,代码行数:8,代码来源:UnsafePacketReadingFixture.cs

示例4: ThrowsPreOnReadOperations

        private static void ThrowsPreOnReadOperations(PacketReader reader, int skip, int padLength, int byteCount)
        {
            reader
                .Invoking(r => r.Skip(skip))
                .ShouldThrow<PacketReadingException>();

            reader
                .Invoking(r => r.ReadBoolean())
                .ShouldThrow<PacketReadingException>();

            reader
                .Invoking(r => r.ReadByte())
                .ShouldThrow<PacketReadingException>();

            reader
                .Invoking(r => r.ReadInt16())
                .ShouldThrow<PacketReadingException>();

            reader
                .Invoking(r => r.ReadUInt16())
                .ShouldThrow<PacketReadingException>();

            reader
                .Invoking(r => r.ReadInt32())
                .ShouldThrow<PacketReadingException>();

            reader
                .Invoking(r => r.ReadUInt32())
                .ShouldThrow<PacketReadingException>();

            reader
                .Invoking(r => r.ReadInt64())
                .ShouldThrow<PacketReadingException>();

            reader
                .Invoking(r => r.ReadUInt64())
                .ShouldThrow<PacketReadingException>();

            reader
                .Invoking(r => r.ReadLengthString())
                .ShouldThrow<PacketReadingException>();

            reader
                .Invoking(r => r.ReadPaddedString(padLength))
                .ShouldThrow<PacketReadingException>();

            reader
                .Invoking(r => r.ReadBytes(byteCount))
                .ShouldThrow<PacketReadingException>();
        }
开发者ID:shoftee,项目名称:OpenStory,代码行数:50,代码来源:UnsafePacketReadingFixture.cs

示例5: ReadPaddedString_Should_Throw_When_Data_Is_Missing

 public void ReadPaddedString_Should_Throw_When_Data_Is_Missing()
 {
     var reader = new PacketReader(new byte[] { 1, 1, 1, 1, 1, 1, 1, 1 });
     reader
         .Invoking(r => r.ReadPaddedString(13))
         .ShouldThrow<PacketReadingException>();
 }
开发者ID:shoftee,项目名称:OpenStory,代码行数:7,代码来源:UnsafePacketReadingFixture.cs


注:本文中的PacketReader.Invoking方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。