public async Task Send()
        {
            var msg = new BrokeredMessage();
            var m = NamespaceManager.CreateFromConnectionString(connection);
            var client = Substitute.For<IBusQueueClient>();
            client.Send(msg);

            var q = new BusQueueSender(Guid.NewGuid().ToString(), m, client);
            await q.Send(msg);

            client.Received().Send(msg);
        }
 public async Task SendForBufferAt()
 {
     var queue = new BusQueueSender(Guid.NewGuid().ToString(), connection);
     await queue.Send((BufferedMessage)null);
 }
 public async Task SaveBrokeredMessageNull()
 {
     var queue = new BusQueueSender(Guid.NewGuid().ToString(), connection);
     await queue.Send((BrokeredMessage)null);
 }
 public async Task SendAt()
 {
     var queue = new BusQueueSender(Guid.NewGuid().ToString(), connection);
     await queue.Send(null, DateTime.UtcNow);
 }
        public async Task SendBatchThrowsMessagingException()
        {
            var msgs = new List<BrokeredMessage>();
            msgs.Add(new BrokeredMessage());
            var m = NamespaceManager.CreateFromConnectionString(connection);
            var first = true;
            var client = Substitute.For<IBusQueueClient>();
            client.When(c => c.Send(msgs)).Do(x =>
            {
                var tmp = first;
                first = false;
                throw new MessagingException(Guid.NewGuid().ToString(), tmp, new Exception());
            });

            var q = new BusQueueSender(Guid.NewGuid().ToString(), m, client);
            await q.Send(msgs);
        }
 public async Task SaveObjectNull()
 {
     var queue = new BusQueueSender(Guid.NewGuid().ToString(), connection);
     await queue.Send((object)null);
 }
        public async Task SendObjBatchThrows()
        {
            var msg = new List<object>();
            msg.Add(new object());
            var m = NamespaceManager.CreateFromConnectionString(connection);
            var client = Substitute.For<IBusQueueClient>();
            client.When(c => c.Send(Arg.Any<IEnumerable<BrokeredMessage>>())).Do(x => { throw new Exception(); });

            var q = new BusQueueSender(Guid.NewGuid().ToString(), m, client);
            await q.Send(msg);
        }
        public async Task SendThrows()
        {
            var msg = new BrokeredMessage();
            var m = NamespaceManager.CreateFromConnectionString(connection);
            var client = Substitute.For<IBusQueueClient>();
            client.When(c => c.Send(msg)).Do(x => { throw new Exception(); });

            var q = new BusQueueSender(Guid.NewGuid().ToString(), m, client);
            await q.Send(msg);
        }
        public async Task SendForBuffer()
        {
            var m = NamespaceManager.CreateFromConnectionString(connection);
            var client = Substitute.For<IBusQueueClient>();
            client.Send(Arg.Any<BrokeredMessage>());

            var q = new BusQueueSender(Guid.NewGuid().ToString(), m, client);
            await q.Send(new BufferedMessage() { ReleaseAt = DateTime.UtcNow });

            client.Received().Send(Arg.Any<BrokeredMessage>());
        }
        public async Task SendObjNullBatch()
        {
            var m = NamespaceManager.CreateFromConnectionString(connection);
            var client = Substitute.For<IBusQueueClient>();

            var q = new BusQueueSender(Guid.NewGuid().ToString(), m, client);
            await q.Send((IEnumerable<object>)null);
        }
        public async Task SendObjBatch()
        {
            var msg = new List<BrokeredMessage>();
            msg.Add(new BrokeredMessage());
            var m = NamespaceManager.CreateFromConnectionString(connection);
            var client = Substitute.For<IBusQueueClient>();
            client.Send(Arg.Any<IEnumerable<BrokeredMessage>>());

            var q = new BusQueueSender(Guid.NewGuid().ToString(), m, client);
            await q.Send((IEnumerable<object>)msg);

            client.Received().Send(Arg.Any<IEnumerable<BrokeredMessage>>());
        }