RhinoMock - AssertWasCalled on same method with different parameter doesn't work

RhinoMock - AssertWasCalled on same method with different parameter doesn't work

I have this method:

I have this method:

        public void Handle(ShipmentConfirmedEvent message)
    {
        try
        {
            var trackingOrderDto = new ShipmentConfirmedDto
            {
                AccountId = message.AccountId,
                FirstName = message.CustomerFirstName,
                TransactionId = message.TransactionId,
                Language = message.LanguageCode,
                ExcludedCommunicationChannels = message.ExcludedCommunicationChannels,
                TrackingId = message.TrackingNumber
            };

        Log.Info("Received notify of Shipment Confirmed request with id <{0}> for order {1}", message.GenerationId, message.TransactionId);
        if (!string.IsNullOrEmpty(_iosForcePushAccountId))
        {
            Log.Info("Per device Ios, l'accountId {0} verrà forzato a {1} per configurazione", trackingOrderDto.AccountId, _iosForcePushAccountId);
            trackingOrderDto.AccountId = Convert.ToInt64(_iosForcePushAccountId);
        }
        Log.Debug("Send push notification for IOS for AccountId <{0}>", trackingOrderDto.AccountId);
        var iosContent = _sender.Create(trackingOrderDto, "IOS");
        _sender.IosSend(iosContent);

        trackingOrderDto.AccountId = message.AccountId;

        if (!string.IsNullOrEmpty(_androidForcePushAccountId))
        {
            Log.Info("Per device Android, l'accountId {0} verrà forzato a {1} per configurazione", trackingOrderDto.AccountId, _androidForcePushAccountId);
            trackingOrderDto.AccountId = Convert.ToInt64(_androidForcePushAccountId);
        }
        Log.Debug("Send push notification for Android for AccountId <{0}>", trackingOrderDto.AccountId);
        var androidContent = _sender.Create(trackingOrderDto, "ANDROID");
        _sender.AndroidSend(androidContent);
    }
    catch (ExcludedCommunicationChannelsException ex)
    {
        Log.Warn(ex.Message);
    }
    catch (Exception ex)
    {
        var msg = String.Format("Errore durante la gestione del messaggio relativo al PushNotification for username {0}", message.MailTo.First().Address);
        Log.Error(ex, msg);
        throw new Exception(ex.Message, ex);
    }
    Log.Info("<{0}> Processed", message.GenerationId);
}

and I have this test:

[Fact]
    public void GivenAnOrderConfirmedEventWithForcedAccountId_WhenHandle_ThenCallSenderWithTheForcedAccountId()
    {
        NServiceBus.Testing.Test.Initialize();

    var service = new ShipmentConfirmedRequestEventConsumer(mockSender, "1111", "2222");

    NServiceBus.Testing.Test.Handler(svc => service)
        .OnMessage<ShipmentConfirmedEvent>(
            m =>
            {
                m.AccountId = 407716;
                m.CustomerFirstName = "Marco";
                m.TransactionId = "T123456";
                m.LanguageCode = "IT";
                m.TrackingNumber = "642167921";
            }
        );
    mockSender.AssertWasCalled(x => x.Create(Arg<ShipmentConfirmedDto>.Matches(dto => dto.AccountId == 2222), Arg<string>.Is.Equal("ANDROID")));
    mockSender.AssertWasCalled(x => x.Create(Arg<ShipmentConfirmedDto>.Matches(dto => dto.AccountId == 1111), Arg<string>.Is.Equal("IOS")));
}

the second AssertWasCalled, the one related to IOS, throw exception because it seems to be overwritten, being within the method the first to be called.

I need to verify that the Create method is called twice within the method, with the parameters specified.

How can I modify the test in order to verify it?

c-sharp testing unity

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

C. C++. C#. 차이점 알려드림. 5분 순삭. Explain C.C++.C#. Like I'm Five

C. C++. C#. 차이점 알려드림. 5분 순삭. Explain C.C++.C#. Like I'm Five. 아시죠? C는 C++.C# 줄인말이 아니라는거?

Learn how to perform CRUD operations using C Sharp

QuickStart: CRUD Operations in C Sharp. Learn how to perform CRUD operations using C Sharp for MongoDB databases.

Testing Microservices Applications

The shift towards microservices and modular applications makes testing more important and more challenging at the same time. Learn more here.

Loops in C++ | For, While, and Do While Loops in C++

In this Video We are going to see how to use Loops in C++. We will see How to use For, While, and Do While Loops in C++.

Using isdigit() in C/C++

In this article, we'll take a look at using the isdigit() function in C/C++. This is a very simple way to check if any value is a digit or not. Let's look