Skip to content
This repository was archived by the owner on Oct 12, 2023. It is now read-only.

Commit 5a7adf9

Browse files
committed
Verify custom properties affect Batch size (serialized bytes)
1 parent 9e26a55 commit 5a7adf9

File tree

2 files changed

+24
-1
lines changed
  • src/Microsoft.Azure.ServiceBus/Core
  • test/Microsoft.Azure.ServiceBus.UnitTests/Primitives

2 files changed

+24
-1
lines changed

src/Microsoft.Azure.ServiceBus/Core/Batch.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public bool TryAdd(Message message)
6868
/// </summary>
6969
public int Length => datas.Count;
7070

71-
private long Size => result.SerializedMessageSize;
71+
internal long Size => result.SerializedMessageSize;
7272

7373

7474
/// <summary>

test/Microsoft.Azure.ServiceBus.UnitTests/Primitives/BatchTests.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,28 @@ public void Should_report_how_many_messages_are_in_batch(int numberOfMessages)
5757
Assert.Equal(numberOfMessages, batch.Length);
5858
}
5959
}
60+
61+
[Fact]
62+
public void Should_show_reflect_property_in_batch_size()
63+
{
64+
using (var batch = new Batch(100))
65+
{
66+
var message = new Message();
67+
68+
batch.TryAdd(message);
69+
70+
Assert.Equal(24, batch.Size);
71+
}
72+
73+
using (var batch = new Batch(100))
74+
{
75+
var message = new Message();
76+
message.UserProperties["custom"] = "value";
77+
78+
batch.TryAdd(message);
79+
80+
Assert.Equal(45, batch.Size);
81+
}
82+
}
6083
}
6184
}

0 commit comments

Comments
 (0)