Skip to content

Commit 0e2123a

Browse files
committed
CSHARP-1191: Added an integration test for GridFSBucket DropAsync method.
1 parent d1d7e42 commit 0e2123a

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/MongoDB.Driver.GridFS.Tests/GridFSBucketTests.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
using FluentAssertions;
2323
using MongoDB.Bson;
2424
using MongoDB.Driver.Core.Clusters;
25+
using MongoDB.Driver.Tests;
2526
using NSubstitute;
2627
using NUnit.Framework;
2728

@@ -171,6 +172,22 @@ public void DownloadToStreamByNameAsync_should_throw_when_filename_is_null()
171172
action.ShouldThrow<ArgumentNullException>().And.ParamName.Should().Be("filename");
172173
}
173174

175+
[Test]
176+
public async Task DropAsync_should_drop_the_files_and_chunks_collections()
177+
{
178+
var client = DriverTestConfiguration.Client;
179+
var database = client.GetDatabase(DriverTestConfiguration.DatabaseNamespace.DatabaseName);
180+
var subject = new GridFSBucket(database);
181+
await subject.UploadFromBytesAsync("test", new byte[] { 0 }); // causes the collections to be created
182+
183+
await subject.DropAsync();
184+
185+
var collections = await (await database.ListCollectionsAsync()).ToListAsync();
186+
var collectionNames = collections.Select(c => c["name"].AsString);
187+
collectionNames.Should().NotContain("fs.files");
188+
collectionNames.Should().NotContain("fs.chunks");
189+
}
190+
174191
[Test]
175192
public void Findsync_should_throw_when_filter_is_null()
176193
{

0 commit comments

Comments
 (0)