From 77dfd1fe760e7e2f0952227b0dcbc7369e8c9d17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A7=E7=9F=B3=E5=A4=B4?= Date: Sat, 12 Oct 2024 23:14:29 +0800 Subject: [PATCH] fix Test --- XUnitTest/JsonEncoderTests.cs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/XUnitTest/JsonEncoderTests.cs b/XUnitTest/JsonEncoderTests.cs index 2b20cb0..6ddeae5 100644 --- a/XUnitTest/JsonEncoderTests.cs +++ b/XUnitTest/JsonEncoderTests.cs @@ -146,7 +146,7 @@ public void CreateRequest() // 简洁请求 { var req = encoder.CreateRequest(name, null); - var pk = (ArrayPacket)req.Payload; + var pk = (OwnerPacket)req.Payload; Assert.Equal(1 + name.Length, pk.Total); Assert.Null(pk.Next); Assert.Equal(8, pk.Offset); @@ -178,14 +178,14 @@ public void CreateRequestWithEmptyArgs() { var args = new Object(); var req = encoder.CreateRequest(name, args); - var pk = (ArrayPacket)req.Payload; + var pk = (OwnerPacket)req.Payload; Assert.Equal(1 + name.Length + 4 + args.ToJson().Length, pk.Total); Assert.NotNull(pk.Next); Assert.Equal(8, pk.Offset); // 拷贝一次,拉平。因为SpanReader不支持跨包读取 - pk = (ArrayPacket)req.Payload.ToArray(); - var reader = new SpanReader(pk.GetSpan()); + var pk2 = (ArrayPacket)req.Payload.ToArray(); + var reader = new SpanReader(pk2.GetSpan()); Assert.Equal(name, reader.ReadString()); @@ -219,7 +219,7 @@ public void CreateRequestFull() { var args = new UserInfo { Name = "Stone", Age = 18 }; var req = encoder.CreateRequest(name, args); - var pk = (ArrayPacket)req.Payload; + var pk = (OwnerPacket)req.Payload; Assert.Equal(1 + name.Length + 4 + args.ToJson().Length, pk.Total); Assert.NotNull(pk.Next); Assert.Equal(8, pk.Offset); @@ -258,7 +258,7 @@ public void CreateResponse() { // 错误码200等同于0,表示成功 var res = encoder.CreateResponse(req, name, 200, null); - var pk = (ArrayPacket)res.Payload; + var pk = (OwnerPacket)res.Payload; Assert.Equal(1 + name.Length, pk.Total); Assert.Null(pk.Next); Assert.Equal(8, pk.Offset); @@ -296,14 +296,14 @@ public void CreateResponseWithError() { var value = "this is an error message"; var res = encoder.CreateResponse(req, name, 500, value); - var pk = (ArrayPacket)res.Payload; + var pk = (OwnerPacket)res.Payload; Assert.Equal(1 + name.Length + 4 + 4 + value.Length, pk.Total); Assert.NotNull(pk.Next); Assert.Equal(8, pk.Offset); // 拷贝一次,拉平。因为SpanReader不支持跨包读取 - pk = (ArrayPacket)pk.ToArray(); - var reader = new SpanReader(pk.GetSpan()); + var pk2 = (ArrayPacket)pk.ToArray(); + var reader = new SpanReader(pk2.GetSpan()); Assert.Equal(name, reader.ReadString()); Assert.Equal(500, reader.ReadInt32()); @@ -340,14 +340,14 @@ public void CreateResponseFull() { var value = new UserInfo { Name = "Stone", Age = 18 }; var res = encoder.CreateResponse(req, name, 0, value); - var pk = (ArrayPacket)res.Payload; + var pk = (OwnerPacket)res.Payload; Assert.Equal(1 + name.Length + 4 + value.ToJson().Length, pk.Total); Assert.NotNull(pk.Next); Assert.Equal(8, pk.Offset); // 拷贝一次,拉平。因为SpanReader不支持跨包读取 - pk = (ArrayPacket)pk.ToArray(); - var reader = new SpanReader(pk.GetSpan()); + var pk2 = (ArrayPacket)pk.ToArray(); + var reader = new SpanReader(pk2.GetSpan()); Assert.Equal(name, reader.ReadString());