Example #1
0
        public async Task ClientThrowsUnauthorizedExceptionWhenUserDoesntHaveAccess()
        {
            await ServiceBusScope.UsingQueueAsync(partitioned : false, sessionEnabled : false, async queueName =>
            {
                var csb        = new ServiceBusConnectionStringBuilder(TestUtility.NamespaceConnectionString);
                csb.SasKeyName = "nonExistingKey";
                csb.EntityPath = queueName;

                var sender = new MessageSender(csb);

                try
                {
                    await Assert.ThrowsAsync <UnauthorizedException>(
                        async() => await sender.SendAsync(new Message()));

                    long nonExistingSequenceNumber = 1000;
                    await Assert.ThrowsAsync <UnauthorizedException>(
                        async() => await sender.CancelScheduledMessageAsync(nonExistingSequenceNumber));
                }
                finally
                {
                    await sender.CloseAsync();
                }
            });
        }
        public async Task CancelScheduledMessageShouldThrowMessageNotFoundException()
        {
            var sender = new MessageSender(TestUtility.NamespaceConnectionString, TestConstants.NonPartitionedQueueName);

            try
            {
                long nonExistingSequenceNumber = 1000;
                await Assert.ThrowsAsync <MessageNotFoundException>(
                    async() => await sender.CancelScheduledMessageAsync(nonExistingSequenceNumber));
            }
            finally
            {
                await sender.CloseAsync().ConfigureAwait(false);
            }
        }
Example #3
0
        public async Task CancelScheduledMessageShouldThrowMessageNotFoundException()
        {
            await ServiceBusScope.UsingQueueAsync(partitioned : false, sessionEnabled : false, async queueName =>
            {
                var sender = new MessageSender(TestUtility.NamespaceConnectionString, queueName);

                try
                {
                    long nonExistingSequenceNumber = 1000;
                    await Assert.ThrowsAsync <MessageNotFoundException>(
                        async() => await sender.CancelScheduledMessageAsync(nonExistingSequenceNumber));
                }
                finally
                {
                    await sender.CloseAsync();
                }
            });
        }
        public async Task ClientThrowsUnauthorizedExceptionWhenUserDoesntHaveAccess()
        {
            var csb = new ServiceBusConnectionStringBuilder(TestUtility.NamespaceConnectionString);

            csb.SasKeyName = "nonExistingKey";
            csb.EntityPath = TestConstants.NonPartitionedQueueName;

            var sender = new MessageSender(csb);

            try
            {
                await Assert.ThrowsAsync <UnauthorizedException>(
                    async() => await sender.SendAsync(new Message()));

                long nonExistingSequenceNumber = 1000;
                await Assert.ThrowsAsync <UnauthorizedException>(
                    async() => await sender.CancelScheduledMessageAsync(nonExistingSequenceNumber));
            }
            finally
            {
                await sender.CloseAsync().ConfigureAwait(false);
            }
        }