Exemplo n.º 1
0
        public void SaveNull()
        {
            var name = Guid.NewGuid().ToString();
            var t    = new StorageQueue(name, ConnectionString);

            Assert.That(() => t.Send((object)null), Throws.TypeOf <ArgumentNullException>());
        }
Exemplo n.º 2
0
        static int Main(string[] args)
        {
            if (args.Length == 0)
            {
                return(-1);
            }

            string storageUrl = args[0];

            var queue = new StorageQueue(storageUrl);

            while (true)
            {
                string message = Console.ReadLine();

                if (message == null)
                {
                    break;
                }

                queue.Send(message);
            }

            return(0);
        }
Exemplo n.º 3
0
        public async Task RoundTripMsgAsObj()
        {
            var storage = new StorageQueue(QueueName, ConnectionString);

            var msg = new CloudQueueMessage(Guid.NewGuid().ToByteArray());
            await storage.Send((object)msg);

            var returned = await storage.Get();

            Assert.AreEqual(msg.AsBytes, returned.AsBytes);
        }
Exemplo n.º 4
0
        public async Task Delete()
        {
            var storage = new StorageQueue(QueueName, ConnectionString);

            var msg = new CloudQueueMessage(Guid.NewGuid().ToByteArray());
            await storage.Send(msg);

            var returned = await storage.Get();

            await storage.Delete(returned);
        }
Exemplo n.º 5
0
        public async Task RoundTripObject()
        {
            var storage  = new StorageQueue(QueueName, ConnectionString);
            var expected = Guid.NewGuid();
            await storage.Send(expected);

            var returned = await storage.Get();

            var guid = JsonConvert.DeserializeObject <Guid>(returned.AsString);

            Assert.AreEqual(expected, guid);
        }
Exemplo n.º 6
0
        public async Task RoundTripMsgAsObj()
        {
            StorageQueue storage = await QueueSetup();

            var msg = new CloudQueueMessage(Guid.NewGuid().ToByteArray());
            await storage.Send((object)msg);

            var returned = await storage.Get();

            Assert.AreEqual(msg.AsBytes, returned.AsBytes);
            await storage.Delete();
        }
Exemplo n.º 7
0
        public async Task Delete()
        {
            StorageQueue storage = await QueueSetup();

            var msg = new CloudQueueMessage(Guid.NewGuid().ToByteArray());
            await storage.Send(msg);

            var returned = await storage.Get();

            await storage.Delete(returned);

            await storage.Delete();
        }
Exemplo n.º 8
0
        public async Task RoundTripObject()
        {
            StorageQueue storage = await QueueSetup();

            var expected = Guid.NewGuid();
            await storage.Send(expected);

            var returned = await storage.Get();

            var guid = JsonConvert.DeserializeObject <Guid>(returned.AsString);

            Assert.AreEqual(expected, guid);
            await storage.Delete();
        }
Exemplo n.º 9
0
        public async Task ApproixmateMessageCount()
        {
            var random  = new Random();
            var count   = random.Next(1, 1000);
            var storage = new StorageQueue(QueueName, ConnectionString);

            for (var i = 0; i < count; i++)
            {
                await storage.Send(Guid.NewGuid());
            }

            var result = await storage.ApproixmateMessageCount();

            Assert.AreEqual(count, result);
        }
Exemplo n.º 10
0
        public async Task Peek()
        {
            StorageQueue storage = await QueueSetup();

            var msg = new CloudQueueMessage(Guid.NewGuid().ToByteArray());
            await storage.Send(msg);

            var peeked = await storage.PeekAsync();

            Assert.AreEqual(msg.AsBytes, peeked.First().AsBytes);

            var returned = await storage.Get();

            Assert.AreEqual(msg.AsBytes, returned.AsBytes);
            await storage.Delete();
        }
Exemplo n.º 11
0
        public async Task ApproixmateMessageCount()
        {
            var          random  = new Random();
            var          count   = random.Next(1, 1000);
            StorageQueue storage = await QueueSetup();

            for (var i = 0; i < count; i++)
            {
                await storage.Send(Guid.NewGuid());
            }

            var result = await storage.ApproixmateMessageCount();

            Assert.AreEqual(count, result);
            await storage.Delete();
        }
Exemplo n.º 12
0
        public async Task GetManyNegative()
        {
            var random = new Random();
            var count  = random.Next(1, 25);

            var storage = new StorageQueue(QueueName, ConnectionString);

            for (var i = 0; i < count; i++)
            {
                var msg = new CloudQueueMessage(Guid.NewGuid().ToByteArray());
                await storage.Send(msg);
            }

            var returned = await storage.GetMany(-1);

            Assert.AreEqual(1, returned.Count());
        }
Exemplo n.º 13
0
        public async Task RoundTripMany()
        {
            var random = new Random();
            var count  = random.Next(1, 25);

            StorageQueue storage = await QueueSetup();

            for (var i = 0; i < count; i++)
            {
                var msg = new CloudQueueMessage(Guid.NewGuid().ToByteArray());
                await storage.Send(msg);
            }

            var returned = await storage.GetMany(count);

            Assert.AreEqual(count, returned.Count());
            await storage.Delete();
        }