Example #1
0
        public void ShouldNotThrow_When_Multiple_Threads_Are_Writing_While_Reading_Custom_Index_Keys()
        {
            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.Indexes.Name.All.Keys.Take(100).ToList();
                    Thread.Sleep(10);
                }
            });

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