Exemplo n.º 1
0
        public async Task PeekGeneric()
        {
            StorageQueue storage = await QueueSetup();

            var expected = new TestCustomObject {
                FooInt = 42, FooString = "The Answer"
            };
            var expected2 = new TestCustomObject {
                FooInt = 43, FooString = "The Answer 2"
            };
            var expectedList = new List <TestCustomObject> {
                expected, expected2
            };

            foreach (var item in expectedList)
            {
                await storage.SendAsync(item);
            }

            var peeked = (await storage.PeekAsync <TestCustomObject>(2)).ToList();

            Assert.AreEqual(expectedList.Count, peeked.Count);
            Assert.IsTrue(expectedList.Any(m => m.FooInt == expected.FooInt && m.FooString == expected.FooString));
            Assert.IsTrue(expectedList.Any(m => m.FooInt == expected2.FooInt && m.FooString == expected2.FooString));

            var returned = (await storage.GetManyAsync <TestCustomObject>()).ToList();

            Assert.AreEqual(expectedList.Count, returned.Count);
            Assert.IsTrue(returned.Any(m => m.FooInt == expected.FooInt && m.FooString == expected.FooString));
            Assert.IsTrue(returned.Any(m => m.FooInt == expected2.FooInt && m.FooString == expected2.FooString));
            await storage.Delete();
        }
Exemplo n.º 2
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();
        }