Exemple #1
0
        public async Task Flush_GetByQuery_ReturnsEmpty(int tasksCount)
        {
            using var index = new StringIndex <string>();
            var inputs = new Dictionary <string, IEnumerable <string> >();

            for (var i = 0; i < tasksCount; i++)
            {
                inputs[Guid.NewGuid().ToString()] = new []
                {
                    Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), Guid.NewGuid().ToString(),
                                               Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), Guid.NewGuid().ToString()
                }
            }
            ;

            var tasks = new List <Task>();

            foreach (var(q, input) in inputs)
            {
                tasks.Add(Task.Run(() => index.Add(q, input)));
            }

            await Task.WhenAll(tasks);

            await Task.Run(() => index.Flush());

            var getTasks = inputs.Keys.Select(x => Task.Run(() => index.Get(x))).ToList();

            await Task.WhenAll(getTasks);

            foreach (var task in getTasks)
            {
                Assert.Empty(task.Result);
            }
        }