private void DecodeIfNeeded() { if (this._decoded != null) { return; } if (this._encoded == null) { return; } if (this._type != BinaryType.Unknwon) { return; } try { this._decoded = MessagePackConvert.DecodeStringStrict(this._encoded); this._type = BinaryType.String; } catch (DecoderFallbackException ex) { this._decodingError = ex; this._type = BinaryType.Blob; } }
public void TestDecodeStringStrict_WithBom_Success() { var encoding = new UTF8Encoding(encoderShouldEmitUTF8Identifier: true); byte[] value = encoding.GetBytes(_testValue); Assert.AreEqual(_testValue, MessagePackConvert.DecodeStringStrict(value)); }
public void TestDecodeStringStrict_Empty_Empty() { Assert.That(MessagePackConvert.DecodeStringStrict(new byte[0]), Is.Empty); }
public void TestDecodeStringStrict_Invalid() { byte[] value = Encoding.Unicode.GetBytes(_testValue); Assert.Throws <DecoderFallbackException>(() => MessagePackConvert.DecodeStringStrict(value)); }
public void TestDecodeStringStrict_Null() { Assert.Throws <ArgumentNullException>(() => MessagePackConvert.DecodeStringStrict(null)); }