Skip to content

Commit d8a6e62

Browse files
committed
fixup tests
1 parent 5357ded commit d8a6e62

File tree

2 files changed

+12
-22
lines changed

2 files changed

+12
-22
lines changed

projects/Unit/APIApproval.Approve.verified.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo(@"Benchmarks, PublicKey=00240000048000009400000006020000002400005253413100040000010001008d20ec856aeeb8c3153a77faa2d80e6e43b5db93224a20cc7ae384f65f142e89730e2ff0fcc5d578bbe96fa98a7196c77329efdee4579b3814c0789e5a39b51df6edd75b602a33ceabdfcf19a3feb832f31d8254168cd7ba5700dfbca301fbf8db614ba41ba18474de0a5f4c2d51c995bc3636c641c8cbe76f45717bfcb943b5")]
12
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo(@"Unit, PublicKey=00240000048000009400000006020000002400005253413100040000010001008d20ec856aeeb8c3153a77faa2d80e6e43b5db93224a20cc7ae384f65f142e89730e2ff0fcc5d578bbe96fa98a7196c77329efdee4579b3814c0789e5a39b51df6edd75b602a33ceabdfcf19a3feb832f31d8254168cd7ba5700dfbca301fbf8db614ba41ba18474de0a5f4c2d51c995bc3636c641c8cbe76f45717bfcb943b5")]
23
namespace RabbitMQ.Client
34
{

projects/Unit/TestMethodArgumentCodec.cs

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,8 @@
4141
namespace RabbitMQ.Client.Unit
4242
{
4343
[TestFixture]
44-
class TestMethodArgumentCodec
44+
public class TestMethodArgumentCodec
4545
{
46-
public static MethodArgumentWriter Writer()
47-
{
48-
return new MethodArgumentWriter(new byte[1024]);
49-
}
50-
51-
public static MethodArgumentReader Reader(byte[] bytes)
52-
{
53-
return new MethodArgumentReader(bytes);
54-
}
55-
5646
public void Check(byte[] actual, byte[] expected)
5747
{
5848
try
@@ -81,22 +71,22 @@ public void TestTableLengthWrite()
8171

8272
int bytesNeeded = WireFormatting.GetTableByteCount(t);
8373
byte[] memory = new byte[bytesNeeded];
84-
var writer = new MethodArgumentWriter(memory);
85-
writer.WriteTable(t);
86-
Assert.AreEqual(bytesNeeded, writer.Offset);
74+
int offset = WireFormatting.WriteTable(memory.AsSpan(), t);
75+
Assert.AreEqual(bytesNeeded, offset);
8776
Check(memory, new byte[] { 0x00, 0x00, 0x00, 0x0C,
8877
0x03, 0x61, 0x62, 0x63,
8978
0x53, 0x00, 0x00, 0x00,
9079
0x03, 0x64, 0x65, 0x66 });
9180
}
9281

9382
[Test]
94-
public void TestTableLengthRead()
83+
public void TestDictionaryLengthRead()
9584
{
96-
IDictionary t = (IDictionary)Reader(new byte[] { 0x00, 0x00, 0x00, 0x0C,
97-
0x03, 0x61, 0x62, 0x63,
98-
0x53, 0x00, 0x00, 0x00,
99-
0x03, 0x64, 0x65, 0x66 }).ReadTable();
85+
WireFormatting.ReadDictionary(new byte[] {
86+
0x00, 0x00, 0x00, 0x0C,
87+
0x03, 0x61, 0x62, 0x63,
88+
0x53, 0x00, 0x00, 0x00,
89+
0x03, 0x64, 0x65, 0x66 }, out var t);
10090
Assert.AreEqual(Encoding.UTF8.GetBytes("def"), t["abc"]);
10191
Assert.AreEqual(1, t.Count);
10292
}
@@ -112,9 +102,8 @@ public void TestNestedTableWrite()
112102
t["x"] = x;
113103
int bytesNeeded = WireFormatting.GetTableByteCount(t);
114104
byte[] memory = new byte[bytesNeeded];
115-
var writer = new MethodArgumentWriter(memory);
116-
writer.WriteTable(t);
117-
Assert.AreEqual(bytesNeeded, writer.Offset);
105+
int offset = WireFormatting.WriteTable(memory.AsSpan(), t);
106+
Assert.AreEqual(bytesNeeded, offset);
118107
Check(memory, new byte[] { 0x00, 0x00, 0x00, 0x0E,
119108
0x01, 0x78, 0x46, 0x00,
120109
0x00, 0x00, 0x07, 0x01,

0 commit comments

Comments
 (0)