Пример #1
0
        public void it_will_read_struct_with_string_byval()
        {
            var expected = new StringStructByval
            {
                First = 0x12345678,
                Text  = Utf8String,
                Last  = 0x76543210
            };

            var source = new byte[] { 0x78, 0x56, 0x34, 0x12, 0x5e, 0x01, 0xdb, 0x1e, 0xdd, 0x10, 0xb5, 0x03, 0x20, 0x00, 0x5f, 0x01, 0xb7, 0x1e, 0x3c, 0x04, 0x40, 0x04, 0x3a, 0x01, 0xea, 0x00, 0x20, 0x00, 0xc4, 0x00, 0x5a, 0x01, 0x08, 0x01, 0xcd, 0x00, 0x7c, 0x00, 0x2d, 0x00, 0x65, 0x01, 0x2e, 0x21, 0xc7, 0x03, 0x67, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x32, 0x54, 0x76 };

            using (var reader = new BinaryReader(new MemoryStream(source)))
            {
                var value = reader.ReadStruct <StringStructByval>();
                value.Should().Be(expected);
                reader.BaseStream.Should().BeEof();
            }
        }
		public void it_will_read_struct_with_string_byval()
		{
			var expected = new StringStructByval()
			{
				First = 0x12345678,
				Text = Utf8String,
				Last = 0x76543210
			};
			
			var source = new byte[]
			{
				0x78, 0x56, 0x34, 0x12, 0x5e, 0x01, 0xdb, 0x1e, 0xdd, 0x10, 0xb5, 0x03, 0x20, 0x00, 0x5f, 0x01, 0xb7, 0x1e, 0x3c, 0x04, 0x40, 0x04, 0x3a, 0x01, 0xea, 0x00, 0x20, 0x00, 0xc4, 0x00, 0x5a, 0x01, 0x08, 0x01, 0xcd, 0x00, 0x7c, 0x00, 0x2d, 0x00, 0x65, 0x01, 0x2e, 0x21, 0xc7, 0x03, 0x67, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x32, 0x54, 0x76
			};

			using (var reader = new BinaryReader(new MemoryStream(source)))
			{
				var value = reader.ReadStruct<StringStructByval>();
				value.Should().Be(expected);
				reader.BaseStream.ShouldBeEof();
			}
		}