Example #1
0
        public void ShouldNotThrow_When_Multiple_Threads_Are_Deleting_Objects()
        {
            var session  = new Session(_platform, "/");
            var articles = session ["data"].Collection <Article, int, ArticleIndexes> ("articles", a => a.ID);

            for (int i = 0; i < 1000; i++)
            {
                articles.Persist(new Article {
                    ID = i
                });
            }

            var deleter = new Deleter(articles, 1);
            var writer  = new Writer(articles, int.MaxValue / 2);

            deleter.Start();
            writer.Start();
            Assert.DoesNotThrow(() =>
            {
                foreach (var i in Enumerable.Range(0, 20))
                {
                    articles.Indexes.Name.All.Keys.Take(100).ToList();
                    Thread.Sleep(10);
                }
            });

            writer.Stop();
        }
Example #2
0
        public void ShouldNotThrow_When_Multiple_Threads_Are_Writing_While_Reading_ID_Index()
        {
            var session  = new Session(_platform, "/");
            var articles = session["data"].Collection <Article, int, ArticleIndexes>("articles", a => a.ID);

            var writer1 = new Writer(articles, 1);
            var writer2 = new Writer(articles, int.MaxValue / 2);

            writer1.Start();
            writer2.Start();
            Assert.DoesNotThrow(() =>
            {
                foreach (var i in Enumerable.Range(0, 20))
                {
                    articles.All.Take(100).ToList();
                    Thread.Sleep(10);
                }
            });

            writer1.Stop();
            writer2.Stop();
        }