public void Can_roundtrip_XDoc()
 {
     var doc = new XDoc("foo").Elem("bar", "baz");
     var serializer = new XDocQueueItemSerializer();
     var stream = serializer.ToStream(doc);
     stream.Seek(0, SeekOrigin.Begin);
     Assert.AreEqual(doc,serializer.FromStream(stream));
 }
Beispiel #2
0
        public void Can_roundtrip_XDoc()
        {
            var doc        = new XDoc("foo").Elem("bar", "baz");
            var serializer = new XDocQueueItemSerializer();
            var stream     = serializer.ToStream(doc);

            stream.Seek(0, SeekOrigin.Begin);
            Assert.AreEqual(doc, serializer.FromStream(stream));
        }
Beispiel #3
0
 public void Perf_test_multi_thread_put_peek_and_take_with_memorystream_queue()
 {
     using (var stream = new MemoryStream()) {
         var queueStream = new SingleFileQueueStream(stream);
         var serializer  = new XDocQueueItemSerializer();
         using (ITransactionalQueue <XDoc> queue = new TransactionalQueue <XDoc>(queueStream, serializer)) {
             Perf_test_multi_thread_put_peek_and_take(queue);
         }
     }
 }
Beispiel #4
0
        public void Perf_test_multi_thread_put_peek_and_take_with_single_file_queue()
        {
            var file = Path.GetTempFileName();

            try {
                var queueStream = new SingleFileQueueStream(file);
                var serializer  = new XDocQueueItemSerializer();
                using (ITransactionalQueue <XDoc> queue = new TransactionalQueue <XDoc>(queueStream, serializer)) {
                    Perf_test_single_thread_put_peek_and_take(queue);
                }
            } finally {
                _log.DebugFormat("wiping xdoc queue");
                File.Delete(file);
            }
        }
Beispiel #5
0
 public void Load_test_mixed_put_peek_take_with_multi_file_queue()
 {
     var path = Path.Combine(Path.GetTempPath(), StringUtil.CreateAlphaNumericKey(6));
     var serializer = new XDocQueueItemSerializer();
     Func<TransactionalQueue<XDoc>> ctor = () => {
         var queueStream = new MultiFileQueueStream(path, 500 * 1024);
         var q = new TransactionalQueue<XDoc>(queueStream, serializer) { DefaultCommitTimeout = TimeSpan.FromSeconds(5) };
         return q;
     };
     try {
         Load_test(ctor);
     } finally {
         Directory.Delete(path, true);
     }
 }
Beispiel #6
0
        public void Perf_test_multi_thread_put_peek_and_take_with_multi_file_queue()
        {
            var path = Path.Combine(Path.GetTempPath(), StringUtil.CreateAlphaNumericKey(6));

            try {
                var serializer  = new XDocQueueItemSerializer();
                var queueStream = new MultiFileQueueStream(path, 500 * 1024);
                using (ITransactionalQueue <XDoc> queue = new TransactionalQueue <XDoc>(queueStream, serializer)
                {
                    DefaultCommitTimeout = TimeSpan.FromSeconds(5)
                }) {
                    Perf_test_multi_thread_put_peek_and_take(queue);
                }
            } finally {
                Directory.Delete(path, true);
            }
        }
Beispiel #7
0
 public void End_to_end_test()
 {
     var file = Path.GetTempFileName();
     try {
         var queueStream = new SingleFileQueueStream(file);
         var serializer = new XDocQueueItemSerializer();
         using(var queue = new TransactionalQueue<XDoc>(queueStream, serializer)) {
             var doc = new XDoc("foo");
             queue.Enqueue(doc);
             var v = queue.Dequeue();
             Assert.AreEqual(doc, v.Value);
             Assert.IsTrue(queue.CommitDequeue(v.Id));
         }
     } finally {
         File.Delete(file);
     }
 }
