예제 #1
0
 public override async Task WriteMapBeginAsync(TMap map, CancellationToken cancellationToken)
 {
     await WriteJsonArrayStartAsync(cancellationToken);
     await WriteJsonStringAsync(TJSONProtocolHelper.GetTypeNameForTypeId(map.KeyType), cancellationToken);
     await WriteJsonStringAsync(TJSONProtocolHelper.GetTypeNameForTypeId(map.ValueType), cancellationToken);
     await WriteJsonIntegerAsync(map.Count, cancellationToken);
     await WriteJsonObjectStartAsync(cancellationToken);
 }
예제 #2
0
        public void GetTypeNameForTypeId_Test()
        {
            // input/output
            var sets = new List <Tuple <TType, byte[]> >
            {
                new Tuple <TType, byte[]>(TType.Bool, TJSONProtocolConstants.TypeNames.NameBool),
                new Tuple <TType, byte[]>(TType.Byte, TJSONProtocolConstants.TypeNames.NameByte),
                new Tuple <TType, byte[]>(TType.I16, TJSONProtocolConstants.TypeNames.NameI16),
                new Tuple <TType, byte[]>(TType.I32, TJSONProtocolConstants.TypeNames.NameI32),
                new Tuple <TType, byte[]>(TType.I64, TJSONProtocolConstants.TypeNames.NameI64),
                new Tuple <TType, byte[]>(TType.Double, TJSONProtocolConstants.TypeNames.NameDouble),
                new Tuple <TType, byte[]>(TType.String, TJSONProtocolConstants.TypeNames.NameString),
                new Tuple <TType, byte[]>(TType.Struct, TJSONProtocolConstants.TypeNames.NameStruct),
                new Tuple <TType, byte[]>(TType.Map, TJSONProtocolConstants.TypeNames.NameMap),
                new Tuple <TType, byte[]>(TType.Set, TJSONProtocolConstants.TypeNames.NameSet),
                new Tuple <TType, byte[]>(TType.List, TJSONProtocolConstants.TypeNames.NameList),
            };

            foreach (var t in sets)
            {
                Assert.IsTrue(TJSONProtocolHelper.GetTypeNameForTypeId(t.Item1) == t.Item2, $"Wrong mapping of TypeName {t.Item2} to TType: {t.Item1}");
            }
        }
예제 #3
0
 public void GetTypeNameForTypeId_NonExistingTType_Test()
 {
     TJSONProtocolHelper.GetTypeNameForTypeId((TType)100);
 }
예제 #4
0
 public void GetTypeNameForTypeId_TStop_Test()
 {
     TJSONProtocolHelper.GetTypeNameForTypeId(TType.Stop);
 }
예제 #5
0
 public override async Task WriteSetBeginAsync(TSet set, CancellationToken cancellationToken)
 {
     await WriteJsonArrayStartAsync(cancellationToken);
     await WriteJsonStringAsync(TJSONProtocolHelper.GetTypeNameForTypeId(set.ElementType), cancellationToken);
     await WriteJsonIntegerAsync(set.Count, cancellationToken);
 }
예제 #6
0
 public override async Task WriteFieldBeginAsync(TField field, CancellationToken cancellationToken)
 {
     await WriteJsonIntegerAsync(field.ID, cancellationToken);
     await WriteJsonObjectStartAsync(cancellationToken);
     await WriteJsonStringAsync(TJSONProtocolHelper.GetTypeNameForTypeId(field.Type), cancellationToken);
 }
예제 #7
0
 public override async Task WriteListBeginAsync(TList list, CancellationToken cancellationToken)
 {
     await WriteJsonArrayStartAsync(cancellationToken).ConfigureAwait(false);
     await WriteJsonStringAsync(TJSONProtocolHelper.GetTypeNameForTypeId(list.ElementType), cancellationToken).ConfigureAwait(false);
     await WriteJsonIntegerAsync(list.Count, cancellationToken).ConfigureAwait(false);
 }