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


C# MessagePackObject.AsStringUtf16方法代码示例

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


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

示例1: TestAsStringUtf16_NonStringBinary

		public void TestAsStringUtf16_NonStringBinary()
		{
			var target = new MessagePackObject( new byte[] { 0xFF } );
			Assert.Throws<InvalidOperationException>( () => target.AsStringUtf16() );
		}
开发者ID:nagyist,项目名称:msgpack-cli,代码行数:5,代码来源:MessagePackObjectTest.Strings.cs

示例2: TestAsStringUtf16_Null_Success

		public void TestAsStringUtf16_Null_Success()
		{
			var target = new MessagePackObject( default( string ) );
			Assert.IsNull( target.AsStringUtf16() );
		}
开发者ID:nagyist,项目名称:msgpack-cli,代码行数:5,代码来源:MessagePackObjectTest.Strings.cs

示例3: TestAsStringUtf16_IsNotString

		public void TestAsStringUtf16_IsNotString()
		{
			var target = new MessagePackObject( 0 );
			Assert.Throws<InvalidOperationException>( () => target.AsStringUtf16() );
		}
开发者ID:nagyist,项目名称:msgpack-cli,代码行数:5,代码来源:MessagePackObjectTest.Strings.cs

示例4: TestAsStringUtf16_ForNonEncoded_Success

		public void TestAsStringUtf16_ForNonEncoded_Success()
		{
			var target = new MessagePackObject( _japanese );
			Assert.AreEqual( _japanese, target.AsStringUtf16() );
		}
开发者ID:nagyist,项目名称:msgpack-cli,代码行数:5,代码来源:MessagePackObjectTest.Strings.cs

示例5: TestAsStringUtf16_EncodingMissmatch

		public void TestAsStringUtf16_EncodingMissmatch()
		{
			var target = new MessagePackObject( Encoding.UTF8.GetBytes( _japanese ) );
			Assert.Throws<InvalidOperationException>( () => target.AsStringUtf16() );
		}
开发者ID:nagyist,项目名称:msgpack-cli,代码行数:5,代码来源:MessagePackObjectTest.Strings.cs

示例6: TestAsStringUtf16_Utf16BEWithoutBom_Success

		public void TestAsStringUtf16_Utf16BEWithoutBom_Success()
		{
			var target = new MessagePackObject( Encoding.BigEndianUnicode.GetBytes( _japanese ) );
			Assert.AreEqual( _japanese, target.AsStringUtf16() );
		}
开发者ID:nagyist,项目名称:msgpack-cli,代码行数:5,代码来源:MessagePackObjectTest.Strings.cs

示例7: TestAsStringUtf16_Empty_Success

		public void TestAsStringUtf16_Empty_Success()
		{
			var target = new MessagePackObject( new byte[ 0 ] );
			Assert.AreEqual( "", target.AsStringUtf16() );
		}
开发者ID:nagyist,项目名称:msgpack-cli,代码行数:5,代码来源:MessagePackObjectTest.Strings.cs

示例8: TestAsStringUtf16_Utf16LEWithoutBom_CannotDetected

		public void TestAsStringUtf16_Utf16LEWithoutBom_CannotDetected()
		{
			var target = new MessagePackObject( Encoding.Unicode.GetBytes( _japanese ) );
			string result;
			try
			{
				result = target.AsStringUtf16();
			}
			catch ( InvalidOperationException )
			{
				// It is OK. The bytes cannot be decoded as UTF-16BE.
				return;
			}

			// It is OK. The bytes incidentally can be decoded as UTF-16BE.
			Assert.AreNotEqual( _japanese, result );
		}
开发者ID:nagyist,项目名称:msgpack-cli,代码行数:17,代码来源:MessagePackObjectTest.Strings.cs

示例9: TestAsStringUtf16_Utf16LEWithBom_Success

		public void TestAsStringUtf16_Utf16LEWithBom_Success()
		{
			var target = new MessagePackObject( Encoding.Unicode.GetPreamble().Concat( Encoding.Unicode.GetBytes( _japanese ) ).ToArray() );
			Assert.AreEqual( _japanese, target.AsStringUtf16() );
		}
开发者ID:nagyist,项目名称:msgpack-cli,代码行数:5,代码来源:MessagePackObjectTest.Strings.cs

示例10: TestAsStringUtf16_NonStringBinary

		public void TestAsStringUtf16_NonStringBinary()
		{
			var target = new MessagePackObject( new byte[] { 0xFF } );
			target.AsStringUtf16();
		}
开发者ID:davemkirk,项目名称:msgpack-cli,代码行数:5,代码来源:MessagePackObjectTest.Strings.cs

示例11: TestAsStringUtf16_IsNotString

		public void TestAsStringUtf16_IsNotString()
		{
			var target = new MessagePackObject( 0 );
			target.AsStringUtf16();
		}
开发者ID:davemkirk,项目名称:msgpack-cli,代码行数:5,代码来源:MessagePackObjectTest.Strings.cs

示例12: TestAsStringUtf16_EncodingMissmatch

		public void TestAsStringUtf16_EncodingMissmatch()
		{
			var target = new MessagePackObject( Encoding.UTF8.GetBytes( _japanese ) );
			var result = target.AsStringUtf16();
		}
开发者ID:davemkirk,项目名称:msgpack-cli,代码行数:5,代码来源:MessagePackObjectTest.Strings.cs


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