]> git.proxmox.com Git - ceph.git/blame - ceph/src/jaegertracing/thrift/lib/netstd/Tests/Thrift.Tests/Protocols/TJsonProtocolTests.cs
buildsys: switch source download to quincy
[ceph.git] / ceph / src / jaegertracing / thrift / lib / netstd / Tests / Thrift.Tests / Protocols / TJsonProtocolTests.cs
CommitLineData
f67539c2
TL
1// Licensed to the Apache Software Foundation(ASF) under one
2// or more contributor license agreements.See the NOTICE file
3// distributed with this work for additional information
4// regarding copyright ownership.The ASF licenses this file
5// to you under the Apache License, Version 2.0 (the
6// "License"); you may not use this file except in compliance
7// with the License. You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing,
12// software distributed under the License is distributed on an
13// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14// KIND, either express or implied. See the License for the
15// specific language governing permissions and limitations
16// under the License.
17
18using System;
19using System.Collections.Generic;
20using System.Text;
21using System.Threading;
22using System.Threading.Tasks;
23using Microsoft.VisualStudio.TestTools.UnitTesting;
24using NSubstitute;
25using Thrift.Protocol;
26using Thrift.Protocol.Entities;
27using Thrift.Transport;
28using Thrift.Transport.Client;
29
30namespace Thrift.Tests.Protocols
31{
32 // ReSharper disable once InconsistentNaming
33 [TestClass]
34 public class TJSONProtocolTests
35 {
36 [TestMethod]
37 public void TJSONProtocol_Can_Create_Instance_Test()
38 {
39 var httpClientTransport = Substitute.For<THttpTransport>(new Uri("http://localhost"), null, null);
40
41 var result = new TJSONProtocolWrapper(httpClientTransport);
42
43 Assert.IsNotNull(result);
44 Assert.IsNotNull(result.WrappedContext);
45 Assert.IsNotNull(result.WrappedReader);
46 Assert.IsNotNull(result.Transport);
47 Assert.IsTrue(result.WrappedRecursionDepth == 0);
48 Assert.IsTrue(result.WrappedRecursionLimit == TProtocol.DefaultRecursionDepth);
49
50 Assert.IsTrue(result.Transport.Equals(httpClientTransport));
51 Assert.IsTrue(result.WrappedContext.GetType().Name.Equals("JSONBaseContext", StringComparison.OrdinalIgnoreCase));
52 Assert.IsTrue(result.WrappedReader.GetType().Name.Equals("LookaheadReader", StringComparison.OrdinalIgnoreCase));
53 }
54
55 private class TJSONProtocolWrapper : TJsonProtocol
56 {
57 public TJSONProtocolWrapper(TTransport trans) : base(trans)
58 {
59 }
60
61 public object WrappedContext => Context;
62 public object WrappedReader => Reader;
63 public int WrappedRecursionDepth => RecursionDepth;
64 public int WrappedRecursionLimit => RecursionLimit;
65 }
66 }
67}