Пример #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();
        }
Пример #2
0
        public async Task GenericGet()
        {
            StorageQueue storage = await QueueSetup();

            var expected = new TestCustomObject {
                FooInt = 42, FooString = "The Answer"
            };
            await storage.SendAsync(expected);

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

            Assert.AreEqual(expected.FooString, returned.FooString);
            Assert.AreEqual(expected.FooInt, returned.FooInt);
            await storage.Delete();
        }
Пример #3
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.SendAsync(Guid.NewGuid());
            }

            var result = await storage.ApproixmateMessageCount();

            Assert.AreEqual(count, result);
            await storage.Delete();
        }
Пример #4
0
        public async Task RoundTripObject()
        {
            StorageQueue storage = await QueueSetup();

            var expected = new TestCustomObject {
                FooInt = 42, FooString = "The Answer"
            };
            await storage.SendAsync <TestCustomObject>(expected);

            var returned = await storage.Get();

            var deserialized = JsonConvert.DeserializeObject <TestCustomObject>(returned.AsString);

            Assert.AreEqual(expected.FooString, deserialized.FooString);
            Assert.AreEqual(expected.FooInt, deserialized.FooInt);
            await storage.Delete();
        }