本文整理汇总了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() );
}
示例2: TestAsStringUtf16_Null_Success
public void TestAsStringUtf16_Null_Success()
{
var target = new MessagePackObject( default( string ) );
Assert.IsNull( target.AsStringUtf16() );
}
示例3: TestAsStringUtf16_IsNotString
public void TestAsStringUtf16_IsNotString()
{
var target = new MessagePackObject( 0 );
Assert.Throws<InvalidOperationException>( () => target.AsStringUtf16() );
}
示例4: TestAsStringUtf16_ForNonEncoded_Success
public void TestAsStringUtf16_ForNonEncoded_Success()
{
var target = new MessagePackObject( _japanese );
Assert.AreEqual( _japanese, target.AsStringUtf16() );
}
示例5: TestAsStringUtf16_EncodingMissmatch
public void TestAsStringUtf16_EncodingMissmatch()
{
var target = new MessagePackObject( Encoding.UTF8.GetBytes( _japanese ) );
Assert.Throws<InvalidOperationException>( () => target.AsStringUtf16() );
}
示例6: TestAsStringUtf16_Utf16BEWithoutBom_Success
public void TestAsStringUtf16_Utf16BEWithoutBom_Success()
{
var target = new MessagePackObject( Encoding.BigEndianUnicode.GetBytes( _japanese ) );
Assert.AreEqual( _japanese, target.AsStringUtf16() );
}
示例7: TestAsStringUtf16_Empty_Success
public void TestAsStringUtf16_Empty_Success()
{
var target = new MessagePackObject( new byte[ 0 ] );
Assert.AreEqual( "", target.AsStringUtf16() );
}
示例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 );
}
示例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() );
}
示例10: TestAsStringUtf16_NonStringBinary
public void TestAsStringUtf16_NonStringBinary()
{
var target = new MessagePackObject( new byte[] { 0xFF } );
target.AsStringUtf16();
}
示例11: TestAsStringUtf16_IsNotString
public void TestAsStringUtf16_IsNotString()
{
var target = new MessagePackObject( 0 );
target.AsStringUtf16();
}
示例12: TestAsStringUtf16_EncodingMissmatch
public void TestAsStringUtf16_EncodingMissmatch()
{
var target = new MessagePackObject( Encoding.UTF8.GetBytes( _japanese ) );
var result = target.AsStringUtf16();
}