public void TestSerializeTooLargeTagContext() { var builder = tagger.EmptyBuilder; for (var i = 0; i < SerializationUtils.TagContextSerializedSizeLimit / 8 - 1; i++) { // Each tag will be with format {key : "0123", value : "0123"}, so the length of it is 8. String str; if (i < 10) { str = "000" + i; } else if (i < 100) { str = "00" + i; } else if (i < 1000) { str = "0" + i; } else { str = i.ToString(); } builder.Put(str, str); } // The last tag will be of size 9, so the total size of the TagContext (8193) will be one byte // more than limit. builder.Put("last", "last1"); var tagContext = builder.Build(); Assert.Throws <TagContextSerializationException>(() => serializer.ToByteArray(tagContext)); }
public void TestSerializeTooLargeTagContext() { ITagContextBuilder builder = tagger.EmptyBuilder; for (int i = 0; i < SerializationUtils.TAGCONTEXT_SERIALIZED_SIZE_LIMIT / 8 - 1; i++) { // Each tag will be with format {key : "0123", value : "0123"}, so the length of it is 8. String str; if (i < 10) { str = "000" + i; } else if (i < 100) { str = "00" + i; } else if (i < 1000) { str = "0" + i; } else { str = i.ToString(); } builder.Put(TagKey.Create(str), TagValue.Create(str)); } // The last tag will be of size 9, so the total size of the TagContext (8193) will be one byte // more than limit. builder.Put(TagKey.Create("last"), TagValue.Create("last1")); ITagContext tagContext = builder.Build(); Assert.Throws <TagContextSerializationException>(() => serializer.ToByteArray(tagContext)); }
private void TestRoundtripSerialization(ITagContext expected) { byte[] bytes = serializer.ToByteArray(expected); ITagContext actual = serializer.FromByteArray(bytes); Assert.Equal(expected, actual); }
public void NoopTagContextBinarySerializer_ToByteArray_DisallowsNull() { ITagContextBinarySerializer noopSerializer = NoopTags.NoopTagContextBinarySerializer; Assert.Throws <ArgumentNullException>(() => noopSerializer.ToByteArray(null)); }