source/TestCommon/source/FunctionApp.TestCommon/ServiceBus/ListenerMock/AssertionExtensions.cs
/// <summary>
/// Assert we have received expected message a number of times.
/// </summary>
Assert we have received expected message a number of times.
Assert we have received expected message a number of times .
public static void AssertReceived(this ServiceBusListenerMock mock, int expectedCount, Func<ServiceBusReceivedMessage, bool> matcher)
        {
            var count = mock.ReceivedMessages.Count(matcher);
            if (count != expectedCount)
            {
                var nonMatchingCount = mock.ReceivedMessages.Count(ctx => !matcher(ctx));
                throw new AssertionException($"Expected to receive {expectedCount} matching messages. Actually received {count} matching messages and {nonMatchingCount} non matching messages.");
            }
        }
public static void AssertReceived ( this ServiceBusListenerMock mock , int expectedCount , Func < ServiceBusReceivedMessage , bool > matcher ) { var count = mock . ReceivedMessages . Count ( matcher ) ; if ( count != expectedCount ) { var nonMatchingCount = mock . ReceivedMessages . Count ( ctx => ! matcher ( ctx ) ) ; throw new AssertionException ( $" Expected to receive  { expectedCount }  matching messages. Actually received  { count }  matching messages and  { nonMatchingCount }  non matching messages. " ) ; } }
Assert we have received expected message a number of times.
Assert we have received expected message a number of times .
ServiceBusListenerMock
this
expectedCount
int
matcher
Func<ServiceBusReceivedMessage, bool>