Skip to content

Commit

Permalink
Ensure link to non-existing subscription throws MessagingEntityNotFou…
Browse files Browse the repository at this point in the history
…ndException (#7942)

Ensure opening link to non-existing subscription throws MessagingEntityNotFoundException

Fixes #6943
  • Loading branch information
nemakam committed Oct 12, 2019
1 parent 30152c8 commit 8698cf6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public async Task<Tuple<AmqpObject, DateTime>> CreateAndOpenAmqpLinkAsync()
exception);

session.SafeClose(exception);
throw AmqpExceptionHelper.GetClientException(exception, null, link?.GetInnerException(), session.IsClosing());
throw AmqpExceptionHelper.GetClientException(exception, null, link?.GetInnerException(), amqpConnection.IsClosing());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,5 +194,19 @@ await ServiceBusScope.UsingQueueAsync(partitioned: false, sessionEnabled: true,
}
});
}

[Fact]
[LiveTest]
public async Task CreatingLinkToNonExistingEntityShouldThrowEntityNotFoundException()
{
var receiver = new MessageReceiver(TestUtility.NamespaceConnectionString, "nonExistingEntity"); // Covers queue and topic
await Assert.ThrowsAsync<MessagingEntityNotFoundException>(async () => await receiver.ReceiveAsync());

await ServiceBusScope.UsingTopicAsync(partitioned: false, sessionEnabled: false, async (topicName, subscriptionName) =>
{
receiver = new MessageReceiver(TestUtility.NamespaceConnectionString, EntityNameHelper.FormatSubscriptionPath(topicName, "nonexistingsub"));
await Assert.ThrowsAsync<MessagingEntityNotFoundException>(async () => await receiver.ReceiveAsync());
});
}
}
}

0 comments on commit 8698cf6

Please sign in to comment.