Пример #1
0
        public void AckMultiMoreThanBatch()
        {
            using (var streamOne = new MemoryStream())
                using (var streamTwo = new MemoryStream())
                {
                    streamOne.WriteByte(0);
                    streamTwo.WriteByte(1);

                    for (var i = 0; i < Queue.ACK_MULTI_BATCH_SIZE; ++i)
                    {
                        var message = new BsonDocument("key", i);

                        streamOne.Position = 0;
                        streamTwo.Position = 0;
                        queue.Send(message, DateTime.Now, 0.0, new Dictionary <string, Stream> {
                            { "one", streamOne }, { "two", streamTwo }
                        });
                    }
                }

            queue.Send(new BsonDocument("key", "value"));

            var handles = new Handle[Queue.ACK_MULTI_BATCH_SIZE];

            for (var i = 0; i < handles.Length; ++i)
            {
                handles[i] = queue.Get(new QueryDocument("key", i), TimeSpan.MaxValue, TimeSpan.Zero).Handle;
            }

            Assert.AreEqual(Queue.ACK_MULTI_BATCH_SIZE + 1, collection.Count());
            Assert.AreEqual(Queue.ACK_MULTI_BATCH_SIZE * 2, gridfs.Files.Count());
            Assert.AreEqual(Queue.ACK_MULTI_BATCH_SIZE * 2, gridfs.Chunks.Count());

            queue.AckMulti(handles);

            Assert.AreEqual(1, collection.Count());
            Assert.AreEqual(0, gridfs.Files.Count());
            Assert.AreEqual(0, gridfs.Chunks.Count());
        }