Esempio n. 1
0
        public async Task ApplyCappedCollectionModelWithoutIndex()
        {
            const int maxDocuments   = 100;
            const int maxSizeInBytes = maxDocuments * 1000;

            var model = new CappedCollectionModel
            {
                CollectionName       = _collectionName,
                MaxSizeInBytes       = maxSizeInBytes,
                MaxNumberOfDocuments = maxDocuments,
            };

            var package = new CollectionModelPackage(_documentDatabase, model, new CollectionModelSettings {
                ReCreate = true
            });

            bool result = await package.Apply(_workContext);

            result.Should().BeTrue();

            (await _documentDatabase.CollectionExist(_workContext, _collectionName)).Should().BeTrue();
            CollectionDetailV1 detail = await _documentDatabase.GetCollectionDetail(_workContext, _collectionName);

            detail.Should().NotBeNull();
            detail.Name.Should().Be(_collectionName);
            detail.Type.Should().Be("collection");
            detail.Readonly.Should().BeFalse();
            detail.Capped.Should().BeTrue();
            detail.MaxDocuments.Should().HaveValue();
            detail.MaxDocuments.Should().Be(maxDocuments);
            detail.MaxSizeInBytes.Should().HaveValue();
            detail.MaxSizeInBytes.Should().BeGreaterOrEqualTo(maxSizeInBytes);
        }