示例#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>());
        }
示例#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);
        }
示例#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);
        }
示例#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);
        }
示例#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);
        }
示例#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();
        }
示例#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();
        }
示例#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();
        }
示例#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);
        }
示例#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();
        }
示例#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();
        }
示例#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());
        }
示例#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();
        }