Skip to content

Commit 5670ee5

Browse files
authored
Improved error message when AssertEmpty fails on a message queue (#84)
Include the type of the first message in the non-empty queue in the error message.
1 parent e102852 commit 5670ee5

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/ReactiveDomain.Testing/Messaging/ConcurrentMessageQueue.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,11 @@ public ConcurrentMessageQueue<T> AssertNext<TMsg>(
5656
}
5757
public void AssertEmpty()
5858
{
59-
if (!IsEmpty)
60-
throw new Exception($" {_name} Queue not Empty.");
59+
if (IsEmpty) return;
60+
var errMsg = $"{_name} Queue is not Empty.";
61+
if (TryPeek(out var msg))
62+
errMsg += $" Instead {msg.GetType()} is next.";
63+
throw new Exception(errMsg);
6164
}
6265

6366
// JUST INHERITING EVERYTHING

0 commit comments

Comments
 (0)