Beispiel #8
0
        public void End_to_end_test()
        {
            var file = Path.GetTempFileName();

            try {
                var queueStream = new SingleFileQueueStream(file);
                var serializer  = new XDocQueueItemSerializer();
                using (var queue = new TransactionalQueue <XDoc>(queueStream, serializer)) {
                    var doc = new XDoc("foo");
                    queue.Enqueue(doc);
                    var v = queue.Dequeue();
                    Assert.AreEqual(doc, v.Value);
                    Assert.IsTrue(queue.CommitDequeue(v.Id));
                }
            } finally {
                File.Delete(file);
            }
        }
Beispiel #9
0
        public void Load_test_mixed_put_peek_take_with_multi_file_queue()
        {
            var path       = Path.Combine(Path.GetTempPath(), StringUtil.CreateAlphaNumericKey(6));
            var serializer = new XDocQueueItemSerializer();
            Func <TransactionalQueue <XDoc> > ctor = () => {
                var queueStream = new MultiFileQueueStream(path, 500 * 1024);
                var q           = new TransactionalQueue <XDoc>(queueStream, serializer)
                {
                    DefaultCommitTimeout = TimeSpan.FromSeconds(5)
                };
                return(q);
            };

            try {
                Load_test(ctor);
            } finally {
                Directory.Delete(path, true);
            }
        }
Beispiel #10
0
        public void Load_test_mixed_put_peek_take_with_single_file_queue()
        {
            var file       = Path.GetTempFileName();
            var serializer = new XDocQueueItemSerializer();
            Func <TransactionalQueue <XDoc> > ctor = () => {
                var queueStream = new SingleFileQueueStream(file);
                var q           = new TransactionalQueue <XDoc>(queueStream, serializer)
                {
                    DefaultCommitTimeout = TimeSpan.FromSeconds(5)
                };
                return(q);
            };

            try {
                Load_test(ctor);
            } finally {
                File.Delete(file);
            }
        }
Beispiel #11
0
 public void Load_test_mixed_put_peek_take_with_single_file_queue()
 {
     var file = Path.GetTempFileName();
     var serializer = new XDocQueueItemSerializer();
     Func<TransactionalQueue<XDoc>> ctor = () => {
         var queueStream = new SingleFileQueueStream(file);
         var q = new TransactionalQueue<XDoc>(queueStream, serializer) { DefaultCommitTimeout = TimeSpan.FromSeconds(5) };
         return q;
     };
     try {
         Load_test(ctor);
     } finally {
         File.Delete(file);
     }
 }
Beispiel #12
0
 public void Perf_test_single_thread_put_peek_and_take_with_single_file_queue()
 {
     var file = Path.GetTempFileName();
     try {
         var queueStream = new SingleFileQueueStream(file);
         var serializer = new XDocQueueItemSerializer();
         using(ITransactionalQueue<XDoc> queue = new TransactionalQueue<XDoc>(queueStream, serializer)) {
             Perf_test_single_thread_put_peek_and_take(queue);
         }
     } finally {
         _log.DebugFormat("wiping xdoc queue");
         File.Delete(file);
     }
 }
Beispiel #13
0
 public void Perf_test_single_thread_put_peek_and_take_with_multi_file_queue()
 {
     var path = Path.Combine(Path.GetTempPath(), StringUtil.CreateAlphaNumericKey(6));
     try {
         var serializer = new XDocQueueItemSerializer();
         var queueStream = new MultiFileQueueStream(path, 500 * 1024);
         using(ITransactionalQueue<XDoc> queue = new TransactionalQueue<XDoc>(queueStream, serializer) { DefaultCommitTimeout = TimeSpan.FromSeconds(5) }) {
             Perf_test_single_thread_put_peek_and_take(queue);
         }
     } finally {
         Directory.Delete(path, true);
     }
 }
Beispiel #14
0
 public void Perf_test_single_thread_put_peek_and_take_with_memorystream_queue()
 {
     using(var stream = new MemoryStream()) {
         var queueStream = new SingleFileQueueStream(stream);
         var serializer = new XDocQueueItemSerializer();
         using(ITransactionalQueue<XDoc> queue = new TransactionalQueue<XDoc>(queueStream, serializer)) {
             Perf_test_single_thread_put_peek_and_take(queue);
         }
     }
 }