public TaskTarsConvertTest() { var test = new TestTarsConvert(); sut = test.ConvertRoot; headHandler = test.HeadHandler; }
public ByteBufferTarsConvertTest() { var test = new TestTarsConvert(); sut = test.ConvertRoot; headHandler = test.HeadHandler; }
public DictionaryTarsConvertTest() { var test = new TestTarsConvert(); sut = test.ConvertRoot; headHandler = test.HeadHandler; }
public ByteTarsConvertTest() { var test = new TestTarsConvert(); sut = test.ConvertRoot; convert = test.Provider.GetRequiredService <ITarsConvert <byte> >(); headHandler = test.HeadHandler; }
public void ShouldEqualExpect(short version, Codec codec) { Unpooled.Buffer(1); var request = new Request() { Version = version, Codec = codec, PacketType = 3, MessageType = 4, RequestId = 66, Timeout = 77, ServantName = "aa.aa", FuncName = "go", Context = new Dictionary <string, string>() { { "a", "b" } }, Status = new Dictionary <string, string>() { { "a1", "b2" } }, Parameters = new object[2] { version, codec } }; var method = GetType().GetMethod("ShouldEqualExpect"); request.ParameterTypes = method.GetParameters(); var test = new TestTarsConvert(); var decoder = new TarsDecoder(test.ConvertRoot); var encoder = new TarsEncoder(test.ConvertRoot); test.FindRpcMethodFunc = (servantName, funcName) => { return(method, true, new ParameterInfo[0], codec, version, method.DeclaringType); }; var buffer = encoder.EncodeRequest(request); var result = decoder.DecodeRequest(buffer); Assert.Equal(request.Version, result.Version); Assert.Equal(request.PacketType, result.PacketType); Assert.Equal(request.MessageType, result.MessageType); Assert.Equal(request.RequestId, result.RequestId); Assert.Equal(request.Timeout, result.Timeout); Assert.Equal(request.ServantName, result.ServantName); Assert.Equal(request.FuncName, result.FuncName); Assert.Equal(request.Context["a"], result.Context["a"]); Assert.Single(request.Context); Assert.Equal(request.Status["a1"], result.Status["a1"]); Assert.Single(request.Status); Assert.Equal(request.Parameters[0], result.Parameters[0]); Assert.Equal(request.Parameters[1], result.Parameters[1]); Assert.Equal(request.Parameters.Length, result.Parameters.Length); }
public void UniAttributeArgumentExceptionTest(Codec codec, int tag) { var test = new TestTarsConvert(); var sut = new UniAttributeV2(test.ConvertRoot, test.HeadHandler) { Temp = new Dictionary <string, IDictionary <string, IByteBuffer> >(3) }; var options = new TarsConvertOptions() { Codec = codec, Version = TarsCodecsVersion.V2, Tag = tag, }; var ex = Assert.Throws <ArgumentException>(() => sut.Put(null, 1, typeof(int), options)); Assert.Equal("put key can not be null", ex.Message); }
public void UniAttributeTest(Codec codec, int tag) { var test = new TestTarsConvert(); var sut = new UniAttributeV2(test.ConvertRoot, test.HeadHandler) { Temp = new Dictionary <string, IDictionary <string, IByteBuffer> >(3) }; var options = new TarsConvertOptions() { Codec = codec, Version = TarsCodecsVersion.V2, Tag = tag, }; sut.Put(string.Empty, 1, typeof(int), options); sut.Put("23", "66", typeof(string), options); sut.Put("23", "23", typeof(string), options); sut.Put("dd", 0d, typeof(double), options); sut.Put("ddd", 0d, typeof(double), options); sut.Put("ddd", null, typeof(double), options); var buf = Unpooled.Buffer(128); sut.Serialize(buf, options); sut.Temp = null; headHandler.ReadHead(buf, options); sut.Deserialize(buf, options); Assert.Equal(3, sut.Temp.Count); var buffer = sut.Temp[string.Empty][string.Empty]; test.HeadHandler.ReadHead(buffer, options); Assert.Equal(1, test.ConvertRoot.Deserialize <int>(buffer, options)); buffer = sut.Temp["23"][string.Empty]; test.HeadHandler.ReadHead(buffer, options); Assert.Equal("23", test.ConvertRoot.Deserialize <string>(buffer, options)); buffer = sut.Temp["dd"][string.Empty]; test.HeadHandler.ReadHead(buffer, options); Assert.Equal(0d, test.ConvertRoot.Deserialize <double>(buffer, options)); }
public TestRpcMetadata(TestTarsConvert tarsConvert) { this.tarsConvert = tarsConvert; }
public TarsHeadHandlerTest() { var test = new TestTarsConvert(); sut = test.HeadHandler; }
public TestClientCallBack(TestTarsConvert testTarsConvert) { this.testTarsConvert = testTarsConvert; }
public async Task ResponseWhenReturnTaskShouldEqualExpect(short version, Codec codec) { Unpooled.Buffer(1); var resp = new Response() { Version = version, Codec = codec, PacketType = 3, MessageType = 4, RequestId = 66, Timeout = 77, ServantName = "aa.aa", FuncName = "go", Context = new Dictionary <string, string>() { { "a", "b" } }, Status = new Dictionary <string, string>() { { "a1", "b2" } }, ReturnParameters = new object[2] { version, codec }, ReturnValue = Task.CompletedTask, ResultStatusCode = RpcStatusCode.ServerSuccess, ResultDesc = "test" }; var method = GetType().GetMethod("ResponseWhenReturnTaskShouldEqualExpect"); resp.ReturnParameterTypes = method.GetParameters(); resp.ReturnValueType = method.ReturnParameter; var test = new TestTarsConvert(); var decoder = new TarsDecoder(test.ConvertRoot); var encoder = new TarsEncoder(test.ConvertRoot); test.FindRpcMethodByIdFunc = i => ("aa.aa", "go"); test.FindRpcMethodFunc = (servantName, funcName) => { return(method, true, method.GetParameters(), codec, version, method.DeclaringType); }; var buffer = encoder.EncodeResponse(resp); var result = decoder.DecodeResponse(buffer); Assert.Equal(resp.Version, result.Version); Assert.Equal(resp.PacketType, result.PacketType); Assert.Equal(resp.MessageType, result.MessageType); Assert.Equal(resp.RequestId, result.RequestId); if (version != 1) { Assert.Equal(resp.ServantName, result.ServantName); Assert.Equal(resp.FuncName, result.FuncName); } Assert.Equal(resp.Context["a"], result.Context["a"]); Assert.Single(resp.Context); Assert.Equal(resp.Status["a1"], result.Status["a1"]); Assert.Single(resp.Status); Assert.Equal(resp.ReturnParameters[0], result.ReturnParameters[0]); Assert.Equal(resp.ReturnParameters[1], result.ReturnParameters[1]); Assert.Equal(resp.ReturnValue, result.ReturnValue); Assert.Equal(resp.ResultStatusCode, result.ResultStatusCode); await(Task) result.ReturnValue; }
public UniAttributeV2Test() { var test = new TestTarsConvert(); headHandler = test.HeadHandler; }