public async Task CallsCancelScheduledMessageAsync() { var(sender, clientMock) = await ComposeServiceBusAndGetSender(); await sender.CancelScheduledMessageAsync(16548); clientMock.Mock.Verify(o => o.CancelScheduledMessageAsync(16548), Times.Once); }
internal async Task CancelScheduledMessagesAsyncTestCase(IMessageSender messageSender, IMessageReceiver messageReceiver, int messageCount) { var scheduleTime = new DateTimeOffset(DateTime.UtcNow).AddSeconds(30); var brokeredMessage = new Message(Encoding.UTF8.GetBytes("Test1")) { MessageId = Guid.NewGuid().ToString() }; TestUtility.Log( $"Sending message with schedule time: {scheduleTime.UtcDateTime} and messageID {brokeredMessage.MessageId}"); var sequenceNumber = await messageSender.ScheduleMessageAsync(brokeredMessage, scheduleTime); TestUtility.Log($"Received sequence number: {sequenceNumber}"); Assert.True(sequenceNumber > 0); TestUtility.Log("Cancelling scheduled message"); await messageSender.CancelScheduledMessageAsync(sequenceNumber); TestUtility.Log("Sleeping for 30 seconds..."); await Task.Delay(TimeSpan.FromSeconds(30)); // Sending a dummy message so that ReceiveAsync(2) returns immediately after getting 1 message // instead of waiting for connection timeout on a single message. await messageSender.SendAsync(new Message(Encoding.UTF8.GetBytes(("Dummy"))) { MessageId = "Dummy" }); IList <Message> messages = null; var retryCount = 5; while (messages == null && --retryCount > 0) { messages = await messageReceiver.ReceiveAsync(2); } Assert.NotNull(messages); Assert.True(messages.Count == 1); Assert.True(messages.First().MessageId == "Dummy"); }
public Task CancelScheduledSend(long sequenceNumber) { return(_client.CancelScheduledMessageAsync(sequenceNumber)); }