public async Task Listed_Collections_Should_Not_Be_Tracked()
        {
            // Given
            var collectionsNames = new[] { "Collection1", "Collection2", "Collection3" };
            await Database.OnceAndSaveAsync(async db =>
            {
                var collections = collectionsNames.Select(name => new Collection {
                    Name = name
                });
                await db.AddRangeAsync(collections);
            });

            // When
            await Database.OnceAsync(async db =>
            {
                var repository  = new CollectionRepository(db);
                var collections = await repository.ListAsync();

                foreach (var collection in collections)
                {
                    collection.Name = $"Manipulated {collection.Name}";
                }

                await db.SaveChangesAsync();
            });

            // Then
            var collections = await Database.OnceAsync(async db =>
                                                       await db.Collections.ToArrayAsync());

            Assert.True(collections.All(collection => collectionsNames.Contains(collection.Name)));
        }
        public async Task Listed_Queryable_Collections_Should_Not_Be_Tracked()
        {
            // Given
            const string prefix = "Collection";
            await Database.OnceAndSaveAsync(async db =>
            {
                var collections = Enumerable.Range(0, 10).Select(i => new Collection {
                    Name = $"{prefix}{i}"
                });
                await db.AddRangeAsync(collections);
            });

            // When
            await Database.OnceAsync(async db =>
            {
                var repository = new CollectionRepository(db);
                var options    = new CollectionListOptions
                {
                    Limit = 3,
                };
                var collections = await repository.ListAsync(options);

                foreach (var collection in collections)
                {
                    collection.Name = $"Manipulated {collection.Name}";
                }

                await db.SaveChangesAsync();
            });

            // Then
            var collections = await Database.OnceAsync(async db =>
                                                       await db.Collections.ToArrayAsync());

            Assert.True(collections.All(collection => collection.Name.StartsWith(prefix)));
        }
        public async Task <IActionResult> ListCollectionAsync([FromQuery] CollectionListOptions options)
        {
            var collections = await _repository.ListAsync(options);

            return(new JsonResult(collections));
        }